<div>Sebatien,</div>
<div> </div>
<div>This looks like a bug to me. Can you add it to the bug tracker: <a href="http://public.kitware.com/Bug/view_all_bug_page.php">http://public.kitware.com/Bug/view_all_bug_page.php</a></div>
<div> </div>
<div>Also, include url's to a sample 24 bit and 8 bit grayscale images.</div>
<div> </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> </div>
<div>Bill<br> </div>
<div><span class="gmail_quote">On 10/25/07, <b class="gmail_sendername">Sébastien Fricker</b> <<a href="mailto:sebastien.fricker@phaseview.net">sebastien.fricker@phaseview.net</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<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'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>
</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>
</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"> </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"> </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->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->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"> </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"> </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"> </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"> </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"> </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"> </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> 'insight-users'<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 class="e" id="q_115d6158202068ee_1">
<p><font face="Times New Roman" size="3"><span style="FONT-SIZE: 12pt"> </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"> </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'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"> </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"> </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"> </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->SetFileName( fileName );</span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO->ReadImageInformation();</span></font></p>
<p><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"> </span></font></p>
<p><font face="Verdana" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> </span></font></p>
<p><font face="Courier New" size="2"><span lang="EN-GB" style="FONT-SIZE: 10pt">imageIO->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->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"> </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"> </span></font></p></span></div></div></div><br>_______________________________________________<br>Insight-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Insight-users@itk.org">
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>