图像处理实验报告一
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
一.图像的读入与直方图拓展
>> clear;
>> clear all;
>> I=imread('pout.tif');
>> imshow(I)
>> whos
Name Size Bytes Class
I 291x240 69840 uint8 array Grand total is 69840 elements using 69840 bytes
>> figure,imhist(I)
>> I2=histeq(I);
>> figure,imhist(I2)
>> figure,imshow(I2)
>> imwrite(I2,'pout.tif')
>> imfinfo('pout.tif')
ans =
Filename: 'pout.tif'
FileModDate: '19-Dec-2012 18:52:08'
FileSize: 67816
Format: 'tif'
FormatVersion: []
Width: 240
Height: 291
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubfileType: 0
BitsPerSample: 8
Compression: 'PackBits' PhotometricInterpretation: 'BlackIsZero'
StripOffsets: [9x1 double]
SamplesPerPixel: 1
RowsPerStrip: 34
StripByteCounts: [9x1 double]
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 255
MinSampleValue: 0
Thresholding: 1
二、同时读入若干幅图像,可以频繁使用figure,imshow;但若要求
在同一窗口读入若干幅图像:则可调用subplot函数。
I1=imread('pout.tif');
>> I2=imread('moon.tif');
>> I3=imread('onion.png');
>> I4=imread('tire.tif');
>> subplot(2,2,1),imshow(I1);
>> subplot(2,2,2),imshow(I2);
>> subplot(2,2,3),imshow(I3);
>> subplot(2,2,4),imshow(I4);
三、还可以尝试读入其它的图片,进行形态学的开闭运算操作、骨骼
化、条纹细化等操作,并可尝试改变结构元素等操作。
图片处理
>> I=imread('rice.png');
>> imshow(I)
>> b=imopen(I,strel('disk',15));
>> I2=imsubtract(I,b);
>> figure,imshow(I2)
>> %图像有些暗,调对比度
>> I3=imadjust(I2,stretchlim(I2),[]);
>> figure,imshow(I3)
>> %检查图像中的对象个数
>> level=graythresh(I3);
>> b2=im2bw(I3,level);%b2=im2bw(I3,graythresh(I3))
>> figure,imshow(b2)
>> [l,num]=bwlabel(b2,4);
>> num
num =
101
>> c=imcrop(l);%裁剪图片
>> figure,imshow(c)
>> rgb_c=label2rgb(l,@spring,'c','shuffle'); >> figure,imshow(rgb_c)。