bugGNU Octave - Bugs: bug #48468, imfinfo: image BitDepth value not...

 
 

bug #48468: imfinfo: image BitDepth value not compatible with MATLAB

Submitter:  Francesco Morsillo <mosy>
Submitted:  Mon 11 Jul 2016 04:32:30 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Francesco Morsillo Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 14 Jul 2016 01:21:34 PM UTC, comment #6: 

As a temporary workaround, you can divide bitdepth not by 3, but by 'size (im, 3)'.  This will even accommodate any images with 4 channels (CMYK).

Carnë Draug <carandraug>
Group Member
Thu 14 Jul 2016 07:50:25 AM UTC, comment #5: 

I could not agree more: MATLAB is mixing bit depth and number of channels. The alpha channel is added as a optional field 'Transparency' of the imfinfo struct in case of images that can have it (i.e. PNG), so it is not counted in the BitDepth.

[Informative]: my 'problem' is not a real problem. Basically I got stuck with some legacy code written by somebody else and in this code there was a bit shifting for images to have all values in the MSBs of the 16 bits of the pixel. In order to do this shift, the code looks at the BitDepth of imfinfo and divides it by 3: doing this in Octave basically makes the code think that the image bit depth is 2 and unexpected values come out.
That part would probably be removed, so it shall not have impacts for me.

Francesco Morsillo <mosy>
Wed 13 Jul 2016 10:36:44 AM UTC, comment #4: 


> It becomes uncomfortable when you want to process images without knowing in advance the bitdepth and let your script compensate for this.


I don't understand how that can be a problem. What do you want to compensate? I'd actually guess that Octave's current behaviour would be nicer because it tells you exactly the bitdepth of each channel. If you get bitdepth of 24, there's a good probability that it's a uint8 or int8 values in 3 colors. But if you have bitdepth 8 and truecolor, then you will know for sure. I don't know of any setup where 24 would mean anything different than 8bit RGB images but for other bitdepth values, there will be other possibilities.

Anyway, this is a compatibility issue and should be fixed. Does Matlab also counts the alpha channel in the bitdepth?

Carnë Draug <carandraug>
Group Member
Wed 13 Jul 2016 07:22:23 AM UTC, comment #3: 

As far as I can tell what Mike says is correct. It becomes uncomfortable when you want to process images without knowing in advance the  bitdepth and let your script compensate for this.

Francesco Morsillo <mosy>
Tue 12 Jul 2016 07:59:33 PM UTC, comment #2: 

So far as as I can tell this only affects the imfinfo function and its documentation. Is that correct or are there any other usages of imread or imwrite that are concerned with this difference?

Mike Miller <mtmiller>
Group Member
Tue 12 Jul 2016 06:12:01 PM UTC, comment #1: 

Confirmed. 
BitDepth value in Octave is of each channel, and in Matlab it
is the sum of all channels.

Avinoam Kalma <avinoam>
Group Member
Mon 11 Jul 2016 04:32:30 PM UTC, original submission:  

Octave:
‘BitDepth’ -> Number of bits per channel per pixel.
https://www.gnu.org/software/octave/doc/v4.0.0/Loading-and-Saving-Images.html

MATLAB:
Bit Depth -> Bit depth is the number of bits used to represent each image pixel.
http://nl.mathworks.com/help/matlab/ref/imread.html#f25-713750

Example:
Let test_image.png be a png RGB image with bitdepth 8 bit per channel.
OctaveBitDepth = 8
MatlabBitDepth = 24

Francesco Morsillo <mosy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by mosy (Submitted the item)
  • -email is unavailable- added by mosy
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-12 mtmiller CategoryNone Octave Function
        Releaseother dev
        Operating SystemGNU/Linux Any
        Summaryimage BitDepth value not compatible with MATLAB imfinfo: image BitDepth value not compatible with MATLAB
    2016-07-12 avinoam StatusNone Confirmed
    2016-07-11 mosy Carbon-Copy- Added mosy

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code