imwrite and imshow problem

1 次查看(过去 30 天)
Paulo
Paulo 2011-8-25
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

回答(1 个)

Sean de Wolski
Sean de Wolski 2011-8-25
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.

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by