Why does an image look better in matlab than in other viewers, (and how to fix this so it is WYSIWYG)?

2 Ansichten (letzte 30 Tage)
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 Kommentare
Amy Oldenburg
Amy Oldenburg am 10 Aug. 2015
Great idea, except Matlab does not allow me to attach a .tif -- so here is a file that I replaced the extension as .bmp but you'll have to rename it as .tif to try it out.
Walter Roberson
Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Abhishek Pandey
Abhishek Pandey am 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
  1 Kommentar
Amy Oldenburg
Amy Oldenburg am 10 Aug. 2015
Unfortunately this doesn't address my question. Of course you can read an image, write it out, and read it back in, and there will be no error. That doesn't address why the figure display of the image in Matlab looks different than in every other Windows-based image viewer.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by