im2single
将图像转换为单精度
说明
示例
将数组转换为单精度数据类型
此示例说明如何将数据类型为 uint8
的数组转换为数据类型 single
。
创建一个数据类型为 uint8
的数值数组。
I = reshape(uint8(linspace(1,255,25)),[5 5])
I = 5x5 uint8 matrix
1 54 107 160 213
12 65 117 170 223
22 75 128 181 234
33 86 139 192 244
43 96 149 202 255
将该数组转换为数据类型 single
。
I2 = im2single(I)
I2 = 5x5 single matrix
0.0039 0.2118 0.4196 0.6275 0.8353
0.0471 0.2549 0.4588 0.6667 0.8745
0.0863 0.2941 0.5020 0.7098 0.9176
0.1294 0.3373 0.5451 0.7529 0.9569
0.1686 0.3765 0.5843 0.7922 1.0000
输入参数
I
— 输入图像
数值数组 | 逻辑数组
输入图像,指定为任意大小和维度的数值数组或逻辑数组。
如果
I
是灰度或 RGB 图像,则它可以是uint8
、uint16
、double
、logical
、single
或int16
。如果
I
是索引图像,则它可以是uint8
、uint16
、double
或logical
。如果
I
是二值图像,则它必须为logical
。
数据类型: single
| double
| int16
| uint8
| uint16
| logical
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
im2single
支持 C 代码生成(需要 MATLAB® Coder™)。有关详细信息,请参阅图像处理的代码生成。
GPU 代码生成
使用 GPU Coder™ 为 NVIDIA® GPU 生成 CUDA® 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
GPU 数组
通过使用 Parallel Computing Toolbox™ 在图形处理单元 (GPU) 上运行来加快代码执行。
此函数完全支持 GPU 数组。有关详细信息,请参阅GPU 上的图像处理。
版本历史记录
在 R2006a 之前推出R2021b: 支持基于线程的环境
im2single
现在支持基于线程的环境。
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)