bugGNU Octave - Bugs: bug #37681, imread function when used with...


bug #37681: imread function when used with indexed images returns a matrix with 0 values, that are not accepted by other image funcs

Submitted by:  None
Submitted on:  Tue Nov 6 17:12:15 2012  
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: None
Originator Name: Lucas SaOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.2
Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

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


Mon Dec 10 23:41:50 2012, comment #4:

Carnë's patches work for me. There has been a lot of changes to the image files and this fix won't be backported to the 3.6.X branch. To see the fix you will need to build from Mercurial sources or wait for the next stable release of Octave.

Rik <rik5>
Project Administrator
Mon Nov 12 04:56:56 2012, comment #3:

I have made another commit to expand the fix to ind2gray. As the two functins had a fair ammount in common but ind2gray had almost no input check, I made a private function for the shared code ratyer than copy and paste.

Please pull changeset 14b7679891dd from https://bitbucket.org/carandraug/octave/ after the changeset mentinoed on the previous comment.

Carnë Draug <carandraug>
Project Member
Mon Nov 12 04:31:27 2012, comment #2:

I have made a commit that corrects this behavior at least in ind2rgb. Please pull changeset 4db08f52a6ed from https://bitbucket.org/carandraug/octave/

Carnë Draug <carandraug>
Project Member
Mon Nov 12 02:07:19 2012, comment #1:

The range of values for indexed images is dependent on their class and this may be the origin for confusion. If the indexed image is of an integer class, their indexes start at 0 so there's an offset of 1 for the colormap. However, some index images can be of class double in which case there's no offset and the minimum index should be 1.

Carnë Draug <carandraug>
Project Member
Tue Nov 6 17:12:15 2012, original submission:

Using <b>[X, map] = imread</b> will give me a matrix X with values from 0 to n-1, while all other image functions expect index mapping from 1 to n, such as imshow, ind2rgb, ind2gray.

This fact makes the execution of a simple <b>imshow('some_file.gif')</b> to show something different from the original image. imshow(<b>X+1</b>, map) would show it fine as well.

The function ind2rgb, for example, even has a validation for indices less than 1 in line 43 of ind2rgb.m:

## Check if X is an indexed image.
if (ndims (x) != 2 || any (x(:) != fix (x(:))) || <b>min (x(:)) < 1</b>)
error ("ind2rgb: X must be an indexed image");

To replicate the error, you can imread any indexed image (such as GIF) and try to use the referred functions with the results.

Is it normal to receive 0 values in X matrix? I am using octave 3.6.2 and graphicsmagick 1.3.16.



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

Attach File(s):

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 rik5 (Posted a comment)
  • -unavailable- added by jordigh (Updated the item)
  • -unavailable- added by carandraug (Posted a comment)
  • -unavailable- added by None (Submitted the item)

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

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Dec 10 23:41:50 2012rik5StatusPatch Submitted=>Fixed
    Mon Nov 12 15:33:34 2012jordighStatusNone=>Patch Submitted

    Back to the top

    Powered by Savane 3.1-cleanup