<DIV>Hi Chris,</DIV>  <DIV>&nbsp;</DIV>  <DIV>I guess you are not correct</DIV>  <DIV>I've compared the values obatined by 2 ways:</DIV>  <DIV>&nbsp;</DIV>  <DIV>1) &nbsp;typedef double PixelType;</DIV>  <DIV>&nbsp;</DIV>  <DIV>2) typedef itk::RGBPixel&lt;double&gt; PixelType;</DIV>  <DIV>----&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>typedef itk::Image&lt;PixelType, 2&gt; ImageType;</DIV>  <DIV>&nbsp;</DIV>  <DIV>With these 2 cases I read color image from file and get pixel values.</DIV>  <DIV>In case 2 I did such conversion (as&nbsp;you told)</DIV>  <DIV>pixelvalue = sqrt(pixel.GetRed()*pixel.GetRed() + pixel.GetGreen()*pixel.GetGreen() + pixel.GetBlue()*pixel.GetBlue());</DIV>  <DIV>&nbsp;</DIV>  <DIV>and compare it with pixel value which&nbsp;I get from case 1, i.e. <FONT size=2>pixelvalue = image-&gt;GetPixel(index);</FONT></DIV>  <DIV>these two values are&nbsp;differ!</DIV>  <DIV>So I looked to the code of&nbsp;ConvertPixelBuffer class and found</DIV>  <DIV><FONT size=2> 
 <div>ConvertRGBToGray</div>  <div>{</div></FONT></DIV>  <DIV><FONT size=2>  <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputComponentType val = static_cast&lt;OutputComponentType&gt;( </div>  <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (2125.0 * static_cast&lt;OutputComponentType&gt;(*inputData) +</div>  <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7154.0 * static_cast&lt;OutputComponentType&gt;(*(inputData+1)) +</div>  <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0721.0 * static_cast&lt;OutputComponentType&gt;(*(inputData+2))) / 10000.0 );</div></FONT></DIV>  <DIV>}</DIV>  <DIV><BR>and tried the same thing with this convertion: the values were equal.</DIV>  <DIV>However thanks a lot. Everything is clear already.</DIV>  <DIV>&nbsp;</DIV>  <DIV>Albert</DIV>  <DIV>&nbsp;</DIV>  <DIV><BR><B><I>Chris Farmer &lt;cfarmer@scitegic.com&gt;</I></B> wrote:</DIV>  <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi again
 Albert,<BR><BR><BR>It looks like all that logic is inside the ConvertPixelBuffer class which takes a ConvertPixelTraits template argument. You could override the current conversion behavior and supply your own rules by specifying a custom ConvertPixelTraits type into your file reader. That said, the default implementation calls into the GetScalarValue() method of the PixelType. If your type is RGBPixel, then this is the conversion:<BR><BR>ComponentType GetScalarValue() const<BR>{<BR>return static_cast<COMPONENTTYPE> (vcl_sqrt(<BR>static_cast<DOUBLE>(this-&gt;operator[](0)) * static_cast<DOUBLE>(this-&gt;operator[](0)) +<BR>static_cast<DOUBLE>(this-&gt;operator[](1)) * static_cast<DOUBLE>(this-&gt;operator[](1)) +<BR>static_cast<DOUBLE>(this-&gt;operator[](2)) * static_cast<DOUBLE>(this-&gt;operator[](2)))); <BR>}<BR><BR>So, it appears to be giving each of the R, G, and B equal weighting.<BR><BR><BR><BR><BR>&nbsp;<BR>-----Original Message-----<BR>From: Albert Chitemyan
 [mailto:abbs_c@yahoo.com] <BR>Sent: Wednesday, November 30, 2005 12:08 AM<BR>To: Chris Farmer<BR>Cc: insight-users@itk.org<BR>Subject: RE: [Insight-users] How does ITK covert color image into grayscaleimage?<BR><BR>Hi Chris,<BR>&nbsp;<BR>I didn't&nbsp;mean that.<BR>I mean, I have got code<BR>&nbsp;<BR>typedef itk::Image<UNSIGNED 2 char,> ImageType;<BR>typedef itk::ImageFileReader<IMAGETYPE> ReaderType;<BR>ReaderType::Pointer reader = ReaderType::New();<BR>&nbsp;<BR>reader-&gt;SetFileName("d:\\image.bmp");//color image<BR>reader-&gt;Update();<BR>&nbsp;<BR>unsigned char* buffer&nbsp;= reader-&gt;GetOutput()-&gt;GetBufferPointer();<BR>&nbsp;<BR>what does contain buffer? Is its elements RED(or GREEN or BLUE) channel of color image?<BR>As I know it isn't so. In that case how is obtained these values?<BR>&nbsp;<BR>&nbsp;<BR>Albert<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR><BR><BR>Chris Farmer <CFARMER@SCITEGIC.COM>wrote:<BR><BR><BR>Hi Albert,<BR><BR>Check out the itk::RGBPixel type. If
 you use RGBPixel as the template type of your itk::Image, then you'll get access to the R, G, and B channels in your image. There are some good sections on this early in the ITK software guide. You're right that many ITK operations are not available to RGB images. You could flatten your images to a scalar pixel type with the RGBToLuminanceImageFilter or treat it as a vector image with the RGBToVectorImageAdaptor. There are at least a few messages in the very recent past from the list that mention these classes, and there are some examples in the ITK source distribution that show how you can work with RGB images.<BR><BR><BR>Chris<BR><BR><BR><BR><BR>&nbsp;<BR>-----Original Message-----<BR>From: Albert Chitemyan [mailto:abbs_c@yahoo.com] <BR>Sent: Tuesday, November 29, 2005 11:26 PM<BR>To: insight-users@itk.org<BR>! Subject: [Insight-users] How does ITK covert color image into grayscaleimage?<BR><BR>Hi all,<BR>&nbsp;<BR>As far as I know ITK's most classes are dealing with grayscale
 images.<BR>How does&nbsp;ImageFileReader read pixel values from color image?. <BR>Does&nbsp;it take only one component(e.g. red)&nbsp;of RGB, or&nbsp;copmute pixel value&nbsp;using those 3 components?(grayscale pixel&nbsp;value = R*a + G*b + B*c).<BR>&nbsp;<BR>Thanks.<BR>&nbsp;<BR>Albert<BR>&nbsp;<BR>&nbsp;<BR><BR>Yahoo! Music Unlimited - Access over 1 million songs. Try it free.<BR>Click here to report this email as spam.<BR><BR><BR>Yahoo! Music Unlimited - Access over 1 million songs. Try it free.<BR></BLOCKQUOTE>  <DIV><BR></DIV><BR><BR><p>
                <hr size=1> <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=37474/*http://promo.yahoo.com/broadband/ 
">Yahoo! DSL</a> Something to write home about. Just $16.99/mo. or less