<div dir="ltr">Thanks! Here is what I did:<br><br>    int channels_before_component_filter = RGBA_image_data-&gt;GetNumberOfScalarComponents(); //4   <br> <br>    vtkSmartPointer&lt;vtkImageExtractComponents&gt; component_extractor = vtkSmartPointer&lt;vtkImageExtractComponents&gt;::New();<br>
    component_extractor-&gt;SetInput(RGBA_image_data);<br>    component_extractor-&gt;SetComponents(0, 1, 2);<br>    component_extractor-&gt;Update();<br><br>    int channels_before_luminance_filter = component_extractor-&gt;GetOutput()-&gt;GetNumberOfScalarComponents(); //3<br>
<br>    vtkSmartPointer&lt;vtkImageLuminance&gt; luminance_filter = vtkSmartPointer&lt;vtkImageLuminance&gt;::New();<br>    luminance_filter-&gt;SetInput(component_extractor-&gt;GetOutput());<br>    luminance_filter-&gt;Update();<br>
    <br>    int channels_after_luminance_filter = luminance_filter-&gt;GetOutput()-&gt;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">&lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;</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 &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>

&gt; You need to be careful here.  There are two ways to convert images to greyscale:<br>
&gt;<br>
&gt;  vtkImageLuminance -&gt; use luminance equation for properly weighting<br>
&gt; the R, G, and B<br>
&gt;<br>
&gt;  vtkImageMagnitude -&gt; do a sum-of-squares computation<br>
&gt;<br>
&gt; These filters are meant for different things.  For RGB, you usually<br>
&gt; want to use luminance because in the RGB colorspace, G has slightly<br>
&gt; higher luminance than R, and both have much higher luminance than B.<br>
&gt;<br>
&gt; The vtkImageMagnitude filter is meant for use on vector images, not so<br>
&gt; much for RGB images.<br>
&gt;<br>
&gt; You can use vtkImageExtractComponents to extract the RGB components<br>
&gt; from an RGBA image:<br>
&gt; vtkImageExtractComponents::SetComponents(0, 1, 2);<br>
&gt;<br>
&gt;  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>