<div dir="ltr">Thanks! Here is what I did:<br><br> int channels_before_component_filter = RGBA_image_data->GetNumberOfScalarComponents(); //4 <br> <br> vtkSmartPointer<vtkImageExtractComponents> component_extractor = vtkSmartPointer<vtkImageExtractComponents>::New();<br>
component_extractor->SetInput(RGBA_image_data);<br> component_extractor->SetComponents(0, 1, 2);<br> component_extractor->Update();<br><br> int channels_before_luminance_filter = component_extractor->GetOutput()->GetNumberOfScalarComponents(); //3<br>
<br> vtkSmartPointer<vtkImageLuminance> luminance_filter = vtkSmartPointer<vtkImageLuminance>::New();<br> luminance_filter->SetInput(component_extractor->GetOutput());<br> luminance_filter->Update();<br>
<br> int channels_after_luminance_filter = luminance_filter->GetOutput()->GetNumberOfScalarComponents(); //1<br><br><br>Prathamesh<br><br><div class="gmail_quote">On Wed, Jul 21, 2010 at 3:12 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Wed, Jul 21, 2010 at 4:09 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
> You need to be careful here. There are two ways to convert images to greyscale:<br>
><br>
> vtkImageLuminance -> use luminance equation for properly weighting<br>
> the R, G, and B<br>
><br>
> vtkImageMagnitude -> do a sum-of-squares computation<br>
><br>
> These filters are meant for different things. For RGB, you usually<br>
> want to use luminance because in the RGB colorspace, G has slightly<br>
> higher luminance than R, and both have much higher luminance than B.<br>
><br>
> The vtkImageMagnitude filter is meant for use on vector images, not so<br>
> much for RGB images.<br>
><br>
> You can use vtkImageExtractComponents to extract the RGB components<br>
> from an RGBA image:<br>
> vtkImageExtractComponents::SetComponents(0, 1, 2);<br>
><br>
> David<br>
<br>
</div>Here are examples of what David G. said:<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Images/ImageLuminance" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Images/ImageLuminance</a><br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Images/ExtractComponents" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Images/ExtractComponents</a><br>
<br>
Thanks,<br>
<font color="#888888"><br>
David<br>
</font></blockquote></div><br></div>