getrangefromclass
基于所属类的图像的默认显示范围
说明
示例
获取图像的默认显示范围
读取数据类型为 uint8
的一个示例图像。
Im = imread('peppers.png');
imshow(Im)
从该图像中获取显示范围。uint8
类型的图像的像素值在 [0, 255] 范围内。
rangeIm = getrangefromclass(Im)
rangeIm = 1×2
0 255
将图像从 uint8
类型转换为 double
类型。
RGB = im2double(Im);
获取新图像的显示范围。像素值在 [0, 1] 范围内,这与 MATLAB® 软件解释 double
类型的图像的方式一致。
rangeRGB = getrangefromclass(RGB)
rangeRGB = 1×2
0 1
输入参数
I
— 输入图像
数值数组 | 逻辑数组
输入图像,指定为数值数组或逻辑数组。
输出参量
range
— 显示范围
二元素数值向量
显示范围,以 [min max]
形式的二元素数值向量形式返回。
对于
single
和double
数据,getrangefromclass
返回的范围[0 1]
与 MATLAB® 软件解释double
和single
类型图像的方式一致。对于整数数据,
getrangefromclass
返回该整数类的最小和最大可表示值。例如,如果类为uint8
,则动态范围为[0 255]
。对于
logical
数据,getrangefromclass
返回范围[0 1]
。
数据类型: double
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
GPU 代码生成
使用 GPU Coder™ 为 NVIDIA® GPU 生成 CUDA® 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)