[vtkusers] RGBA to gray in VTK
Prathamesh Kulkarni
prathameshmkulkarni at gmail.com
Wed Jul 21 16:05:23 EDT 2010
I have the output of vtkImageBlend which is RGBA, and I need to convert this
to grayscale.
Prathamesh
On Wed, Jul 21, 2010 at 3:00 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100721/6c07290b/attachment.htm>
More information about the vtkusers
mailing list