imread (repost)

Thomas L. Scofield scofield at calvin.edu
Tue Aug 5 21:46:39 CDT 2008


In Octave:

octave:4> im = imread("magnolia.png");
octave:5> whos im
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        im        480x640x4                1228800  uint8

Total is 1228800 elements using 1228800 bytes

octave:6> max(max(im(:,:,4)))
ans = 247
octave:7> min(min(im(:,:,4)))


octave:8> [im,map,alpha] = imread("magnolia.png");
octave:9> whos im map alpha
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        im        480x640x4                1228800  uint8
        map         0x0                          0  double
        alpha       0x0                          0  double

Total is 1228800 elements using 1228800 bytes


In Matlab:

 >> im = imread('magnolia.png');
 >> whos im
   Name        Size              Bytes  Class    Attributes

   im        480x640            307200  uint8


 >> [im, map, alpha] = imread('magnolia.png');
 >> whos im map alpha
   Name         Size              Bytes  Class     Attributes

   alpha        0x0                   0  double
   im         480x640            307200  uint8
   map        250x3                6000  double


For this same image, here is the output of the GraphicsMagick shell  
command  "gm identify -verbose magnolia.png":

Image: /Users/scofield/images/generic/magnolia.png
   Format: PNG (Portable Network Graphics)
   Geometry: 640x480
   Class: DirectClass
   Type: true color with transparency
   Depth: 8 bits-per-pixel component
   Channel Depths:
     Red:      8 bits
     Green:    8 bits
     Blue:     8 bits
     Opacity:  8 bits



On Aug 5, 2008, at 10:34 PM, John W. Eaton wrote:

> On  5-Aug-2008, Thomas L. Scofield wrote:
>
> |
> | On Aug 5, 2008, at 4:53 PM, Søren Hauberg wrote:
> |
> | > tir, 05 08 2008 kl. 22:50 +0200, skrev Søren Hauberg:
> | >> tir, 05 08 2008 kl. 10:35 -0400, skrev Thomas L. Scofield:
> | >>> That's not the kind of modification I was suggesting for  
> imshow.  I
> | >>> was suggesting this much simpler change (pseudocode):
> | >>>
> | >>>
> | >>>   if (length (size (image)) == 3 && size (image, 3) == 4)
> | >>>     show image(:, :, 1:3)
> | >>>   else
> | >>>     show image
> | >>>   endif
> | >>
> | >> I can only see the point of this behaviour if 'imread' actually
> | >> returns
> | >> NxMx3 arrays.
> | >
> | > Aaarghh, I of course ment to write MxNx4 here...
> | >
> |
> |
> | That brings us back around to my original post.  I have examples of
> | png files for which
> |
> |    im = imread ("file.png");
> |    size (im, 3)
> |
> | produces the output 4.
>
> Can you find out what Matlab's imread returns for this file?  I'm also
> curious about what happens if you call imread like this:
>
>   [im, map, alpha] = imread ('file.png')
>
> Thanks,
>
> jwe

Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/octave-maintainers/attachments/20080805/07d0a525/attachment-0001.html 


More information about the Octave-maintainers mailing list