What is the need for [ ] in imshow(I,[ ]);

9 Ansichten (letzte 30 Tage)
D Joseph
D Joseph am 14 Aug. 2015
Kommentiert: Halina H am 5 Dez. 2017
What is the need for [ ] in imshow(I,[ ]); Here I represents an image

Antworten (1)

Walter Roberson
Walter Roberson am 14 Aug. 2015
imshow(I) defaults to using imshow(I,[]) for grayscale images, with the behaviour of imshow(I) and imshow(I,[]) on color images being undefined in the documentation. Coding imshow(I,[]) is something that programmers do to signal that they specifically want imshow to use the scaling behaviour
imshow(I,[]) for grayscale images, whether coded or by default, uses image objects and sets CDataMapping to 'scaled' and sets the axes CLimMode to 'auto'
As described in the imshow DisplayRange parameter:
Display range of a grayscale image, specified as a two-element vector [LOW HIGH]. imshow displays the value low (and any value less than low) as black, and the value high (and any value greater than high) as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. If you specify an empty matrix ([]), imshow uses [min(I(:)) max(I(:))]; that is, use the minimum value in I as black, and the maximum value as white.
  9 Kommentare
Image Analyst
Image Analyst am 5 Dez. 2017
If you use imshow(Image) you will display any values as unscaled and if the value is more than 1 it will clip to 1 and show up as all white. If the value is less than 0, it will clip to 0 and show up as all black. Values in between 0 and 1 will show up as normal gray scale.
If you imshow(Image,[]) it will find the min and map it to 0 and be black. It will find the max and map it to 1 and show up as all white. There will be no clipping like there is if you don't use []. If the range is beyond 0-1, like negative numbers or numbers in the hundreds or thousands, it will compress the range so that all values show up as gray scale (no clipping at all). If the range is less than 0-1 (like .3 to .6 or something), then it will expand the range so that, again, all values show up as gray scale. Using [] will give you the max dynamic range possible while still being able to see all pixels with no clipping/saturation.
Using imshow(uint8(Image)) will cast the double image to integers in the range 0-255. If the range is beyond that, then clipping will occur. If not, then no clipping will occur. The pixels are displayed with their actual gray level, so no compression or expansion of intensity will occur. If the range is less than 0-255 then the image will show up with less contrast than if you had used []. If the range is more than 0-255, clipping will occur for values less than 0 or more than 255, but the values in between 0 and 255 will stay the same (rounded to the nearest integer of course).
I hope that explains it so you can understand where your thinking was incorrect.
Halina H
Halina H am 5 Dez. 2017
Thanks for the further clarification Image Analyst. It helps me to correct my understanding.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by