图像处理课程设计报告

摘要:MATLAB和Mathematica、Maple并称为三大数学软件。它在数学类科技应用软件

在数值计算方面首屈一指。MATLAB可以进行矩阵运算、绘制函数和数据、实现算法、创

用户界面、连

接其他编程语言的程序等,主要应用于工程计算、控制设计、信号处理与通讯、图像处理、信号检测、金融建模设计与分析等领域。

数字图像处理(DigitalImageProcessing)是通过计算机对图像进行去除噪声、增强、复原、分割、提取特征等处理的方法和技术。数字图像处理的产生和迅速发展主要受三个因素的影响:一是计算机的发展;二是数学的发展(特别是离散数学理论的创立和完善);三是广泛的农牧业、林业、环境、军事、工业和医学等方面的应用需求的增长。

关键词:MATLAB,数字图像处理

一.课程设计目的

1、提高分析问题、解决问题的能力,进一步巩固数字图像处理系统中的基本原理与方法。

2、熟悉掌握一门计算机语言,可以进行数字图像的应用处理的开发设计

. 课程设计的内容

MATLAB GUI程序设计,利用MATLAB图像处理工具箱。

要求:按照软件工程方法,根据需求进行程序的功能分析和界面设计,给出设计详细说明。然后按照自己拟定的功能要求进行程序设计和调试。

以下几点是程序实现的功能。

1)能对图像文件(bmp、 jpg、 tiff、 gif等)进行打开、保存、另存、打印、退出等功能操作。

(2)能对图像进行直方图统计,包括R直方图,直方图统计,直放图均衡,周长和面积计算,区域图面积统计。

(3)能对图像进行图像变化处理,包括小波变换,傅里叶变换,快速傅里叶变化,快速逆变换,傅里叶逆变换,离散余弦变换。

(4)能对图像进行滤波处理,包括低通滤波,平滑滤波,自适应滤波。

(5)能对图像进行频域增强处理,包括同态滤波,高频锐化。

(6)能对图像进行噪声添加处理,包括椒盐噪声,加性噪声,高斯噪声。

(7)能对图像进行图像滤波器处理,包括高通滤波器,低通滤波器。

三、总体方案设计

通过MATLAB 的GUI 设计界面,实现打开,保存,退出,打印功能,设计对比

示区,功能按钮,实现各种图形处理的基本功能。

四、各个功能模块的主要实现程序

     在gui界面上创建一系列的按钮以实现各种功能。其实现语句如下:

打开程序:

function OPEN_Callback(hObject, eventdata, handles)

