dangerChihuahua007
dangerChihuahua007

Reputation: 20915

What does `imshow(someImage, [])` do?

I am trying to figure out what the second (empty vector) parameter in imshow(someImage, []) in Matlab is for.

According to doc imshow, it's either a color map or a range of width/height, but neither of these make sense to me since the vector is empty.

Upvotes: 4

Views: 1394

Answers (2)

chappjc
chappjc

Reputation: 30589

The documentation from help imshow describes this syntax:

imshow(I,[LOW HIGH]) displays the grayscale image I, specifying the display range for I in [LOW HIGH]. The value LOW (and any value less than LOW) displays as black, the value HIGH (and any value greater than HIGH) displays as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. If you use an empty matrix ([]) for [LOW HIGH], imshow uses [min(I(:)) max(I(:))]; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white.

Upvotes: 2

Olivier
Olivier

Reputation: 921

With the empty bracket imshow will display the range between the minimum and maximum value. For example, if your image is 16bits, the maximum value is 65536, but if your actual pixel values stop at 1000, imshow(image) will seem black (because even 1000 over 65536 is small). If you use imshow(image, []), then the display will be adjust between 0 and 1000.

It is the same as:

minValue = min(min(image));
maxValue = max(max(image));
imshow(image,[minValue maxValue]);

Upvotes: 7

Related Questions