View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0007773 | ITK | public | 2008-10-02 13:50 | 2008-10-03 12:17 | |||||
Reporter | Johannes Perl | ||||||||
Assigned To | Bill Lorensen | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | Linux | OS | Kubuntu 8.04 | OS Version | Kernel 2.6.24-19 | ||||
Product Version | ITK-3-8 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0007773: bitmap images can not be read as RGB | ||||||||
Description | Some bitmap images can not be read as RGB images, due to a bug in BMPImageIO. If the bitmap images are read, the single color values get lost and are translated into greyscale values. The problem was already reproduced and investigated by Bill Lorensen. "The BMPImageIO is not properly generating a lookup table when the number of colors == 0. It should generate a lookup table based on the depth of the image." | ||||||||
Steps To Reproduce | Use the following code and compile it. Then call ./RGBTest 000.bmp with the uploaded image being in the same folder. The output will be: Pixel values from GetRed,GetGreen,GetBlue: Red = 36 Green = 36 Blue = 36 Pixel values: Red = 36 Green = 36 Blue = 36 //file RGBTest.cxx #include "itkImage.h" #include "itkImageFileReader.h" #include "itkRGBPixel.h" int main( int , char * argv[] ) { typedef itk::RGBPixel< unsigned char > PixelType; typedef itk::Image< PixelType, 2 > ImageType; typedef itk::ImageFileReader< ImageType > ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName( argv[1] ); reader->Update(); ImageType::Pointer image = reader->GetOutput(); ImageType::IndexType pixelIndex; pixelIndex[0] = 3; pixelIndex[1] = 3; PixelType onePixel = image->GetPixel( pixelIndex ); PixelType::ValueType red = onePixel.GetRed(); PixelType::ValueType green = onePixel.GetGreen(); PixelType::ValueType blue = onePixel.GetBlue(); std::cout << "Pixel values from GetRed,GetGreen,GetBlue:" << std::endl; std::cout << "Red = " << itk::NumericTraits<PixelType::ValueType>::PrintType(red) << std::endl; std::cout << "Green = " << itk::NumericTraits<PixelType::ValueType>::PrintType(green) << std::endl; std::cout << "Blue = " << itk::NumericTraits<PixelType::ValueType>::PrintType(blue) << std::endl; red = onePixel[0]; // extract Red component green = onePixel[1]; // extract Green component blue = onePixel[2]; // extract Blue component std::cout << "Pixel values:" << std::endl; std::cout << "Red = " << itk::NumericTraits<PixelType::ValueType>::PrintType(red) << std::endl; std::cout << "Green = " << itk::NumericTraits<PixelType::ValueType>::PrintType(green) << std::endl; std::cout << "Blue = " << itk::NumericTraits<PixelType::ValueType>::PrintType(blue) << std::endl; return 0; } //CMakeLists.txt PROJECT(RGBTest) # Find ITK. FIND_PACKAGE(ITK REQUIRED) IF(ITK_FOUND) INCLUDE(${ITK_USE_FILE}) ENDIF(ITK_FOUND) ADD_EXECUTABLE(RGBTest RGBTest.cxx ) TARGET_LINK_LIBRARIES(RGBTest ITKCommon ITKIO) | ||||||||
Tags | No tags attached. | ||||||||
Resolution Date | |||||||||
Sprint | |||||||||
Sprint Status | |||||||||
Attached Files | 0001001_os_sn6040.bmp [^] (590,902 bytes) 2008-10-02 13:50 | ||||||||
Relationships | |
Relationships |
Notes | |
(0013713) Bill Lorensen (developer) 2008-10-02 14:27 |
I used the example provided by the reporter along with a sample image he provided. As he reports, the values are reported as grayscale, the color being lost. I tracked down the problem in itkBMPImageIO.cxx. The code does not correctly compute a lookup table when the number of colors is 0. Also, the Allow8Bit mode interferes with a corrected implementation. It seems this mode should always be false in itk since the reader will convert rgb images to scalars. |
(0013723) Bill Lorensen (developer) 2008-10-03 12:17 |
The code was not correctly create a color table if the depth was 8. Corrected in cvs entries: http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/IO/itkBMPImageIO.cxx?root=Insight&r1=1.28&r2=1.29&sortby=date [^] http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/IO/itkBMPImageIO.h?root=Insight&r1=1.8&r2=1.9&sortby=date [^] |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2008-10-02 13:50 | Johannes Perl | New Issue | |
2008-10-02 13:50 | Johannes Perl | File Added: 0001001_os_sn6040.bmp | |
2008-10-02 14:23 | Bill Lorensen | Status | new => assigned |
2008-10-02 14:23 | Bill Lorensen | Assigned To | => Bill Lorensen |
2008-10-02 14:27 | Bill Lorensen | Note Added: 0013713 | |
2008-10-02 14:27 | Bill Lorensen | Status | assigned => acknowledged |
2008-10-03 12:11 | Bill Lorensen | Resolution | open => fixed |
2008-10-03 12:12 | Bill Lorensen | Status | acknowledged => resolved |
2008-10-03 12:17 | Bill Lorensen | Status | resolved => feedback |
2008-10-03 12:17 | Bill Lorensen | Resolution | fixed => reopened |
2008-10-03 12:17 | Bill Lorensen | Note Added: 0013723 | |
2008-10-03 12:17 | Bill Lorensen | Status | feedback => closed |
2008-10-03 12:17 | Bill Lorensen | Resolution | reopened => fixed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |