[vtkusers] RGBA to gray in VTK
David Doria
daviddoria+vtk at gmail.com
Wed Jul 21 16:00:48 EDT 2010
On Wed, Jul 21, 2010 at 3:51 PM, Prathamesh Kulkarni
<prathameshmkulkarni at gmail.com> wrote:
> Hello all,
>
> I am trying to convert an image from RGBA to gray scale so that I can
> compare it pixel by pixel with another gray scale image. Following is what I
> did:
>
> vtkSmartPointer<vtkImageMapToColors> gray_from_RGBA_map =
> vtkSmartPointer<vtkImageMapToColors>::New();
> grayd_from_RGB_map->SetInput(RGBA_image_data);
>
> gray_from_RGB_map->SetOutputFormatToLuminance();
>
> gray_from_RGB_map->Update();
>
> int channels =
> gray_from_RGBA_map->GetOutput()->GetNumberOfScalarComponents();
>
> The variable "channels" is 4 irrespective of whether I include a
> vtkImageMapToColors in the pipeline.
>
> Am I doing anything wrong here? What is the best way to do this?
>
>
> Any help will be highly appreciated.
>
>
> Prathamesh
Is the 'A' important? Or do you just want RGB to grey?
http://www.vtk.org/Wiki/VTK/Examples/Images/ConvertToGreyScale
Thanks,
David
More information about the vtkusers
mailing list