help-octave
[Top][All Lists]
Advanced

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

Re: Problem reading the Gray Image - Image quality


From: James Sherman Jr.
Subject: Re: Problem reading the Gray Image - Image quality
Date: Mon, 9 Apr 2012 18:40:26 -0400

On Mon, Apr 9, 2012 at 5:57 PM, Jithender Reddy <address@hidden> wrote:
Hi,

I'm trying to read a gray image using imread, but the image quality is not good. The same commands works well in the freemat and the quality is good.
Please find the screen shot attached.

I'm using the Octave version 3.6.1

I'm using the command as 

1) reading from the .bmp file directly
----------------------------------------------------
x = imread('d:\lena512.bmp');
figure(2), image(x), colormap(gray)

2) reading from the text file where I have the gray image matrix
------------------------------------------------------------------------------------------
x = dlmread('d:\Lena512_BMP_Matrix.txt', '', 0, 0);
figure(2), image(x), colormap(gray)


Please help me to correct this.

Thanks in advance.

Thanks,
Jithender

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


image (just reading the help text, I haven't used this function in a while) assumes that the values in x are indices into the map.  Colormap(gray) by default sets the colormap to 64 levels of gray (at least in 3.4.3 that I have), while I assume that your Lena image has 256 levels.  So what I think is happening is that any values over 64 get mapped to 64 and thus appear white.  My best guess is that simply changing
colormap(gray)
to
colormap(gray(256))
will solve your problem.

You could also do (and this would be equivalent, I believe) is you could do:
figure(2); imshow(x, [0 255]);
or 
figure(2); imshow(x, [1 256]);
(I don't remember whether it is 0-indexed or 1-indexed).

Hope this helps.



reply via email to

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