[Insight-users] problem with RGB .bmp images

Bill Lorensen bill.lorensen at gmail.com
Fri Oct 3 12:26:07 EDT 2008


John,

I have fixed the bug http://public.kitware.com/Bug/view.php?id=7773
and checked in the changes. Please delete the files I sent to you off
list and update itkBMPImageIO.h and itkBMPImageIO.cxx.

Thanks,

Bill

On Thu, Oct 2, 2008 at 12:00 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> John,
>
> I tried your code and image. I can reproduce your problem. 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.
>
> Please enter a bug for this, following the proecedure at:
> http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes
>
> Feel free to assign the bug to me.
>
> Bill
>
> On Wed, Oct 1, 2008 at 6:15 AM, John <dbgtjp at hotmail.com> wrote:
>> Luis Ibanez <luis.ibanez at ...> writes:
>>
>>>
>>>
>>> Hi John,
>>>
>>> Are you declaring your image as an image whose
>>> pixel type is itkRGBPixel<>  ?
>>>
>>> Please provide a minimal code snippet illustrating your problem.
>>>
>>>     Thanks
>>>
>>>        Luis
>>
>> Hi Luis,
>>
>> Of course I declared the pixel type as itk::RGBPixel.
>>
>> To verify that it is not an error of my code I took the example from
>> Examples/DataRepresentation/Image/RGBImage.cxx.
>>
>> The following code results for the image http://jperl.gu6.info/000.bmp
>> in the output:
>>
>> Pixel values from GetRed,GetGreen,GetBlue:
>> Red = 137
>> Green = 137
>> Blue = 137
>> Pixel values:
>> Red = 137
>> Green = 137
>> Blue = 137
>>
>> Here the code I used:
>>
>> #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] = 90;
>>  pixelIndex[1] = 435;
>>
>>  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;
>> }
>>
>> I tried the above code on linux and windows with the same result.
>> Hope this helps you.
>>
>> John
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>


More information about the Insight-users mailing list