bugGNU Octave - Bugs: bug #42834, imread ("default.img")...

 
 

bug #42834: imread ("default.img") returns empty colormap with gm 1.3.16

Submitter:  Andreas Weber <andy1978>
Submitted:  Wed 23 Jul 2014 12:21:42 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 26 Jul 2014 03:36:28 AM UTC, comment #8: 

I grafted the cset back on to the stable branch since this could be considered a regression.  See this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/87cba451fd5e).

Rik <rik5>
Group administrator
Fri 25 Jul 2014 01:40:18 PM UTC, comment #7: 

I pushed this cset to the default branch. Should it be merged into stable? In a way, it could be considered a regression.

Carnë Draug <carandraug>
Group Member
Thu 24 Jul 2014 05:53:41 PM UTC, comment #6: 

That is an even older so I guess it is safe to assume it fixed it. Andy, please reopen this bug if for some reason does not for you.

Carnë Draug <carandraug>
Group Member
Thu 24 Jul 2014 05:46:27 PM UTC, comment #5: 

The patch stops the error message for me with GM 1.3.12.

Rik <rik5>
Group administrator
Thu 24 Jul 2014 04:45:37 PM UTC, comment #4: 

I have, I hope, devised a solution for this. If someone running Octave with GM 1.3.16 or older, could check if the attached cset works, I can push it.



(file #31769)

Carnë Draug <carandraug>
Group Member
Wed 23 Jul 2014 10:36:49 PM UTC, comment #3: 

I have already discussed this with Andy on IRC. Basically the problem is on is_indexed function in _magick__read_.cc file

http://hg.savannah.gnu.org/hgweb/octave/file/c6b89c4a9e63/libinterp/dldfcn/__magick_read__.cc#l75

The file is an indexed image but is_indexed() seems to return false when using older version of GraphicsMagick. This is a problematic function because of the reasons listed on the source (basically, GM does not really tells anything about the file, only about how it is stored in memory after reading and optimizing).

GM uses libpng to read png files, so we access it's values directly to really check if the file is indexed. If the value of "color type orig" is 3, it is an indexed image. I do not know why this is failing on older versions of GM but you can check by running the following:

+verbose+
$ gm identify -verbose default.img | grep -P "Class|IHDR"
  Class: PseudoClass
  Png:IHDR.color-type-orig: 3
  Png:IHDR.bit-depth-orig: 8
-verbose-

If you do not have the "Png:IHDR.color-type-orig", then run the command without grepping and look for something similar to it.

The whole point of using GM is ignoring the underlying library that is actually doing the reading. If we have to start checking things like this for every format, then GM starts losing its value (which in my opinion is already quite low for many other reasons I stated in other bug reports and mailing list).

The GraphicsMagick version where this bug appears is still on Debian stable (which we should be supporting). It also did not exist before 3.8 when default.img was not really an image but an Octave data file so it could be considered a regression.

Carnë Draug <carandraug>
Group Member
Wed 23 Jul 2014 09:58:58 PM UTC, comment #2: 

I'm adding Carne Draug to the CC list because he has done a lot of the work with GraphicsMagick and the default image.

Rik <rik5>
Group administrator
Wed 23 Jul 2014 05:11:39 PM UTC, comment #1: 

This is because _magick_read_.cc:is_indexed for our "default.img" (md5sum d581bb80374d39ef0994154afc5c1f47)
returns false for graphicsmagick 1.3.16 and true for 1.3.18.

I'll attach a quick test if someone wants to try it out. is_indexed is a direct copy from _magick_read_.cc.

Compile with g++ -Wall $(pkg-config --cflags GraphicsMagick++) main.cc -o isindex $(pkg-config --libs GraphicsMagick++)

(file #31765)

Andreas Weber <andy1978>
Group Member
Wed 23 Jul 2014 12:21:42 PM UTC, original submission:  

Debian GNU/Linux 7.5 (wheezy)
libgraphicsmagick++1-dev 1.3.16-1.1
imread("default.img") returns an empty colormap with octave 3.8.1, 3.8.2 or default.


octave:1> demo imshow 4
imshow example 4:
 clf;
 [I, M] = imread ("default.img");
 [R, G, B] = ind2rgb (I, M);
 imshow (cat (3, R, G*0.5, B*0.8));

warning: your version of GraphicsMagick limits images to 8 bits per pixel
imshow example 4: failed
ind2rgb: MAP must be a valid colormap
octave:2> [I, M] = imread ("default.img");
octave:3> M
M = [](0x0)
octave:4>


I run this demo yesterday in debian jessie without problems so I guess this depends on the version of GraphicsMagick.

Andreas Weber <andy1978>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31765:  main.cc added by andy1978 (879B - text/x-c++src - testcase for is_index)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by andy1978 (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-26 rik5 Item GroupNone Regression
    2014-07-24 carandraug StatusNone Fixed
        Open/ClosedOpen Closed
    2014-07-24 carandraug Attached File- Added gm-libpng-bug42834.patch, #31769
    2014-07-23 rik5 Carbon-Copy- Added carandraug
    2014-07-23 andy1978 Attached File- Added main.cc, #31765

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code