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

 
 

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

Submitted by:  Francesco Morsillo <mosy>
Submitted on:  Mon 11 Jul 2016 04:32:30 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Francesco MorsilloOpen/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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>
Project Administrator
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>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 12 Jul 2016 07:59:33 PM UTCmtmillerCategoryNone=>Octave Function
      Releaseother=>dev
      Operating SystemGNU/Linux=>Any
      Summaryimage BitDepth value not compatible with MATLAB=>imfinfo: image BitDepth value not compatible with MATLAB
    Tue 12 Jul 2016 06:12:01 PM UTCavinoamStatusNone=>Confirmed
    Mon 11 Jul 2016 04:32:31 PM UTCmosyCarbon-Copy-=>Added mosy

    Back to the top


    Powered by Savane 3.1-cleanup1