From: Alberto Bedin on 14 Jun 2010 11:41 I have an input image which is lena.bmp. It's the black and white version of Lena. There are only two lines in the code: img = imread('lena.bmp'); imwrite(img,'lenaSaved.bmp','bmp'); Now... the image are different. Why lenaSaved.bmp is darker than lena.bmp? I have to manually modify contrast and brightness in Photoshop to get the same image. Note that lena.bmp and the saved image have the same matrix! Is there a way to get the same identical image?
From: Alberto Bedin on 14 Jun 2010 12:03 "Alberto Bedin" <alberto.bedin(a)email.it> wrote in message <hv5iig$5jj$1(a)fred.mathworks.com>... > I have an input image which is lena.bmp. It's the black and white version of Lena. > > There are only two lines in the code: > > img = imread('lena.bmp'); > imwrite(img,'lenaSaved.bmp','bmp'); > > Now... the image are different. Why lenaSaved.bmp is darker than lena.bmp? I have to manually modify contrast and brightness in Photoshop to get the same image. Note that lena.bmp and the saved image have the same matrix! > > Is there a way to get the same identical image? Oh I forgot to tell you that if I try to show the image in Matlab: figure(1) imagesc(img); colormap(gray); The image is correctly displayed (fidelity contrast and brightness to the original file).
From: ImageAnalyst on 14 Jun 2010 16:49 Try passing in clims of [0 255] to imagesc(). Or use image or imshow. The actual image matrix must be the same so it must be just how imagesc scales the colors for display. imagesc() will take whatever gray values you have and scale them so that the min is 1 and the max is 64 so that it can use the "canned" colormaps such as the default one, or even the gray which you are using. If your min of your image is not close to zero or 1 then (after it's scaled to 1-64) it may look different than if you display it between 0 and 255.
From: Alberto Bedin on 15 Jun 2010 05:23 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <194551a1-1838-4d58-adf8-d6fd4a4959fe(a)c10g2000yqi.googlegroups.com>... > Try passing in clims of [0 255] to imagesc(). Or use image or imshow. > The actual image matrix must be the same so it must be just how > imagesc scales the colors for display. imagesc() will take whatever > gray values you have and scale them so that the min is 1 and the max > is 64 so that it can use the "canned" colormaps such as the default > one, or even the gray which you are using. If your min of your image > is not close to zero or 1 then (after it's scaled to 1-64) it may look > different than if you display it between 0 and 255. You're right. I have just tried: imagesc(img,[0,255]); colormap(gray); and the image is displayed darker and not as the original one. Now I would like that imwrite works as imagesc(img) and not like imagesc(img,[0,255]). What can I do? Thanks
From: ImageAnalyst on 15 Jun 2010 07:12
imwrite writes out the actual pixel values and has nothing to do with how it looks when displayed with any colormap. If you want it to look different, you need to actually change the pixel values. Maybe you want to use imadjust() to create a new scaled matrix that you can write out. |