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

📄 imextrac.m

📁 小波变换工具箱
💻 M
字号:
function [Image2,NbDots]=imextrac(Image,trace);
% imextrac(Image) extract and isolate dots in a binary image
%
% example:
% Image=[1 0 0 0 0 0 1 0 0 0 1 0 ;...
%        1 1 0 0 0 1 1 0 0 0 1 1 ;...
%        1 0 0 0 1 0 1 0 0 0 0 1 ;...
%        0 0 0 0 1 1 1 0 0 0 0 0 ;...
%        0 0 0 0 0 0 0 0 0 0 0 0 ];
% image2=imextrac(Image)
%
%	See also tfrsurf.

% 	F. Auger, oct 1999
%	Copyright (c) CNRS - France 1999. 
%
%	------------------- CONFIDENTIAL PROGRAM -------------------- 
%	This program can not be used without the authorization of its
%	author(s). For any comment or bug report, please send e-mail to 
%	f.auger@ieee.org 
if nargin==1, trace=0; end;

Image2=Image;
[Nbrow,Nbcol]=size(Image2);

NbDots=1 ; 
if trace==1, fprintf('extracting dots in the image.\n'); end;

if (Image2(1,1)==1),
 NbDots=NbDots+1; Image2(1,1)=NbDots;
end;

for i=2:Nbcol,
 if (Image2(1,i)==1),
  if (Image2(1,i-1)>1),
   Image2(1,i)=Image2(1,i-1);
  else
   NbDots=NbDots+1; Image2(1,i)=NbDots;
  end;
 end; 
end;
if trace==1, disprog(1,Nbrow,10); end;

for j=1:Nbrow,
 if (Image2(j,1)==1),
  if (Image2(j-1,1)>1),
   Image2(j,1)=Image2(j-1,1);
  else
   NbDots=NbDots+1; Image2(j,1)=NbDots;
  end;
 end;

 for i=2:Nbcol,
  if (Image2(j,i)==1),
   if (Image2(j-1,i)==0)&(Image2(j,i-1)==0),
    NbDots=NbDots+1; Image2(j,i)=NbDots;
   elseif (Image2(j-1,i)==0)&(Image2(j,i-1)>1),
    Image2(j,i)=Image2(j,i-1);
   elseif (Image2(j-1,i)>1)&(Image2(j,i-1)==0),
    Image2(j,i)=Image2(j-1,i);
   elseif (Image2(j-1,i)>1)&(Image2(j,i-1)>1),
    MinDot=min(Image2(j-1,i),Image2(j,i-1));
    MaxDot=max(Image2(j-1,i),Image2(j,i-1));
    Indices=find(Image2==MaxDot); Image2(Indices)=MinDot;
    Image2(j,i)=MinDot;
   else error('should never happen');
   end;
  end; 
 end;
 if trace==1, disprog(j,Nbrow,10); end;
end;

⌨️ 快捷键说明

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