matlab应用笔记[一]

本文详细介绍了MATLAB中用于图像处理的重要函数,包括imread用于读取图像,im2double将图像转换为双精度格式,imshow用于显示图像,im2bw则将图像转换为二值图像。文章通过实例展示了这些函数的使用方法,同时提及了hold函数在图像叠加中的作用,以及bwlabel用于标记二值图像中连通组件的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.imread函数
A = imread(filename, fmt) 读入字符串指定的文件名的图片文件。逗号后面的参数为格式。
该函数的返回值A有两种情况:
1.当图片文件为灰度图像的时候,得到的A是一个MxN的二维矩阵;
2.当图片文件为真彩图片的时候,得到的A是一个MxNx3的三维矩阵。 (注意这里的第三维一定是3,与图无关)
对于tiff格式的文件,由于它里面包含的彩色图片是采用CMYK色彩空间的,所以返回来的A是一个  MxNx4的三维矩阵。关于TIFF的更多信息请使用help窗口查看。
The class of A depends on the bits-per-sample
of the image data, rounded to被取整到 the next byte boundary. For example, imread returns
24-bit color data as an array of uint8 data because the sample size for each color component is 8 bits.例如,imread函数将24位的彩色数据返回为一个包含8位无符号整数的数组,因为每个色彩单元的样本尺寸是8比特。 See Tips for a discussion of bitdepths, and see Format-Specific Information for
more detail about supported bit depths and sample sizes for a particular format.

[X, map] = imread(...) reads the indexed image in filename into X and its associated colormap into map. Colormap values in the image file are automatically rescaled into the range [0,1].
该语句读取被索引的图片放入X中并且与其相关联的颜色 映射 读入到变量map中。图片文件中的颜色映射表的所有值都被自动地重整到[0,1]区间的范围。

[...] = imread(filename) attempts to infer the format of the file from its content.

该语句是用来根据文件的内容来尝试推断文件的格式的。

[...] = imread(URL,...) reads the image from an Internet URL. The URL must include the protocol type (e.g.,  http://).
该语句是从网址或者说 统一资源定位符(Uniform Resource Locator)上读取互联网上的图片,而该网址必须包含协议类型也就是说例如HTTP等的开头。

[...] = imread(...,Param1,Val1,Param2,Val2...) specifies parameters that control various characteristics of the operations for specific formats. For more information, see Format-Specific Information.

EXAMPLE
Read and Display Image
Read a sample image.
A = imread('ngc6543a.jpg');
mread returns a 650-by-600-by-3 array, A.
Display the image.
image(A)
Convert Indexed Image to RGB
Read an image and convert it to an RGB image.
Read the first image in the sample indexed image file, corn.tif.
[X,map] = imread('corn.tif');
X is a 415-by-312 array of type uint8.
Verify that the colormap, map, is not empty, and convert the data in X to RGB.通过map这个变量的值来验证颜色映射表是否为空(非真彩图像为空,彩色图像为非空),当为非空时将X的数据转换为RGB模型(彩色图像)。
if ~isempty(map)
Im = ind2rgb(X,map);
end
View the size and class of X.
whos Im
Name           Size                   Bytes                         Class                     Attributes

Im            415x312x3            3107520                   double  
X is now a 415-by-312-by-3 array of type double.

2.im2double函数
Convert image to double precision  将图像转换为双精度数据类型
Syntax
I2 = im2double(I)
RGB2 = im2double(RGB)
I = im2double(BW)
X2 = im2double(X,'indexed')
gpuarrayB = im2dou
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值