<div>Sebastien,</div>
<div>&nbsp;</div>
<div>Thanks for the bug report and sample data. I fixed the problem. Update Code/IO/itkBMPImageIO.cxx and let us know if you still have problems.</div>
<div>&nbsp;</div>
<div>I also added your data to Testing/Data/Input and added 2 tests to read your data. The next time you update all of itk, you&#39;ll get the data and new tests.</div>
<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>Bill<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/25/07, <b class="gmail_sendername">Bill Lorensen</b> &lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Sebatien,</div>
<div>&nbsp;</div>
<div>This looks like a bug to me. Can you add it to the bug tracker: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://public.kitware.com/Bug/view_all_bug_page.php" target="_blank">http://public.kitware.com/Bug/view_all_bug_page.php
</a></div>
<div>&nbsp;</div>
<div>Also, include url&#39;s to a sample 24 bit and 8 bit grayscale images.</div>
<div>&nbsp;</div>
<div>I looked at the itkBMPImageIO.cxx code. For sure, it is not setting the pixel type correctly. It looks like it should be setting the number of components correctly, but the logic may be flawed.</div>
<div>&nbsp;</div>
<div>Bill<br>&nbsp;</div>
<div>
<div><span class="e" id="q_115d81a54e0e5a75_1"><span class="gmail_quote">On 10/25/07, <b class="gmail_sendername">Sébastien Fricker</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sebastien.fricker@phaseview.net" target="_blank">
sebastien.fricker@phaseview.net</a>&gt; wrote:</span> </span></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div><span class="e" id="q_115d81a54e0e5a75_3">
<div lang="FR" vlink="purple" link="blue">
<div>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Dear ITK users,</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Since I didn&#39;t get any answer, let me try to explain my problem differently:</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">In my project, I open 2 types of BMP images:</span></font></p>
<p style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt"><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><span>-<font face="Times New Roman" size="1"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</span></font></span></span></font><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">8 bits grayscale images</span></font></p>
<p style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt"><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><span>-<font face="Times New Roman" size="1"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</span></font></span></span></font><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">24 bits RGB images</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">When I use an imageIO to read the file headers, I obtain the following (for both types of images):</span>
 </font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">imageIO-&gt;GetPixelType() returns SCALAR</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">imageIO-&gt;GetComponentType returns UCHAR</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">imageIO-GetNumberOfComponents returns 3</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Instead, I would expect:</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">For 8 bits grayscale:</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Pixel type = SCALAR</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Component type = UCHAR</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Number of components = 1</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">For 24 bits RGB:</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Pixel type = RGB</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Component type = UCHAR</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Number of components = 3</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Is this a bug or am I missing something? For example the user manual says that if pixel type is SCALAR, then number of components should always be 1, which is not the case here… 
</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Thank you,</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;</span></font></p>
<p><font face="Arial" color="navy" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Sebastien Fricker</span></font></p>
<div>
<div style="TEXT-ALIGN: center" align="center"><font face="Times New Roman" size="3"><span lang="EN-US" style="FONT-SIZE: 12pt">
<hr align="center" width="100%" size="2">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span lang="EN-US" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</span></font></b><font face="Tahoma" size="2"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">
 insight-users-bounces+sebastien.fricker=<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:phaseview.net@itk.org" target="_blank">phaseview.net@itk.org</a> [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:insight-users-bounces+sebastien.fricker=phaseview.net@itk.org" target="_blank">
 insight-users-bounces+sebastien.fricker=phaseview.net@itk.org</a>] <b><span style="FONT-WEIGHT: bold">On Behalf Of </span></b>Sébastien Fricker<br><b><span style="FONT-WEIGHT: bold">Sent:</span></b> mardi 23 octobre 2007 08:54 
<br><b><span style="FONT-WEIGHT: bold">To:</span></b> &#39;insight-users&#39;<br><b><span style="FONT-WEIGHT: bold">Subject:</span></b> [Insight-users] Determine if BMP is color or grayscale</span></font><span lang="EN-US">
 </span></p></div>
<div><span>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Dear ITK users,</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">How can I determine if a BMP image is 8 bits grayscale or 24 bits RGB?</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">I was able to use an ImageIO to read image information, but I can&#39;t seem to access the bit depth information (m_Depth being private). 
</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">I would like to write an application that can open and process grayscale or color images, then save the output as grayscale or color. 
</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Color images are processed differently (they are treated as vector images) so I need to differentiate them.</span></font></p>

<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Here is a sample of my code:</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO( fileName.c_str(), itk::ImageIOFactory::ReadMode );</span></font></p>

<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO-&gt;SetFileName( fileName );</span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO-&gt;ReadImageInformation();</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO-&gt;GetComponentType() </span></font><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">
returns</span></font><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt"> UCHAR </span></font><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">in both cases 
</span></font><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">.</span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO-&gt;GetNumberOfComponents() </span></font><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">
returns</span></font><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt"> 3 </span></font><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">in both cases 
</span></font><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">.</span></font><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;</span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Thanks for your help,</span></font></p>
<p style="MARGIN-BOTTOM: 12pt"><font face="Verdana" size="2"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Sébastien Fricker</span></font></p>
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt">&nbsp;</span></font></p></span></div></div></div><br></span></div>_______________________________________________<br>Insight-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Insight-users@itk.org" target="_blank">
Insight-users@itk.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br><br>
</blockquote></div><br></blockquote></div><br>