1、数字图像处理题库1.选择一副图像eight.tif,设置输入/输出变换的灰度级范围,a=0.3,b=5,c=3,d=6。I=imread(eight.tif);I=im2double(I);I1=0.3.*I+5/255;I2=3.*I+6/255;subplot(1,3,1);imshow(I);title(原始图像);subplot(1,3,2);imshow(I1);title(a=0.3,b=5);subplot(1,3,3);imshow(I2);title(a=3,b=6);2.设置非线性扩展函数的参数c=2,r=1.5,对图像eight.tif进行变换。I=imread(eigh
2、t.tif);c=2;r=1.5;S=imadjust(I,r)*c;subplot(1,2,1);imshow(I);title(原始图像);subplot(1,2,2);imshow(S);title(非线性扩展的图像);3.采用灰度倒置变换函数s=255-r进行图像eight.tif变换I=imread(eight.tif);I=im2double(I);a=-1;b=255;S=a.*I+b/255;subplot(1,2,1);imshow(I);title(原始图像);subplot(1,2,2);imshow(S);title(变换后的图像);4.对图像eight.tif进行旋转
3、45度和180度I=imread(eight.tif);J=imrotate(I,60,bilinear);K=imrotate(I,180,bilinear);subplot(1,3,1);imshow(I);title(原始图像);subplot(1,3,2);imshow(J);title(旋转60图像);subplot(1,3,3);imshow(K);title(旋转180图像);5.选取一副图像eight.tif,进行离散傅里叶变换,将其中心移到零点,得到其离散傅里叶变换。参考例4.10I=imread(eight.tif);I1=fftshift(fft2(I);subplot(
4、1,2,1);imshow(I);title(原始图像);subplot(1,2,2);imshow(log(abs(I1),);title(变换后的图像);6.选取一副图像,进行离散傅里叶变换,再对其进行一定角度的旋转,进行离散傅里叶变换. 参考例4.6I=zeros(255,255);I(100:150,50:200)=1;I1=fftshift(abs(fft2(I);I2=imrotate(I,60,bilinear,crop);I3=fftshift(abs(fft2(I2);subplot(1,4,1);imshow(I);title(原始图像);subplot(1,4,2);im
5、show(I1,5 50);title(傅立叶变换后的图像);subplot(1,4,3);imshow(I2);title(旋转90度后图像);subplot(1,4,4);imshow(I3,5 50);title(傅立叶变换后的原始图像);7.选取一副图像eight.tif,进行离散余弦变换,并对其进行离散余弦反变换。参考例4.13I=imread(eight.tif);I1=dct2(I);I2=idct2(I1)/255;subplot(1,3,1);imshow(I);title(原始图像);subplot(1,3,2);imshow(I1);title(余弦变换图像);subpl
6、ot(1,3,3);imshow(I2);title(反余弦变换图像);8.选取一副图像eight.tif,采用butterworth高通滤波器对图像进行高通滤波。参考例5.7I=imread(eight.tif);I1=fftshift(fft2(I);M,N=size(I1);n=2;d0=30;n1=floor(M/2);n2=floor(N/2);for x=1:M for y=1:N d=sqrt(x-n1)2+(y-n2)2); H=1/(1+(d0/d)(2*n); I2(x,y)=H*I1(x,y); endendI2=ifftshift(I2);I3=real(ifft2(I
7、2);subplot(1,2,1);imshow(I);title(原始图像);subplot(1,2,2);imshow(I3);title(Butterworth高通滤波处理后的图像);9.选择一副图像eight.tif,对灰度图像进行直方图均衡化处理。I=imread(eight.tif);K=16;H=histeq(I,K);figure,subplot(2,2,1);imshow(I,);title(原始图像);subplot(2,2,2);imshow(H,),hold onsubplot(2,2,3),hist(double(I),16);subplot(2,2,4),hist(
8、double(H),16);10.选择一副图像eight.tif,对灰度图像采用均值滤波。img=imread(eight.tif);subplot(1,3,1);imshow(img);title(原图);img_noise=double(imnoise(img,salt & pepper,0.08);subplot(1,3,2);imshow(img_noise,);title(加噪点图);img_deal=imfilter(img_noise,fspecial(average,5);subplot(1,3,3);imshow(img_deal,);title(平滑图);11.选择一副图像
9、coins.png,对灰度图像,采用prewitt边缘算子和sobel算子对图像进行增强处理。img=imread(coins.png);img1=edge(img,prewitt);img2=edge(img,sobel);subplot(1,3,1);imshow(img);title(原始图像);subplot(1,3,2);imshow(img1);title(prewitt);subplot(1,3,3);imshow(img2);title(sobel);12.仿照matlab识别圆形物体例程,对coins.png图像进行处理。I=imread(coins.png);thresho
10、ld = graythresh(I);bw = im2bw(I,threshold);imshow(I);% remove all object containing fewer than 30 pixelsbw = bwareaopen(bw,30);% fill a gap in the pens capse = strel(disk,2);bw = imclose(bw,se);% fill any holes, so that regionprops can be used to estimate% the area enclosed by each of the boundaries
11、bw = imfill(bw,holes);B,L = bwboundaries(bw,noholes);% Display the label matrix and draw each boundaryhold onfor k = 1:length(B) boundary = Bk; plot(boundary(:,2), boundary(:,1), w, LineWidth, 2)endimshow(I);stats = regionprops(L,Area,Centroid);threshold = 0.94;% loop over the boundariesfor k = 1:le
12、ngth(B) % obtain (X,Y) boundary coordinates corresponding to label k boundary = Bk; % 求周长 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,metr
13、ic_string,Color,y,. FontSize,14,FontWeight,bold);endtitle(求各个硬币的半径);13.对灰度图像进行直线检测,参考例8.2I=imread(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);hold on;max_len=0;f
14、or k=1:length(lines) xy=lines(k).point1;lines(k).point2; plot(xy(:,1),xy(:,2),LineWidth,2,Color,g);end14.对图像eight.tif进行OSTU算法阈值分割,参考例8.4i=imread(eight.tif);width,height=size(i);thresh=graythresh(i);bw=im2bw(i,thresh);imshow(bw);15.对图像img3.bmp进行开运算和闭运算以及填充,参考例8.11i=imread(img3.bmp);i=rgb2gray(i);bw=im2bw(i);se = strel(disk,6);bw=imopen(bw,se);bw=bw;imshow(bw);16.识别图像中字的个数。参考matlab例程Correcting Nonuniform Illuminationi=imread(img4.bmp);i=rgb2gray(i);thresh=graythresh(i);bw=im2bw(i,thresh);se = strel(disk,2);bw=bw;bw=imdilate(bw,se);labeled,nu
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1