Javier
Javier

Reputation: 1550

Octave IMAGE package failing to convert an image to grey scale

I am trying to do the VLFeat.org tutorial: http://www.vlfeat.org/overview/sift.html, to learn about SIFT features. I am doing it using octave. My octave version is GNU Octave, version 3.8.2, I am on a mac is 10.9.5 and when I list the pakages:

octave:4>pkg list
 Package Name  | Version | Installation directory
--------------+---------+-----------------------
 control *|   2.6.6 | /Users/javier/octave/control-2.6.6
 general *|   1.3.4 | /Users/javier/octave/general-1.3.4
   image *|   2.2.2 | /Users/javier/octave/image-2.2.2
  signal *|   1.3.0 | /Users/javier/octave/signal-1.3.0

so all packages loaded. The VLFeat version I am using:

octave:5>vl_version
0.9.19

The I type

I = vl_impattern('roofs1') ;
warning: your version of GraphicsMagick limits images to 8 bits per pixel
image(I) ;

Sometimes I get that warning, sometimes I don't. I then transform the image into a gray scale image using:

I = single(rgb2gray(I)) ;

I obtain an image that is all blue, I can't see anything in there other than a uniform dark blue image. There is no error message or any other warning, just a blue image. I have tried a few things: other images, load using imread in the image package and nothing seems to work (when I use imread I get something similar to a heatmap, still not a gray scale image). I guess this might have to do with the warning:

warning: your version of GraphicsMagick limits images to 8 bits per pixel

all my octave installation has been done with macports. So, I guess the question is. Do I have to install GraphicsMagick again. If so, using macports, is it:

 sudo port install GraphicsMagick --with-quantum-depth=16

Do I have to rebuilt octave again?

Thanks in advance

Upvotes: 0

Views: 781

Answers (1)

carandraug
carandraug

Reputation: 13081

You can't do this

I = single(rgb2gray(I)) ;

The display range of an image of class single is different from uint8. Either use im2single:

imshow (im2single (rgb2gray (I))

or set the display range of imshow:

imshow (single (rgb2gray (I)), [0 255])
imshow (single (rgb2gray (I)), [])

See the octave manual:

The actual meaning of the value of a pixel in a grayscale or RGB image depends on the class of the matrix. If the matrix is of class double pixel intensities are between 0 and 1, if it is of class uint8 intensities are between 0 and 255, and if it is of class uint16 intensities are between 0 and 65535.

Upvotes: 1

Related Questions