getrangefromclass
Returns the minimum and maximum values of an image's data class.
Category: Graphics > Images
Syntax
range = getrangefromclass(I)
Returns [min max] for the class of I.
Description
Only the class of I matters, not its values. For integer classes the range is the full span of the type; for floating-point and logical images the conventional display range [0 1] is returned. It is useful for scaling code that must work with several image classes.
Input arguments
I- Image array of any numeric or logical class.
Output arguments
range- Two-element vector:
[0 255]foruint8,[-32768 32767]forint16,[0 1]fordouble,singleand logical.
Example
Ranges by class
getrangefromclass(uint8(1))
getrangefromclass(int16(1))
getrangefromclass(0.5)
Output
ans = 1×2
0 255
ans = 1×2
-32768 32767
ans = 1×2
0 1