Why does an image look better in matlab than in other viewers, (and how to fix this so it is WYSIWYG)?
2 views (last 30 days)
Show older comments
Above is a screen capture from two windows: the top window is a matlab figure displaying a tif using the following commands:
img=imread('Image.tif'); % reads in as uint8, i.e., an 8-bit tif, also it is uncompressed
imshow(img); % note no auto-scaling used in imshow, no colormap used
The bottom window is the same image displayed in IrfanView, although I have also looked at it using Windows Picture Viewer, and by inserting it into MS Word, PowerPoint, etc, and it looks the same as in IrfanView. I note that I could also write the image:
imwrite(img,'Image2.tif','tif'); % write the image to a new tif
and re-view that in IrfanView but it still looks bad. I don't think this is specific to tif versus other formats, but rather has to do with some magic that matlab uses to display images. My problem with this is that when I am performing image processing to prepare images for publication, what I see in the figure is not what I get in any other image viewer -- the latter is what it will look like in the publication. How can I get Matlab to display images such that they are WYSIWYG (what-you-see-is-what-you-get)?
3 Comments
Walter Roberson
on 10 Aug 2015
In OS-X (Mac), the default image view "Preview" shows the same as MATLAB shows, the brighter version, as do the other OS-X viewers that I tried.
Answers (1)
Abhishek Pandey
on 10 Aug 2015
Hi Amy,
I understand that you are experiencing irregular image quality of a TIF file on MATLAB as compared to an external image viewer. I tried reproducing this using an example TIF file but I don’t seem to have a problem with it.
Try using the following code to test it with an example TIF file that MATLAB ships:
oldImg = imread('example.tif'); % read image
imwrite(oldImg, 'new.tif') % write it to a new file
newImg = imread('new.tif'); % read the new created file
error = immse(oldImg, newImg) % calculate error between the two images
This code reads a TIF file, writes it to a new one and then compares the two files to display the mean squared error between the two. You can also look at them in an image viewer.
I hope this helps!
- Abhishek
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!