getrangefromclass
Default display range of image based on its class
Description
Examples
Get Default Display Range of Image
Read a sample image of data type uint8
.
Im = imread('peppers.png');
imshow(Im)
Get the display range from the image. Images of type uint8
have pixel values in the range [0, 255].
rangeIm = getrangefromclass(Im)
rangeIm = 1×2
0 255
Convert the image from type uint8
to type double
.
RGB = im2double(Im);
Get the display range of the new image. The pixel values are in the range [0, 1], which is consistent with how the MATLAB® software interprets images of type double
.
rangeRGB = getrangefromclass(RGB)
rangeRGB = 1×2
0 1
Input Arguments
I
— Input image
numeric array | logical array
Input image, specified as a numeric array or logical array.
Output Arguments
range
— Display range
2-element numeric vector
Display range, returned as a 2-element numeric vector of the form
[min max]
.
For
single
anddouble
data,getrangefromclass
returns the range[0 1]
to be consistent with the way MATLAB® software interprets images of typedouble
andsingle
.For integer data,
getrangefromclass
returns the minimum and maximum representable values for that integer class. For example, if the class isuint8
, the dynamic range is[0 255]
.For
logical
data,getrangefromclass
returns the range[0 1]
.
Data Types: double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)