% hObject    handle to OPEN (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

[name,path]=uigetfile({'*.jpg';'*.bmp';'*.gif';'*.tif'},'ÔØÈëͼÏñ');

if isequal(name,0)isequal(path,0)

    errordlg('ûÓÐÑ¡ÖÐÎļþ','³ö´í');

    return

else

    x=imread([path,name]);

    axes(handles.axes1);

    imshow(x);

    handles.img=x;

    handles.noise_img=x;

    guidata(hObject,handles)

end

保存程序:

function save_Callback(hObject, eventdata, handles)

% hObject    handle to save (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

[filename,pathname] = uiputfile({'*.jpg';'*.bmp';'*.gif';'*.tif'},'ͼƬ±£´æΪ');

if isequal([filename,pathname],[0,0])

     errordlg('ûÓб£´æ','³ö´í');

     return;

else

file=strcat(pathname,filename);

(handles.axes1);

i=getimage(gca);

imwrite(i,file);

打印程序:

function dayin_Callback(hObject, eventdata, handles)

% hObject    handle to dayin (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

printpreview

printpreview(f)

退出程序:

function tuichu_Callback(hObject, eventdata, handles)

% hObject    handle to tuichu (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% hObject    handle to quit (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

button = questdlg('ÄúÈ·¶¨ÒªÍ˳ö±¾³ÌÐòÂð£¿','È·¶¨²Ù×÷');

switch button

case 'Yes'  

  close(gcf);

    case 'No'

     

end;

然后制作axes1并建立面板,修改颜色和名称,即界面中的function,再在面板上添加按钮

1. R直方图按钮程序:

function RZHIFANGTU_Callback(hObject, eventdata, handles)

% hObject    handle to RZHIFANGTU (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.axes1,'HandleVisibility','ON');

axes(handles.axes1);

x=imhist(handles.img(:,:,1));                       %Ö±·½Í¼Í³¼Æ

x1=x(1:10:256);

horz=1:10:256;

bar(horz,x1);

set(handles.axes1,'xtick',0:50:255);

2.直方图统计按钮:

function zhifangtutongji_Callback(hObject, eventdata, handles)

% hObject    handle to zhifangtutongji (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.axes1,'HandleVisibility','ON');

axes(handles.axes1);

x=imhist(handles.img(:,:,1));                       %Ö±·½Í¼Í³¼Æ

x1=x(1:10:256);

horz=1:10:256;

bar(horz,x1);

axes(handles.axes1);

set(handles.axes1,'xtick',0:50:255);

% hObject    handle to tongji (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 % --- Executes on button press in zhifangtujunheng.

3.直方图统计按钮程序:
function zhifangtujunheng_Callback(hObject, eventdata, handles)

% hObject    handle to zhifangtujunheng (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

set(handles.axes1,'HandleVisibility','ON');

axes(handles.axes1);

if isrgb(handles.img)

    a=histeq(handles.img(:,:,1));

    b=histeq(handles.img(:,:,2));

    c=histeq(handles.img(:,:,3));

    k(:,:,1)=a;

    k(:,:,2)=b;

    k(:,:,3)=c;

    axes(handles.axes1);

    imshow(k);

else

h=histeq(handles.img);

axes(handles.axes1);%Ö±·½Í¼¾ùºâ

imshow(h);

end

% hObject    handle to junheng (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 % --- Executes on button press in mianjijisuan.

4.周长和面积计算程序:

function mianjijisuan_Callback(hObject, eventdata, handles)

% hObject    handle to mianjijisuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

y=handles.img;

k=rgb2gray(y);

BW = im2bw(k); % ת»¯Îª¶þֵͼÏñ

[L,N] = bwlabel(BW,4); % ±ê×¢¶þ½øÖÆͼÏñÖÐÒÑÁ¬½ÓµÄ²¿·Ö

X=1;%ĬÈÏͼÏñÖÐÖ»ÓÐÒ»¸öÁ¬Í¬ÇøÓò.

[i j]=find(L==X);%½«±ê×¢µÄÇøÓò·Åµ½Ò»¸öÊý×éÖÐ.

bwi=bwselect(L,i,j,4);

p=bwperim(bwi);

perm=sum(sum(p));%Öܳ¤.

area=size(i);%Ãæ»ý.±ê×¢ÇøÓòÏñËصãÊý¾ÍΪÎïÌåÃæ»ý.

imshow(BW);

pa=['ͼÏñÃæ»ýΪ:' num2str(area) 'ÏñËصã'];

pp=['ͼÏñÖܳ¤Îª:' num2str(perm) 'ÏñËØ'];

xxx=[pa,pp];

title(xxx);

% hObject    handle to zhouchanghemianji (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA

% --- Executes on button press in pushbutton8.

5.区域图面积程序

function quyumianji_Callback(hObject, eventdata, handles)

% hObject    handle to quyumianji (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

y=handles.img;

k=rgb2gray(y);

x=area(k,-2);

 title('ÇøÓòÃæ»ýͼµÄ»æÖÆ');

set(gca,'Layer','top');

 % hObject    handle to quyutumianji (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 % --- Executes on button press in kuaisufuliyebianhuan.

6.小波变换程序:
function xiaobo_Callback(hObject, eventdata, handles)

% hObject    handle to xiaobo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if (isrgb(x)~=0);

y=rgb2gray(x);

 [cA1,cH1,cV1,cD1] = dwt2(y,'bior3.7');

A1=upcoef2('a',cA1,'bior3.7',1);

image(wcodemat(A1,192));

 title('½üËÆֵϵÊýA1');

else

      [cA1,cH1,cV1,cD1] = dwt2(x,'bior3.7');

A1=upcoef2('a',cA1,'bior3.7',1);

image(wcodemat(A1,192));

end

% hObject    handle to xiaobobianhuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in ditonglvbo.

7.傅里叶变换程序:

function fuliyebianhuan_Callback(hObject, eventdata, handles)

% hObject    handle to fuliyebianhuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if isrgb(x);

i=fft(x);

else

 i=fft(x);

end

O=fftshift(i);

imshow(O);

title('ÆÕͨft±ä»»ºóµÄͼÏñ');

% hObject    handle to ft (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

8.快速傅里叶程序:
function kuaisufuliyebianhuan_Callback(hObject, eventdata, handles)

% hObject    handle to kuaisufuliyebianhuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

i=fftn(x);

else

 i=fft2(x);

end

 O=fftshift(i);

imshow(O);

title('fft±ä»»ºóµÄͼÏñ');

% hObject    handle to fft (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in nibianhuan.

9.快速逆变换程序;

function nibianhuan_Callback(hObject, eventdata, handles)

% hObject    handle to nibianhuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

i=ifftn(x);

O=fftshift(i);

imshow(O);

title('ifft±ä»»ºóµÄͼÏñ');

else

 i=ifft2(x);

 O=fftshift(i);

imshow(O);

title('ifft±ä»»ºóµÄͼÏñ');

end

% hObject    handle to ifft (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

10.傅里叶逆变换程序:
function fuliyenibianhuan_Callback(hObject, eventdata, handles)

% hObject    handle to fuliyenibianhuan (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

i=ifft(x);

else

 i=fft(x);

end

O=ifftshift(i);

imshow(O);

title('ÆÕͨift±ä»»ºóµÄͼÏñ');

% hObject    handle to ift (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

11.离散余弦变化程序:

function yuxuanbianhua_Callback(hObject, eventdata, handles)

% hObject    handle to yuxuanbianhua (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

x=(handles.img);

if (isrgb(x)~=0);

y=rgb2gray(x);

i=dct(y);

imshow(i);

title('DCT±ä»»ºóµÄͼÏñ');

else

     i=dct(x);

imshow(i);

title('DCT±ä»»ºóµÄͼÏñ');

end    

% hObject    handle to dct (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

12.低通滤波程序:

function ditonglvbo_Callback(hObject, eventdata, handles)

% hObject    handle to ditonglvbo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

if isrgb(handles.img)

x=(handles.img);

y=rgb2gray(x);

h=imnoise(y,'salt & pepper',0.04);                  %¼Ó½·ÑÎÔëÉù

z=medfilt2(h,[5 5],'symmetric');                    %ÖÐÖµÂ˲¨

imshow(z);

else

     msgbox('ÕâÒѾ­ÊǻҶÈͼÏñ','ת»»Ê§°Ü');

end    

% hObject    handle to ditonglubo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

12.平滑滤波程序:

function pinhualvbo_Callback(hObject, eventdata, handles)

% hObject    handle to pinhualvbo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

axes(handles.axes1);

img=(handles.img);

if isrgb(img)

f=rgb2gray(img);

f=double(f);

f=fft2(f);

f=fftshift(f);

[m,n]=size(f);  %

d0=80;

m1=fix(m/2);

n1=fix(n/2);

for i=1:m

    for j=1:n

        d=sqrt((i-m1)^2+(j-n1)^2);

        h(i,j)=exp(-d^2/2/d0^2);

    end

end

g=f.*h;

g=ifftshift(g);

g=ifft2(g);

g=mat2gray(real(g));

imshow(g);

else

     msgbox('ÕâÒѾ­ÊǻҶÈͼÏñ','ת»»Ê§°Ü');

end    

% hObject    handle to pinghualubo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in zishiyin.

13.自适应滤波程序:

function zishiyin_Callback(hObject, eventdata, handles)

% hObject    handle to zishiyin (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

if isrgb(handles.img)

x=(handles.img);

y=rgb2gray(x);

h=imnoise(y,'gaussian',0,0.05);                 %¼Ó¸ß˹ÔëÉù

z=wiener2(h,[5 5]);%×ÔÊÊÓ¦Â˲¨

axes(handles.axes1);

imshow(z);

else

      msgbox('ÕâÒѾ­ÊǻҶÈͼÏñ','ת»»Ê§°Ü');

end    

% hObject    handle to zishiyinglubo (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in tongtai.

14.同态滤波程序:

function tongtai_Callback(hObject, eventdata, handles)

% hObject    handle to tongtai (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

y=(handles.img);

I=rgb2gray(y);

I=im2uint8(I);

[M N]=size(I);        

I=double(I);      

lnI = log(1+I); ;    

FI  = fft2(lnI);   

P =fftshift(FI);       

for i=1:M

    for j=1:N 

        D(i,j)=((i-M/2)^2+(j-N/2)^2);

    end               

end

 prompt={'Èñ»¯²ÎÊý:','½ØֹƵÂÊ'};

 defans={'0','0'};

 p=inputdlg(prompt,'Èñ»¯²ÎÊý:',1,defans);

 c=str2num(p{1});

 Do=str2num(p{2}); 

 H=(2.0-0.5)*(1-exp(c*(-D/(Do^2))))+0.5;

 hI=FI.*H;                               

gI=ifft2(hI);   

Y=exp(gI);     

G=real(Y);

s=uint8(G);

imshow(s);

% hObject    handle to tongtaizq (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in gaopin.

15.高频锐化程序:

function gaopin_Callback(hObject, eventdata, handles)

% hObject    handle to gaopin (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

if isrgb(handles.img)

x=(handles.img);

y=rgb2gray(x);

h=[0 -1 0;-1 4 -1;0 -1 0 ];

I=imfilter(y,h);

imshow(I);

title('ƵÓòÈñ»¯ºóµÄͼÏñ');

end

% hObject    handle to gaopingruihua (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in jiaoyanzaosheng.

16.椒盐噪声程序:

function jiaoyanzaosheng_Callback(hObject, eventdata, handles)

% hObject    handle to jiaoyanzaosheng (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

prompt={'ÊäÈë²ÎÊý:'};

%¶Ô»°¿òµÄÉèÖã¬Óû§ÊäÈëµÄÊÇ×Ö·û´®

defans={'0.02'};    %ȱʡֵ

p=inputdlg(prompt,'ÊäÈë²ÎÊý£º',1,defans);   

p1=str2num(p{1});         %×Ö·û´®×ª»¯ÎªÊýÖµ

axes(handles.axes1);

x=(handles.img);

y=imnoise(x,'salt & pepper',p1);              

handles.noise_img=y;

guidata(hObject,handles);

imshow(y);

% hObject    handle to jiaoyanzaosheng (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in jiaxin.

16.加性噪声程序:

function jiaxin_Callback(hObject, eventdata, handles)

% hObject    handle to jiaxin (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

axes(handles.axes1);

prompt={'ÊäÈë²ÎÊý:'};

defans={'0.02'};

p=inputdlg(prompt,'ÊäÈë²ÎÊý£º',1,defans);

p1=str2num(p{1});

y=imnoise(handles.img,'speckle',p1);

 handles.noise_img=y;

guidata(hObject,handles);

imshow(y);

% hObject    handle to jiaxingzaosheng (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in gaosizaosheng.

 % --- Executes on button press in gaotonglvboqi.

1

17.高斯噪声程序:

function gaotonglvboqi_Callback(hObject, eventdata, handles)

% hObject    handle to gaotonglvboqi (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% hObject    handle to Gaosigaotonglb (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

%¸ßͨÂ˲¨Æ÷

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

    msgbox('ÕâÊDzÊɫͼÏñ,²»ÄÜͨ¹ý¸ßͨÂ˲¨Æ÷','ʧ°Ü');

else

y1=imnoise(x,'gaussian');   %¼Ó¸ß˹ÔëÉù

f=double(y1);       % Êý¾ÝÀàÐÍת»»

k=fft2(f);          % ¸µÁ¢Ò¶±ä»»

g=fftshift(k);       % ת»»Êý¾Ý¾ØÕó

[M,N]=size(g);

nn=2;

d0=3;        %½ØֹƵÂÊΪ3

m=fix(M/2); n=fix(N/2);

for i=1:M

        for j=1:N

            d=sqrt((i-m)^2+(j-n)^2);       % ¼ÆËã¸ßͨÂ˲¨Æ÷´«µÝº¯Êý

            if d<=d0

                h=0;

            else h=1;

            end

            result(i,j)=h*g(i,j);

        end

end

result=ifftshift(result);

y2=ifft2(result);

y3=uint8(real(y2));

imshow(y3);   

end

% --- Executes on button press in batewosi.

18.高通滤波器程序:

function gaotonglvboqi_Callback(hObject, eventdata, handles)

% hObject    handle to gaotonglvboqi (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% hObject    handle to Gaosigaotonglb (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

%¸ßͨÂ˲¨Æ÷

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

    msgbox('ÕâÊDzÊɫͼÏñ,²»ÄÜͨ¹ý¸ßͨÂ˲¨Æ÷','ʧ°Ü');

else

y1=imnoise(x,'gaussian');   %¼Ó¸ß˹ÔëÉù

f=double(y1);       % Êý¾ÝÀàÐÍת»»

k=fft2(f);          % ¸µÁ¢Ò¶±ä»»

g=fftshift(k);       % ת»»Êý¾Ý¾ØÕó

[M,N]=size(g);

nn=2;

d0=3;        %½ØֹƵÂÊΪ3

m=fix(M/2); n=fix(N/2);

for i=1:M

        for j=1:N

            d=sqrt((i-m)^2+(j-n)^2);       % ¼ÆËã¸ßͨÂ˲¨Æ÷´«µÝº¯Êý

            if d<=d0

                h=0;

            else h=1;

            end

            result(i,j)=h*g(i,j);

        end

end

result=ifftshift(result);

y2=ifft2(result);

y3=uint8(real(y2));

imshow(y3);   

end

% --- Executes on button press in batewosi.

19.低通滤波器

function batewosi_Callback(hObject, eventdata, handles)

% hObject    handle to batewosi (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% hObject    handle to Batewosidt (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

%µÍͨÂ˲¨Æ÷

axes(handles.axes1);

x=(handles.img);

if isrgb(x)

    msgbox('ÕâÊDzÊɫͼÏñ,²»ÄÜͨ¹ýµÍͨÂ˲¨Æ÷','ʧ°Ü');

else

y1=imnoise(x,'salt & pepper');   % µþ¼Ó½·ÑÎÔëÉù

f=double(y1);   % Êý¾ÝÀàÐÍת»»£¬MATLAB²»Ö§³ÖͼÏñµÄÎÞ·ûºÅÕûÐ͵ļÆËã

g=fft2(f);       % ¸µÁ¢Ò¶±ä»»

g=fftshift(g);    % ת»»Êý¾Ý¾ØÕó

[M,N]=size(g);

nn=2;       % ¶þ½×°ÍÌØÎÖ˹(Butterworth)µÍͨÂ˲¨Æ÷

d0=10;      %½ØֹƵÂÊΪ10

m=fix(M/2); n=fix(N/2);

for i=1:M

       for j=1:N

           d=sqrt((i-m)^2+(j-n)^2);

           h=1/(1+0.414*(d/d0)^(2*nn));   % ¼ÆËãµÍͨÂ˲¨Æ÷´«µÝº¯Êý

           result(i,j)=h*g(i,j);

       end

end

result=ifftshift(result);

y2=ifft2(result);

y3=uint8(real(y2));

imshow(y3);  % ÏÔʾÂ˲¨´¦ÀíºóµÄͼÏñ

end

% --- Executes on mouse press over figure background.

function figure1_ButtonDownFcn(hObject, eventdata, handles)

% hObject    handle to figure1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

测试和调试

原图片:

R直方图:

直方图均衡:

周长和面积计算:

区域面积图的绘制:

小波变换:

傅里叶变换:

快速逆变换:

快速傅里叶变化:

傅里叶逆变换:

离散余弦变:

低通滤波:

平滑滤波:

自适应滤波:

 

同态滤波:

高频锐化:

椒盐噪声:

加性噪声:

图像经过滤波器:

巴特沃斯低通滤波:

高斯高通滤波:

GUI界面:

六、设计心得

通过自己亲自做本次设计是我受益匪浅,不仅学到很多课本里德东西更重要的是锻炼了自己的动手能力。通过本次的数字图像处理设计,发现了自己MATLAB的不足之处,并对语法和程序设计有了进一步的理解,对GUI有了一定的掌握,基本完成了设计要求。图像处理应用数知识解决实际问题。

课程设计不仅让我完成了老师的课程要求,还有了一定的实际应用能力,这种学以致用的课程对我能力提升有很大的帮助,在老师的悉心教导对我的数字图像处理课程和其他课程的学习有很大的启发,还要不断努力,积极学习,为将来的毕业打下坚实的基础。

通过此次学习知道自己还要非常多的东西需要补充,学习是一个积累的过程,在平时就要注意,不要等到最后才想办法。

七:参考文献

【1】  程卫国,冯峰,姚东,徐听.MATLAB5.3应用指南[M].北京:人民邮电出版社

【2】《MATLAB图像处理与识别案例精选 》 胡晓峰编著

相关推荐