[Insight-users] convert to gray scale image
Luis Ibanez
luis.ibanez at kitware.com
Tue, 20 Apr 2004 13:42:15 -0400
Hi Beck,
Here are some options:
A) Use ImageAdaptors. You decide how to convert color to
grayscale and encode such conversion in the PixelAccessor.
Please read the SoftwareGuide for details.
http://www.itk.org/ItkSoftwareGuide.pdf
Chapter 12, pdf-page 521.
B) Use the UnaryFunctor filter. This is very similar to
Adaptors. In this case you simply encode the color to
grayscale conversion into a Functor. Then instantiate
the UnaryFunctorFilter using your Functor.
You can look at filters like the AsinImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1AsinImageFilter.html
in order to get an idea on how to do this.
C) If your image is coming straight from a file, you could
simply instantiate the input image as being of a single
scalar type. The ImageIO classes convert color to grayscale
when needed. The drawback here is that you don't have any
control on the conversion process.
---
A Bonus: note that there are region growing methods that will
operate directly on RGB images. For example:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VectorConfidenceConnectedImageFilter.html
There is also a LevelSet filter (similar to thresholding +
region growing + regularization) that accepts vector images
(therefore RGB images).
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VectorThresholdSegmentationLevelSetImageFilter.html
Regards,
Luis
--------------
Beck wrote:
> Dear All:
> I want to use NeighborhoodConnectedImageFilter and my images are full
> color images.
> So I want to convert color images to gray scale images as input for
> NeighborhoodConnectedImageFilter.
> How can I convert color images to gray scale images?
> Hope anyone can help.
>
> Thanks
>
> Beck