[Insight-users] Separating saturation from RGB image

David Doria daviddoria at gmail.com
Mon Feb 21 10:56:50 EST 2011


On Mon, Feb 21, 2011 at 7:13 AM, Piotr Majkrzak <petrol.91 at gmail.com> wrote:
> Dear all,
> I'm writing to you because i have a problem with ITK library. It's my first
> program with it.
> I don't know how to use ITK to separate saturation layer of RGB image.
> My function:
> double Sat(itk::RGBPixel<uint8_t> & RGB)
> {
>   return static_cast<double>(std::max(RGB[0],std::max(RGB[1],RGB[2])) -
> std::min(RGB[0],std::min(RGB[1],RGB[2]))) /
> static_cast<double>(std::max(RGB[0],std::max(RGB[1],RGB[2])));
> }
> is good for one pixel, but I don't know how to apply it for all pixels and
> create new image.
> Yours sincerely
> Piotr Majkrzak

To apply a function to every pixel in an image, you should use
UnaryFunctorImageFilter.

Here is an example:
http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/UnaryFunctorImageFilter

David


More information about the Insight-users mailing list