⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example.txt

📁 图象处理函数和一下例子,对于初学者查阅十分有帮助
💻 TXT
字号:
实例67:图像的块操作
h0=figure('toolbar','none',...
   'position',[198 56 350 468],...
   'name','实例67');
h1=axes('parent',h0,...
   'position',[0.2 0.45 0.6 0.5],...
   'visible','off');
i=imread('tire.tif');
imshow(i)
b1=uicontrol('parent',h0,...
   'units','points',...
   'tag','b1',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','边沿操作',...
   'position',[30 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''tire.tif'');,',...
       'f=inline(''max(x(:))'');,',...
       'i2=nlfilter(i,[2 2],f);,',...
       'imshow(i2)']);
b2=uicontrol('parent',h0,...
   'units','points',...
   'tag','b2',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','显示块操作',...
   'position',[100 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''tire.tif'');,',...
       'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
       'i2=blkproc(i,[6 6],f);,',...
       'imshow(i2)']);
b3=uicontrol('parent',h0,...
   'units','points',...
   'tag','b3',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','交叠块操作',...
   'position',[170 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''tire.tif'');,',...
       'f=inline(''uint8(round(mean2(x)*ones(size(x))))'');,',...
       'i2=blkproc(i,[6 6],[3 3],f);,',...
       'imshow(i2)']);
b4=uicontrol('parent',h0,...
   'units','points',...
   'tag','b4',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','关闭',...
   'fontsize',14,...
   'position',[90 50 70 30],...
   'callback','close');

实例70:函数变换
h0=figure('toolbar','none',...
   'position',[198 56 350 468],...
   'name','函数变换');
h1=axes('parent',h0,...
   'position',[0.25 0.45 0.5 0.5],...
   'visible','off');
i=imread('cameraman.tif');
imshow(i)
b1=uicontrol('parent',h0,...
   'units','points',...
   'tag','b1',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','图像压缩',...
   'position',[30 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''cameraman.tif'');,',...
       'i2=im2double(i);,',...
       'imshow(i2)']);
b2=uicontrol('parent',h0,...
   'units','points',...
   'tag','b2',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','图像解压',...
   'position',[100 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''cameraman.tif'');,',...
       'i=im2double(i);,',...
       't=dctmtx(8);,',...
       'b=blkproc(i,[8 8],''p1*x*p2'',t,t'');,',...
       'mask=[1 1 1 1 0 0 0 0;,',...
             '1 1 1 0 0 0 0 0;,',...
             '1 1 0 0 0 0 0 0;,',...
             '1 0 0 0 0 0 0 0;,',...
             '0 0 0 0 0 0 0 0;,',...
             '0 0 0 0 0 0 0 0;,',...
             '0 0 0 0 0 0 0 0;,',...
             '0 0 0 0 0 0 0 0];,',...
       'b2=blkproc(b,[8 8],''p1.*x'',mask);,',...
       'i2=blkproc(b2,[8 8],''p1*x*p2'',t'',t);,',...
       'imshow(i2)']);
b3=uicontrol('parent',h0,...
   'units','points',...
   'tag','b3',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','线条解析',...
   'position',[170 100 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''cameraman.tif'');,',...
       'bw=edge(i);,',...
       'imshow(bw)']);
b4=uicontrol('parent',h0,...
   'units','points',...
   'tag','b4',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'style','pushbutton',...
   'string','关闭',...
   'fontsize',15,...
   'position',[80 50 80 30],...
   'callback','close');

实例68:图形的过滤操作
h0=figure('toolbar','none',...
   'position',[198 56 350 468],...
   'name','过滤操作');
h1=axes('parent',h0,...
   'position',[0.3 0.45 0.5 0.5],...
   'visible','off');
i=imread('cameraman.tif');
imshow(i)
b1=uicontrol('parent',h0,...
   'units','points',...
   'tag','b1',...
   'style','pushbutton',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'string','均平过滤',...
   'position',[50 120 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''blood1.tif'');,',...
       'h=fspecial(''average'',6);,',...
       'i2=uint8(round(filter2(h,i)));,',...
       'imshow(i2)']);
b2=uicontrol('parent',h0,...
   'units','points',...
   'tag','b2',...
   'style','pushbutton',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'string','sobel过滤',...
   'position',[150 120 50 20],...
   'callback',[...
       'cla,',...
       'i=imread(''blood1.tif'');,',...
       'h=fspecial(''sobel'');,',...
       'i2=filter2(h,i);,',...
       'imshow(i2,[])']);
b1=uicontrol('parent',h0,...
   'units','points',...
   'tag','b1',...
   'style','pushbutton',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'string','关闭',...
   'position',[85 60 80 30],...
   'callback','close'); 


实例71:radon函数变换
h0=figure('toolbar','none',...
   'position',[198 56 350 468],...
   'name','实例71');
h1=axes('parent',h0,...
   'position',[0.3 0.45 0.5 0.5],...
   'visible','off');
p=phantom(256);
imshow(p)
b1=uicontrol('parent',h0,...
   'units','points',...
   'tag','b1',...
   'style','pushbutton',...
   'string','变换一',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'position',[30 100 50 20],...
   'callback',[...
       'cla,',...
       'k=1;,',...
       'theta1=0:10:170;,',...
       'r1=radon(p,theta1);,',...
       'imagesc(r1),',...
       'colormap(hot),',...
       'colorbar']);
b2=uicontrol('parent',h0,...
   'units','points',...
   'tag','b2',...
   'style','pushbutton',...
   'string','变换二',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'position',[100 100 50 20],...
   'callback',[...
       'cla,',...
       'k=2;,',...
       'theta2=0:5:175;,',...
       'r2=radon(p,theta2);,',...
       'imagesc(r2),',...
       'colormap(hot),',...
       'colorbar']);
b3=uicontrol('parent',h0,...
   'units','points',...
   'tag','b3',...
   'style','pushbutton',...
   'string','变换三',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'position',[170 100 50 20],...
   'callback',[...
       'cla,',...
       'k=3;,',...
       'theta3=0:2:178;,',...
       'r3=radon(p,theta3);,',...
       'imagesc(r3),',...
       'colormap(hot),',...
       'colorbar']);
b4=uicontrol('parent',h0,...
   'units','points',...
   'tag','b4',...
   'style','pushbutton',...
   'string','原始图像',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'position',[50 50 70 30],...
   'callback',[...
       'cla,',...
       'if k==1,',...
       'i1=iradon(r1,10);,',...
       'imshow(i1),',...
       'end,',...
       'if k==2,',...
       'i2=iradon(r2,5);,',...
       'imshow(i2),',...
       'end,',...
       'if k==3,',...
       'i3=iradon(r3,2);,',...
       'imshow(i3),',...
       'end']);        
b5=uicontrol('parent',h0,...
   'units','points',...
   'tag','b5',...
   'style','pushbutton',...
   'string','关闭',...
   'backgroundcolor',[0.75 0.75 0.75],...
   'position',[150 50 70 30],...
   'callback','close');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -