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

📄 publscript01.html

📁 用matlab实现图像融合
💻 HTML
字号:
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">   <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">         <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document.      -->      <title>publscript01</title>      <meta name="generator" content="MATLAB 7.0">      <meta name="date" content="2007-01-14">      <meta name="m-file" content="publscript01"><style>body {  background-color: white;  margin:10px;}h1 {  color: #990000;   font-size: x-large;}h2 {  color: #990000;  font-size: medium;}p.footer {  text-align: right;  font-size: xx-small;  font-weight: lighter;  font-style: italic;  color: gray;}pre.codeinput {  margin-left: 30px;}span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.showbuttons {  margin-left: 30px;  border: solid black 2px;  padding: 4px;  background: #EBEFF3;}pre.codeoutput {  color: gray;  font-style: italic;}pre.error {  color: red;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows.  On Gecko-based browsers, the shrink-to-fit doesn't work. */ p,h1,h2,div {  /* for MATLAB's browser */  width: 600px;  /* for Mozilla, but the "width" tag overrides it anyway */  max-width: 600px;  /* for IE */  width:expression(document.body.clientWidth > 620 ? "600px": "auto" );}    </style></head>   <body>      <h2>Contents</h2>      <div>         <ul>            <li><a href="#1">Path Tracing</a></li>            <li><a href="#2">Displaying results</a></li>            <li><a href="#3">Series detection of spots</a></li>         </ul>      </div>      <h2>Path Tracing<a name="1"></a></h2><pre class="codeinput"><span class="comment">%        An application of path tracing is intended for</span><span class="comment">%detecting an external border of spot (simply connected</span><span class="comment">%black  pixels set).</span><span class="comment">%        An output includes:</span><span class="comment">% - two arrays with spot border pixels,</span><span class="comment">% - coordinates of points of optimal location (centers</span><span class="comment">%   of mass) for a spot and for a spot border,</span><span class="comment">% - perimeter (as length of line connected  centers of</span><span class="comment">%   border pixels and as count of external border pixel</span><span class="comment">%   edges),</span><span class="comment">% - count of  pixels of a spot and its border,</span><span class="comment">% - coordinates of the most remote pixels,</span><span class="comment">% - a distance between them,</span><span class="comment">% - coordinates of vertices of minimal  rectangle with</span><span class="comment">%   spot inside it.</span><span class="comment">%        Output data might  be calculated from both an</span><span class="comment">%image and a numeric matrix.</span><span class="comment">%The author - Eduard Polityko, PHD.</span><span class="comment">%E-mail     - Edpolit@gmail.com</span><span class="comment">%Edition 28-Dec-2006</span>alfa=<span class="string">'examp03.bmp'</span>;[a b xc]=digis1(alfa);</pre><h2>Displaying results<a name="2"></a></h2><pre class="codeinput">figure;image(imread(alfa)');colormap([0 0 0;1 1 1]);title(<span class="string">'Spot'</span>);axis <span class="string">xy</span>;grid <span class="string">on</span>format <span class="string">short</span> <span class="string">g</span>rp=repmat(<span class="string">'_'</span>,1,26);disp(<span class="string">'     Coordinates'</span>)disp(rp)disp(<span class="string">'Center of mass of contour'</span>)disp(xc(1:2));disp(<span class="string">'Center of mass of spot   '</span>);disp([xc(3:4)]);disp([<span class="string">'Rectangle to crop '</span>;<span class="keyword">...</span><span class="string">'(ends of diagonal)'</span>])disp(xc(10:13))disp(<span class="string">'The most remote points'</span>)disp([a(xc(7)),b(xc(7)),a(xc(8)),b(xc(8))])disp(rp)disp(<span class="string">'Maximal distance between points'</span>)disp(xc(9));disp(<span class="string">'Count of black pixels:'</span>)disp([{<span class="string">'Border'</span>},{xc(5)};{<span class="string">'Spot'</span>},{xc(6)}])disp(<span class="string">'         Perimeter:'</span>)disp(<span class="string">'  count of external edges'</span>)disp(<span class="string">'      of border pixels '</span>)disp(xc(14))disp(<span class="string">'  length of line connected'</span>)disp(<span class="string">'  centers of border pixels'</span>)disp(xc(15))figure;zx=plot(a,b,<span class="string">'-'</span>,xc(1),xc(2),<span class="string">'+'</span>,<span class="keyword">...</span>  xc(3),xc(4),<span class="string">'*'</span>,[xc(10) xc(12)],[xc(11) xc(13)],<span class="string">'o'</span>,<span class="keyword">...</span>  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],<span class="string">'p'</span>);grid <span class="string">on</span>set(zx,<span class="string">'linewidth'</span>,1)legend(<span class="string">'spot border'</span>,[<span class="string">'center of '</span>; <span class="string">'curve mass'</span>],<span class="keyword">...</span>  [<span class="string">'center of'</span>; <span class="string">'spot mass'</span>],[<span class="string">'rectangle vertices'</span>],<span class="keyword">...</span><span class="comment">,</span>  [<span class="string">'the most     '</span>;<span class="string">'remote points'</span>],<span class="string">'location'</span>, <span class="string">'best'</span>);title([<span class="string">'Measurement'</span>]);</pre><pre class="codeoutput">     Coordinates__________________________Center of mass of contour       308.43       232.64Center of mass of spot          200.95       180.43Rectangle to crop (ends of diagonal)    10     1   430   558The most remote points    36    47   407   553__________________________Maximal distance between points       627.44Count of black pixels:    'Border'    [ 3354]    'Spot'      [61786]         Perimeter:  count of external edges      of border pixels         3560  length of line connected  centers of border pixels       3437.7</pre><img vspace="5" hspace="5" src="publscript01_01.png"> <img vspace="5" hspace="5" src="publscript01_02.png"> <h2>Series detection of spots<a name="3"></a></h2><pre class="codeinput">figuresubplot(2,3,1)J=imread(<span class="string">'examp05.bmp'</span>);image(J');axis <span class="string">xy</span>;title(<span class="string">'Spots'</span>)colormap([0 0 0;1 1 1]);subplot(2,3,2)[a b xc]=digis1(J);plot(a,b,<span class="string">'-'</span>,xc(1),xc(2),<span class="string">'+'</span>,<span class="keyword">...</span>  xc(3),xc(4),<span class="string">'*'</span>,[xc(10) xc(12)],[xc(11) xc(13)],<span class="string">'o'</span>,<span class="keyword">...</span>  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],<span class="string">'p'</span>);<span class="keyword">for</span> rr=1:4subplot(2,3,2+rr)J1=J;<span class="keyword">for</span> i=1:length(a); ii=0; <span class="keyword">while</span> ~J(a(i),b(i)+ii)   J(a(i),b(i)+ii)=1;   ii=ii+1; <span class="keyword">end</span><span class="keyword">end</span>[a b xc]=digis1(J);plot(a,b,<span class="string">'-'</span>,xc(1),xc(2),<span class="string">'+'</span>,<span class="keyword">...</span>  xc(3),xc(4),<span class="string">'*'</span>,[xc(10) xc(12)],[xc(11) xc(13)],<span class="string">'o'</span>,<span class="keyword">...</span>  [a(xc(7)),a(xc(8))],[b(xc(7)),b(xc(8))],<span class="string">'p'</span>);<span class="keyword">end</span></pre><img vspace="5" hspace="5" src="publscript01_03.png"> <p class="footer"><br>         Published with MATLAB&reg; 7.0<br></p>      <!--##### SOURCE BEGIN #####%% 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##### SOURCE END #####-->   </body></html>

⌨️ 快捷键说明

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