<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>They do appear a bit different:</div><div><br></div><div><div>template<class T></div><div>typename RGBPixel<T>::ComponentType</div><div>RGBPixel<T></div><div>::GetLuminance() const</div><div>{</div><div> const double luminance = </div><div> 0.30 * this->GetRed() +</div><div> 0.59 * this->GetGreen() +</div><div> 0.11 * this->GetBlue();</div><div> return static_cast<ComponentType>( luminance );</div><div>}</div><div><br></div><div><div>void</div><div>ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits></div><div>::ConvertRGBToGray(InputPixelType* inputData, </div><div> OutputPixelType* outputData , int size)</div><div>{ </div><div> // Weights convert from linear RGB to CIE luminance assuming a</div><div> // modern monitor. See Charles Pontyon's Colour FAQ</div><div> // <a href="http://www.inforamp.net/~poynton/notes/colour_and_gamma/ColorFAQ.html">http://www.inforamp.net/~poynton/notes/colour_and_gamma/ColorFAQ.html</a></div><div> // NOTE: The scale factors are converted to whole numbers for precision</div><div><br></div><div> InputPixelType* endInput = inputData + size*3;</div><div> while(inputData != endInput)</div><div> {</div><div> OutputComponentType val = static_cast<OutputComponentType>( </div><div> (2125.0 * static_cast<OutputComponentType>(*inputData) +</div><div> 7154.0 * static_cast<OutputComponentType>(*(inputData+1)) +</div><div> 0721.0 * static_cast<OutputComponentType>(*(inputData+2))) / 10000.0 );</div><div> inputData += 3;</div><div> OutputConvertTraits::SetNthComponent(0, *outputData++, val);</div><div> }</div><div> </div><div>}</div><div><br></div><div>As far as the "correct" method for converting RGB to Luminance, I am not sure either is completely correct. The problem is that input color RGB values are not profiled, that is we don't know if the color space of the pixels are in sRGB, Adobe RGB etc. For example sRGB does not have constant gamma value through it's space. Without these consideration a correct conversion from RGB to Luminance can not be made.</div><div><br></div><div>However for your particular problem, it most likely does not matter what is the correct Luminance. As you are performing registration, this conversion is merely needed for evaluating the registration metric. This is a more difficult problem, without a correct or best way to do it. For the Visible Human I have used just the Red channel before. </div><div><br></div><div>Brad</div><div><br></div></div></div><div><br><div><div>On Jul 8, 2009, at 3:58 PM, Sharath Venkatesha wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: arial, helvetica, sans-serif; font-size: 10pt; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hi Bradley,<br><br>Thanks for the information.<br><br>I got the doubt as my results change in the two cases (though by very small amount, initially ), i.e with and without using itkRGBToLuminanceImageFilter.<br>I feed the input images to registration filter, and the output parameters of registration change (in second decimal values) per iteration.<br><br>And over multiple iterations of the optimizer, I get a change of 2-3 pixels in translation parameters, and the angle also changes by 0.5 degrees, for a particular set of input images. All the other parameters involved remain constant in both the cases.<br><br>I want to know the correct method to follow.<br><br>Thanks,<br>Sharath Venkatesha<br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold; ">From:</span></b><span class="Apple-converted-space"> </span>Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>><br><b><span style="font-weight: bold; ">To:</span></b><span class="Apple-converted-space"> </span>Sharath Venkatesha <<a href="mailto:sharath20284@yahoo.com">sharath20284@yahoo.com</a>><br><b><span style="font-weight: bold; ">Cc:</span></b><span class="Apple-converted-space"> </span>Insight users <<a href="mailto:insight-users@itk.org">insight-users@itk.org</a>><br><b><span style="font-weight: bold; ">Sent:</span></b><span class="Apple-converted-space"> </span>Wednesday, July 8, 2009 12:32:07 PM<br><b><span style="font-weight: bold; ">Subject:</span></b><span class="Apple-converted-space"> </span>Re: [Insight-users] RGB Input to ImageFileReader defined with 'unsigned char' type ?<br></font><br>Hello Sharath,<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This conversion is done through with itk::ConvertPixelBuffer:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span><a target="_blank" href="http://www.itk.org/Doxygen/html/classitk_1_1ConvertPixelBuffer.html">http://www.itk.org/Doxygen/html/classitk_1_1ConvertPixelBuffer.html</a></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This class is responsible for doing all the conversions that occur when reading an image from a file into your itk::Image. When the types don't match it auto-magically converts the types. This enable one to read a file of chars into an itk::Image of floats with out any problems.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">For you particular case it computes the luminance based on the RGB values to get "grey" pixels. The RGBToLuminance filter should give simular results as well. </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Brad</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">On Jul 8, 2009, at 3:19 PM, Sharath Venkatesha wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br>Hi,<br><br>I observed that it works, if I give RGB input image to a ImageFileReader defined with 'unsigned char' type.<span class="Apple-converted-space"> </span><br>Is the behaviour defined?Are there many approximations involved?<br><br>I generally use itkRGBToLuminanceImageFilter to convert RGB input images to grayscale, before performing registration.<br><br><br>Thanks,<br>Sharath<br><br><br><br><br>_____________________________________<br>Powered by<span class="Apple-converted-space"> </span><a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><span><a target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br><br><span>Please keep messages on-topic and check the ITK FAQ at:<span class="Apple-converted-space"> </span><a target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a></span><br><br>Follow this link to subscribe/unsubscribe:<br><span><a target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a></span><br></div></blockquote></div><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="font-size: 12px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; ">========================================================</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; ">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="Arial"><span class="Apple-style-span" style="font-family: Arial; "><span class="Apple-style-span" style="font-family: Arial; ">Lockheed Martin </span></span></font><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; ">Contractor for</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; ">Office of High Performance Computing and Communications</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; ">National Library of Medicine<span class="Apple-converted-space"> </span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font size="3" face="Helvetica" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; "><a rel="nofollow" ymailto="mailto:blowekamp@mail.nih.gov" target="_blank" href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></div><br class="Apple-interchange-newline"></span></div></span></div><br></div></div></div></div><br></div><br class="Apple-interchange-newline"></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">========================================================</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font class="Apple-style-span" face="Arial"><span class="Apple-style-span" style="font-family: Arial; "><span class="Apple-style-span" style="font-family: Arial; ">Lockheed Martin </span></span></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Contractor for</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Office of High Performance Computing and Communications</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">National Library of Medicine<span class="Apple-converted-space"> </span></font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span> </div><br></div></body></html>