getrangefromclass
Default display range of image based on its class
Description
Examples
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
Input image, specified as a numeric array or logical array.
Output Arguments
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™.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
The getrangefromclass
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)