pngread does not read 12bit gray images
Bill Denney
bill at denney.ws
Fri Jul 11 06:04:23 CDT 2008
Søren Hauberg wrote:
> fre, 11 07 2008 kl. 01:10 -0400, skrev de Almeida, Valmor F.:
>
>> Yep. It does work. However it is a little tricky to compare the max(Y(:)) and min(Y(:)) values octave has in memory with the output of imagemagick's "identify" tool.
>>
>> Just for the record. In the following output from identify
>>
>> Format: PNG (Portable Network Graphics)
>> Class: DirectClass
>> Geometry: 275x220+0+0
>> Type: Grayscale
>> Endianess: Undefined
>> Colorspace: Gray
>> Depth: 16-bit
>> Channel depth:
>> Gray: 12-bit
>> Channel statistics:
>> Gray:
>> Min: 774 (0.188968)
>> Max: 1558 (0.380377)
>> Mean: 1213.52 (0.296275)
>> Standard deviation: 95.3054 (0.0232683)
>>
>> Octave's values for min and max are: 12384 and 24928. These are obtained from multiplying the corresponding numbers in parentheses from the "identify" output by 65536.
>>
>
> Hmmm, that's a bit odd isn't it? It seems that
>
> 0.188968 * (2^12 - 1) = 774
>
> and
>
> 0.188968 * (2^16 - 1) = 12384
>
> So, this is somehow related to the fact that the image is 12 bit but is
> read as 16 bit. Should the minimum value be 774 (as ImageMagick reports)
> or should it be 12384 (as Octave reports) ? I mean, who's right?
I'd say that ImageMagick is right, but that we shouldn't change our
output unless we implement a 12 bit numeric class (with the new classes
that could be done relatively easily, but I don't think it's worth the
effort for this). The reason is that we should be able to replicate the
image through its normalized intensity in the current bit depth. If we
set it to 774, but it's stored in an uint16, then unless you
specifically knew the image was 12 bit, it seems likely that you would
represent the image as lower contrast than it really is (most code will
make the assumption that the intensity is 774/(2^16 - 1)). Keeping the
12384 allows round-trips to be made correctly while I don't think that's
the case for 774.
Have a good day,
Bill
More information about the Help-octave
mailing list