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

📄 curve_linear_heat_flow.m

📁 所有程序的运行和编译环境为:Visual C++ 6.0和MATLAB 6.5 service pack1(一般情况下MATLAB 6.5即可)。 如果您有和技术相关的问题或者发现本书实例有错误之处
💻 M
字号:
%%% This program evolves a closed curve according linear heat flow by using
%%% Fourier transform method.

clear all;
close all;
clc;

Img = imread('Africa.bmp');
figure(1);imshow(Img);
[nrow,ncol]=size(Img);
sigama=3;                      % the parameter of gaussian kernel
x=-255:0.5:256;
g=exp(-x.^2/(2*sigama^2));

boundary_Img=zeros([nrow,ncol]);
B = bwboundaries(Img);         % Get the boundary of a binary image as a closed curve
boundary=B{2};
L=length(boundary);
for ii=1:L
    xx(ii)=boundary(ii,2);                % store the positions of the curve points
    yy(ii)=boundary(ii,1);
    boundary_Img(yy(ii),xx(ii))=1;        % for display only
end
figure(2);imshow(boundary_Img);

FTg=fft(g,L); m=max(abs(FTg)); FTg=FTg/m; % normalize FT{g}
nn=1;
for n=1:2048
  for ii=1:L
    z(ii)=xx(ii)+yy(ii)*j;               % This is the so_called Fourier Descriptor for the curve
  end
  FTz=fft(z);
  gz=FTg.*FTz;
  zz=ifft(gz);                           
  xx=real(zz);      yy=imag(zz);         % This is curve after evolving for n times. 
  if mod(n,2^nn)==0
     for ii=1:L
        boundary_Img(floor(yy(ii)),floor(xx(ii)))=1;
     end
     figure(3);imshow(boundary_Img);     % Display current curve.
     nn=nn+1;
  end
end

⌨️ 快捷键说明

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