imwrite and imshow problem

1 view (last 30 days)
Paulo
Paulo on 25 Aug 2011
Here is my code: irisImage = imread('C:\Users\Tests\iris.bmp'); irisImageGrayScale = double(rgb2gray(irisImage)); figure;imshow(irisImageGrayScale) imwrite(irisImageGrayScale, 'C:\Users\Tests\irisGrayScaled.jpg','jpg');
The image being recorded is not the grayscale of the iris.bmp but instead, an image with white background and small dots on the center. The imshow also is the same but when I change imshow and use
imshow(irisImageGrayScale, [])
the correct gray scale of the picture is showed

Answers (1)

Sean de Wolski
Sean de Wolski on 25 Aug 2011
Yes, by viewing with imshow and the [] (full range) option you're seeing the full range of values. Otherwise, you're seeing only the values between zero and one which most of the uint8 values will be above. I would recommend trying im2double if you need to save. Or just converting back to uint8 before saving and/or never converting to double in the first place. The only reason to convert to double is if you want to do math on the image.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!