# Correct way of plotting images

4 views (last 30 days)
Muzammil Behzad on 19 Jul 2016
Commented: Thorsten on 19 Jul 2016
Hi community,
I need to know what's the correct way of plotting an image. Let's say I have an original grayscale [0-255] image ( let's assume a complete black image I = zeros(256,256)) and then I add high noise to it ( J = I + sigma*randn(size(I)) ) which set the image range to something like [-220 220]. I have three methods to plot the image as follows (just assume the image is not converted to double):
1) imshow(J) - when I read other images, it's by default in uint8 type.
2) imshow(double(J), [])
3) imshow(double(J), [0 255])
Which one is "perceptually" the true representation of the noisy image? Does imshow() perform clipping/quantization? Many thanks in advance.
##### 3 CommentsShow 1 older commentHide 1 older comment
Muzammil Behzad on 19 Jul 2016
Thank you Adam for your response. Yes I went through them and it's quite explained but I still have the confusion that's why I posted. The main thing is that we can use any option to display 'that we want'. I am more concerned to which option is 'perceptually the correct one'. As I said my noisy image has values something like [-220 220]. I can use any method to display as per 'my want/will' but which one should be the correct one 'perceptually'. For example, see the attached two figures. Figure 1 is displayed as imshow(J,[]) and Figure 2 is displayed as imshow(J, [0 255]).
Now since I have to calculate PSNR for the image so I want to know which one is 'correct one' because if I find PSNR for one version of the image and displaying the other version of the image, it's totally wrong. So I want both the objective (PSNR and SSIM etc.) and subjective representation to be compatible/on the same page.
Adam on 19 Jul 2016
'Perceptually correct' is a fairly subjective measure and the type of thing people do PhDs on so it isn't really trivial. You can make a decision based purely on the maths applied in each one or you can do a lot of reading to understand the intricacies of perceptual interpretation. It depends what you want to highlight though really. Stretching data values in not necessarily wrong because the individual data values are arbitrary anyway in terms of their absolute values.

Thorsten on 19 Jul 2016
I usually use
imshow(J, [])
to view the full range of data. In the end, data are always quantized to be shown as 24bit RGB images, assuming that you have a standard monitor that supports no higher resolution than 24bit.
##### 2 CommentsShow NoneHide None
Muzammil Behzad on 19 Jul 2016
But if the image (noisy image lets say) has values out of 0-255 then which one is perceptually correct one? if we use what you said (imshow(J, [])) then it will bring the minimum value to zero, the maximum value to 255 and will scale the intermediate values accordingly. Isn't that incorrect, i.e., scaling the intensities to other values?
Thorsten on 19 Jul 2016
You're right. If you want to keep the intensity values in the range of the original values, you have to use
imshow(J, [0 255])

Image Analyst on 19 Jul 2016
imshow() does clip if you don't use []. If you use [], then it scales each image's min-to-max to 0-255. So to compare images on the same scale, you'll have to find the overall min and max of ALL images, then pass those in.
imshow(image1, [overallMin, overallMax]);
imshow(image2, [overallMin, overallMax]);

### Categories

Find more on Image Quality in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!