octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

imread returns MxNx4 when Matlab returns MxNx3


From: Ben Abbott
Subject: imread returns MxNx4 when Matlab returns MxNx3
Date: Sun, 15 May 2011 14:35:15 -0400

When reading a png bitmap, imread() returns an image of size MxNx4,while 
matlab's imread() returns MxNx3. The extra index causes image() to crash.

--------- octave session begin ---------
octave:1> img = imread ('test');
warning: your version of GraphicsMagick limits images to 16 bits per pixel
octave:2> image (img)
error: invalid value for array property "cdata"
error: called from:
error:   /Users/bpabbott/Development/mercurial/default/scripts/image/image.m at 
line 118, column 7
error:   /Users/bpabbott/Development/mercurial/default/scripts/image/image.m at 
line 75, column 7
error: __go_draw_axes__: A(I): index out of bounds; value 2 out of bound 0
error: called from:
error:   
/Users/bpabbott/Development/mercurial/default/scripts/plot/__go_draw_axes__.m 
at line 442, column 11
error:   
/Users/bpabbott/Development/mercurial/default/scripts/plot/__go_draw_figure__.m 
at line 167, column 19
error:   
/Users/bpabbott/Development/mercurial/default/scripts/plot/__gnuplot_drawnow__.m
 at line 86, column 5
octave:2> image (img(:,:,1:3))
octave:3> whos img
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        img       823x893x4                2939756  uint8

Total is 2939756 elements using 2939756 bytes
---------- octave session end ----------

I'm unfamiliar with Octave's imread function. Can someone tell me if this is 
intentional or an accident (the doc-string indicates it is not, but I thought I 
ask).

If imread() is working as intended, then I'm inclined to modify 
image.m:__img__() to prune the 3rd dimension to a length of 3. If there is a 
bug 

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]