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

📄 publscript01.m

📁 用matlab实现图像融合
💻 M
字号:
%% Path Tracing

%        An application of path tracing is intended for 
%detecting an external border of spot (simply connected 
%black  pixels set).
%        An output includes:
% - two arrays with spot border pixels,
% - coordinates of points of optimal location (centers
%   of mass) for a spot and for a spot border,
% - perimeter (as length of line connected  centers of 
%   border pixels and as count of external border pixel
%   edges), 
% - count of  pixels of a spot and its border,
% - coordinates of the most remote pixels,
% - a distance between them, 
% - coordinates of vertices of minimal  rectangle with
%   spot inside it.
%        Output data might  be calculated from both an 
%image and a numeric matrix.
%The author - Eduard Polityko, PHD.
%E-mail     - Edpolit@gmail.com
%Edition 28-Dec-2006
alfa='examp03.bmp';
[a b xc]=digis1(alfa);

%% Displaying results

figure;
image(imread(alfa)');colormap([0 0 0;1 1 1]);
title('Spot');axis xy;grid on
format short g
rp=repmat('_',1,26);
disp('     Coordinates')
disp(rp)
disp('Center of mass of contour')
disp(xc(1:2));
disp('Center of mass of spot   ');
disp([xc(3:4)]);
disp(['Rectangle to crop ';...
'(ends of diagonal)'])
disp(xc(10:13))
disp('The most remote points')
disp([a(xc(7)),b(xc(7)),a(xc(8)),b(xc(8))])
disp(rp)
disp('Maximal distance between points')
disp(xc(9));
disp('Count of black pixels:')
disp([{'Border'},{xc(5)};{'Spot'},{xc(6)}])
disp('         Perimeter:')
disp('  count of external edges')
disp('      of border pixels ')
disp(xc(14))
disp('  length of line connected') 
disp('  centers of border pixels')
disp(xc(15))
figure;
zx=plot(a,b,'-',xc(1),xc(2),'+',...
  xc(3),xc(4),'*',[xc(10) xc(12)],[xc(11) xc(13)],'o',...
  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],'p');grid on
set(zx,'linewidth',1)
legend('spot border',['center of '; 'curve mass'],...
  ['center of'; 'spot mass'],['rectangle vertices'],...,
  ['the most     ';'remote points'],'location', 'best');
title(['Measurement']);

%% Series detection of spots

figure
subplot(2,3,1)
J=imread('examp05.bmp');
image(J');axis xy;title('Spots')
colormap([0 0 0;1 1 1]);
subplot(2,3,2)
[a b xc]=digis1(J);
plot(a,b,'-',xc(1),xc(2),'+',...
  xc(3),xc(4),'*',[xc(10) xc(12)],[xc(11) xc(13)],'o',...
  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],'p');
for rr=1:4
subplot(2,3,2+rr)
J1=J;
for i=1:length(a);
 ii=0;
 while ~J(a(i),b(i)+ii)
   J(a(i),b(i)+ii)=1;
   ii=ii+1;
 end
end
[a b xc]=digis1(J);
plot(a,b,'-',xc(1),xc(2),'+',...
  xc(3),xc(4),'*',[xc(10) xc(12)],[xc(11) xc(13)],'o',...
  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],'p');
end

⌨️ 快捷键说明

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