octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45779] Writing 8-bit grayscale image to bmp f


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #45779] Writing 8-bit grayscale image to bmp file should write an indexed image
Date: Tue, 25 Aug 2015 14:42:55 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0

Update of bug #45779 (project octave):

                 Summary: Writing and 8-bit image to BMP produces a 24-bit bmp
=> Writing 8-bit grayscale image to bmp file should write an indexed image

    _______________________________________________________

Follow-up Comment #7:

@Mike Miller : Yes, you mentioned that on comment #1 but not that you had
tested. Sounded like you were assuming it from the documentation.


Well, this wouldn't be very difficult to fix. A possible fix would be identify
the bmp format in 'private/__imwrite__.m' and create the gray colormap there
before calling '__magick_write__'. Or this could all be done in
'__magick_write__'


However, this is a not a fix I would like to implement, and I'm not sure I'd
even like to see it implemented. I see a few reasons for it:

0 We are losing the main advantage of using GM by adding this weird
exceptions.
0 The logic is that if there's a colormap, then it writes an indexed image, if
not then it should write an intensity values image (gray or RGB) depending on
the number of channels.  If a format does not support gray intensity values,
then I'd argue that an RGB image is closer. Note that a grayscale image can
perfectly be of class double and on the range [0 1], definitely not only an
indexed of a gray map.
0 Tiff is the de facto standard when such details matter.
0 If the user really really wants an indexed image to be written, and it's
dependent on it, then it should be specific and specify the colormap.
0 Matlab documentation is not explicit on what should happen. It says "If A is
of data type uint8, then imwrite outputs 8-bit values".  We already do this,
we write 8-bit per channel. This is not semantics. Matlab documentation also
calls RGB files 8-bit files "If A is a grayscale or RGB color image [...]
scales the data by 255 before writing it to the file as 8-bit values" (it also
calls them 24-bit images in other cases).

So I propose closing this as won't fix. If anyone is relaying on imwrite to
write an indexed image, then it should be explicit and use:


imwrite (gray_image, gray (256), "foo.bmp");


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45779>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]