MantisBT - ITK
View Issue Details
0010917ITKpublic2010-06-30 08:162010-11-16 12:06
aurelien 
kentwilliams 
normalmajoralways
closedfixed 
ITK-3-18 
ITK-4-A2 
2010-11-16
completed
0010917: Cannot read a RGBA png file into an itk::Image<unsigned char, 2> properly
I tried to read a 4 channels (RGBA) png image file into an
itk:Image<unsigned char, 2> and the output image makes no sense. It
appears that it works fine with RGB png images. In fact, I located the
issue in ConvertPixelBuffer::ConvertRGBAToGray() that computes the
grayscale pixel value by applying the following formula:

((2125.0 * static_cast<double>RedPixelValue +
  7154.0 * static_cast<double>GreenPixelValue +
  0721.0 * static_cast<double>BluePixelValue)/1000.0) //OK
     * static_cast<double>AlphaPixelValue
//Here is the issue

In a RGBA png image, the range of AlphaPixelValue is [0,255]. The
resulting grayscale value is no longer reasonably allowed to be casted
into an unsigned char. That's why the reader output doesn't make any
sense. I isolated this behavior in the attachment.
a fix is pushed to gerrit
No tags attached.
gz PngReadWriteBug.tar.gz (43,437) 2010-06-30 08:16
https://public.kitware.com/Bug/file/3217/PngReadWriteBug.tar.gz
Issue History
2010-06-30 08:16aurelienNew Issue
2010-06-30 08:16aurelienFile Added: PngReadWriteBug.tar.gz
2010-11-02 14:14Hans JohnsonStatusnew => assigned
2010-11-02 14:14Hans JohnsonAssigned To => Gabe Hart
2010-11-02 14:15Hans JohnsonAssigned ToGabe Hart => kentwilliams
2010-11-04 12:43kentwilliamsSprint Status => active
2010-11-04 12:43kentwilliamsAdditional Information Updated
2010-11-16 12:06kentwilliamsResolution Date => 2010-11-16
2010-11-16 12:06kentwilliamsSprint Statusactive => completed
2010-11-16 12:06kentwilliamsStatusassigned => closed
2010-11-16 12:06kentwilliamsResolutionopen => fixed
2010-11-16 12:06kentwilliamsFixed in Version => ITK-4-A2

There are no notes attached to this issue.