bugGNU Octave - Bugs: bug #46382, imread returns image of class...

 
 

bug #46382: imread returns image of class logical for too many rgb images

Submitter:  Hartmut <hardy>
Submitted:  Thu 05 Nov 2015 09:13:33 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

  Spam posted by anonymous
Fri 06 Nov 2015 07:08:28 AM UTC, comment #3: 

Yes, you are right.
In the development branch


>> class(I)
ans = uint8


Avinoam Kalma <avinoam>
Group Member
Thu 05 Nov 2015 11:28:33 PM UTC, comment #2: 

I think this is a duplicate of bug #41584 which was fixed back in July:

http://hg.savannah.gnu.org/hgweb/octave/rev/a7770c66cb3d

Can you please check with the development version of Octave?

Carnë Draug <carandraug>
Group Member
Thu 05 Nov 2015 10:35:45 PM UTC, comment #1: 

Maybe it is not GraphicsMagick, but the lines


      if (img.is_bool_type ())
        encode_bool_image (imvec, img.bool_array_value ());


in _magic_read_.cc?


Avinoam Kalma <avinoam>
Group Member
Thu 05 Nov 2015 09:13:33 PM UTC, original submission:  

This happens with the current 4.0.0 release of Octave:


clear, close all;
R = [0 0 0 0; 0 255 255 0; 0 255 255 0; 0 0 0 0];
G = [0 1 2 3; 4 5 6 7; 100 101 102 103; 200 201 202 203];
B = G + 10;
RGB = uint8(cat(3, R, G, B));
filename = 'test_image.png';
imwrite(RGB, filename);       % so far so good
I = imread(filename);
class(I)                      % -> class logical :(


The resulting class of I is "logical". This results in a significant amount of data loss, because all the information in the G and B channel is thus mostly discarded by imread.

I think I have read elsewhere that imread needs to do some kind of "guessing" if the read image is ment to be of class logical or of an integer class, because Image Magick doesn't provide this information. And I assume that imread does its best for greyscale images. But for RGB images like in this example, I think we could do better:

I would suggest to only assign class logical to an image (inside of the imread function) if ALL the color channels only consist of 0 and intmax. Currenetly it seems to me that for this decision only the red R channel is used.

(PS: This seems to be an artificial example. But I had a real image with only orange hues in it, where this really happened...)

Hartmut <hardy>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

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

    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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-06 carandraug StatusNone Duplicate
        Open/ClosedOpen Closed
        Dependencies- Depends on bugs #41584

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code