[Insight-users] Determine if BMP is color or grayscale
Bill Lorensen
bill.lorensen at gmail.com
Thu Oct 25 12:59:05 EDT 2007
Sebatien,
This looks like a bug to me. Can you add it to the bug tracker:
http://public.kitware.com/Bug/view_all_bug_page.php
Also, include url's to a sample 24 bit and 8 bit grayscale images.
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.
Bill
On 10/25/07, Sébastien Fricker <sebastien.fricker at phaseview.net> wrote:
>
> Dear ITK users,
>
> Since I didn't get any answer, let me try to explain my problem
> differently:
>
> In my project, I open 2 types of BMP images:
>
> - 8 bits grayscale images
>
> - 24 bits RGB images
>
>
>
> When I use an imageIO to read the file headers, I obtain the following
> (for both types of images):
>
>
>
> imageIO->GetPixelType() returns SCALAR
>
> imageIO->GetComponentType returns UCHAR
>
> imageIO-GetNumberOfComponents returns 3
>
>
>
> Instead, I would expect:
>
>
>
> For 8 bits grayscale:
>
> Pixel type = SCALAR
>
> Component type = UCHAR
>
> Number of components = 1
>
>
>
> For 24 bits RGB:
>
> Pixel type = RGB
>
> Component type = UCHAR
>
> Number of components = 3
>
>
>
> 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…
>
>
>
> Thank you,
>
>
>
> Sebastien Fricker
> ------------------------------
>
> *From:* insight-users-bounces+sebastien.fricker=phaseview.net at itk.org[mailto:
> insight-users-bounces+sebastien.fricker=phaseview.net at itk.org] *On Behalf
> Of *Sébastien Fricker
> *Sent:* mardi 23 octobre 2007 08:54
> *To:* 'insight-users'
> *Subject:* [Insight-users] Determine if BMP is color or grayscale
>
>
>
> Dear ITK users,
>
>
>
> How can I determine if a BMP image is 8 bits grayscale or 24 bits RGB?
>
> 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).
>
>
>
> I would like to write an application that can open and process grayscale
> or color images, then save the output as grayscale or color.
>
> Color images are processed differently (they are treated as vector images)
> so I need to differentiate them.
>
>
>
> Here is a sample of my code:
>
>
>
> itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
> fileName.c_str(), itk::ImageIOFactory::ReadMode );
>
> imageIO->SetFileName( fileName );
>
> imageIO->ReadImageInformation();
>
>
>
>
>
>
>
> imageIO->GetComponentType() returns UCHAR in both cases.
>
> imageIO->GetNumberOfComponents() returns 3 in both cases.
>
>
>
> Thanks for your help,
>
> Sébastien Fricker
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071025/4bccba34/attachment.htm
More information about the Insight-users
mailing list