数字图像处理题库Word文档格式.docx
《数字图像处理题库Word文档格式.docx》由会员分享,可在线阅读,更多相关《数字图像处理题库Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
subplot(1,2,1);
subplot(1,2,2);
imshow(S);
非线性扩展的图像'
3.采用灰度倒置变换函数s=255-r进行图像eight.tif变换
a=-1;
b=255;
S=a.*I+b/255;
变换后的图像'
4.对图像eight.tif进行旋转45度和180度
J=imrotate(I,60,'
bilinear'
K=imrotate(I,180,'
imshow(J);
旋转60图像'
imshow(K);
旋转180图像'
5.选取一副图像eight.tif,进行离散傅里叶变换,将其中心移到零点,得到其离散傅里叶变换。
参考例4.10
I1=fftshift(fft2(I));
imshow(log(abs(I1)),[]);
6.选取一副图像,进行离散傅里叶变换,再对其进行一定角度的旋转,进行离散傅里叶变换.参考例4.6
I=zeros(255,255);
I(100:
150,50:
200)=1;
I1=fftshift(abs(fft2(I)));
I2=imrotate(I,60,'
'
crop'
I3=fftshift(abs(fft2(I2)));
subplot(1,4,1);
subplot(1,4,2);
imshow(I1,[550]);
傅立叶变换后的图像'
subplot(1,4,3);
旋转90度后图像'
subplot(1,4,4);
imshow(I3,[550]);
傅立叶变换后的原始图像'
7.选取一副图像eight.tif,进行离散余弦变换,并对其进行离散余弦反变换。
参考例4.13
I1=dct2(I);
I2=idct2(I1)/255;
余弦变换图像'
反余弦变换图像'
8.选取一副图像eight.tif,采用butterworth高通滤波器对图像进行高通滤波。
参考例5.7
[M,N]=size(I1);
n=2;
d0=30;
n1=floor(M/2);
n2=floor(N/2);
forx=1:
M
fory=1:
N
d=sqrt((x-n1)^2+(y-n2)^2);
H=1/(1+(d0/d)^(2*n));
I2(x,y)=H*I1(x,y);
end
end
I2=ifftshift(I2);
I3=real(ifft2(I2));
imshow(I3);
Butterworth高通滤波处理后的图像'
9.选择一副图像eight.tif,对灰度图像进行直方图均衡化处理。
K=16;
H=histeq(I,K);
figure,
subplot(2,2,1);
imshow(I,[]);
subplot(2,2,2);
imshow(H,[]),holdon
subplot(2,2,3),hist(double(I),16);
subplot(2,2,4),hist(double(H),16);
10.选择一副图像eight.tif,对灰度图像采用均值滤波。
img=imread('
imshow(img);
原图'
img_noise=double(imnoise(img,'
salt&
pepper'
0.08));
imshow(img_noise,[]);
加噪点图'
img_deal=imfilter(img_noise,fspecial('
average'
5));
imshow(img_deal,[]);
平滑图'
11.选择一副图像coins.png,对灰度图像,采用prewitt边缘算子和sobel算子对图像进行增强处理。
coins.png'
img1=edge(img,'
prewitt'
img2=edge(img,'
sobel'
imshow(img1);
imshow(img2);
12.仿照matlab识别圆形物体例程,对coins.png图像进行处理。
threshold=graythresh(I);
bw=im2bw(I,threshold);
%removeallobjectcontainingfewerthan30pixels
bw=bwareaopen(bw,30);
%fillagapinthepen'
scap
se=strel('
disk'
2);
bw=imclose(bw,se);
%fillanyholes,sothatregionpropscanbeusedtoestimate
%theareaenclosedbyeachoftheboundaries
bw=imfill(bw,'
holes'
[B,L]=bwboundaries(bw,'
noholes'
%Displaythelabelmatrixanddraweachboundary
holdon
fork=1:
length(B)
boundary=B{k};
plot(boundary(:
2),boundary(:
1),'
w'
'
LineWidth'
2)
stats=regionprops(L,'
Area'
Centroid'
threshold=0.94;
%loopovertheboundaries
%obtain(X,Y)boundarycoordinatescorrespondingtolabel'
k'
%求周长
delta_sq=diff(boundary).^2;
perimeter=sum(sqrt(sum(delta_sq,2)));
%求面积
area=stats(k).Area;
%求半径
metric=2*area/perimeter;
metric_string=sprintf('
r=%2.2f'
metric);
text(boundary(1,2)-35,boundary(1,1)+13,metric_string,'
Color'
y'
...
'
FontSize'
14,'
FontWeight'
bold'
求各个硬币的半径'
13.对灰度图像进行直线检测,参考例8.2
img1.bmp'
I=rgb2gray(I);
bw=edge(I,'
log'
[H,T,R]=hough(bw);
P=houghpeaks(H,5,'
threshold'
ceil(0.3*max(H(:
))));
x=T(P(:
2));
y=R(P(:
1));
lines=houghlines(bw,T,R,P,'
FillGap'
5,'
MinLength'
10);
imshow(bw);
holdon;
max_len=0;
fork=1:
length(lines)
xy=[lines(k).point1;
lines(k).point2];
plot(xy(:
1),xy(:
2),'
2,'
g'
14.对图像eight.tif进行OSTU算法阈值分割,参考例8.4
i=imread('
[width,height]=size(i);
thresh=graythresh(i);
bw=im2bw(i,thresh);
15.对图像img3.bmp进行开运算和闭运算以及填充,参考例8.11
img3.bmp'
i=rgb2gray(i);
bw=im2bw(i);
6);
bw=imopen(bw,se);
bw=~bw;
16.识别图像中字的个数。
参考matlab例程CorrectingNonuniformIllumination
img4.bmp'
bw=imdilate(bw,se);
[labeled,nu