资源简介
代码实现PCNN定位噪声点,并且结合形态学滤除图像中的椒盐噪声
代码片段和文件信息
function [pointsedges] = lattice(XYconnect)
%Function [pointsedges]=lattice(XYconnect) generates a 2D
%“4-connected“ Cartesian lattice with dimensions X and Y.
%
%Inputs: X/Y - The dimensions of the lattice (i.e. the number of
% nodes will equal X*Y)
% connect - Optional iInteger indicating the connectivity of
% the lattice
% 0 - 4-connected (Default)
% 1 - 8-connected
% K>1 - Radially connected with radius = K
%
%Outputs: points - Nx2 lattice nodes
% edges - Mx2 lattice edges
%
%
%6/5/03 - Leo Grady
% Copyright (C) 2002 2003 Leo Grady
% Computer Vision and Computational Neuroscience Lab
% Department of Cognitive and Neural Systems
% Boston University
% Boston MA 02215
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not write to the Free Software
% Foundation Inc. 59 Temple Place - Suite 330 Boston MA 02111-1307 USA.
%
% Date - $Id: lattice.mv 1.2 2003/08/21 17:29:29 lgrady Exp $
%========================================================================%
%Check for single point
if X*Y==1
points=[1;1];
edges=[];
return
end
%Read connect argument
if nargin < 3
connect=0;
end
if connect < 2
%Generate points
rangex=0:(X-1);
rangey=0:(Y-1);
[x y]=meshgrid(rangeyrangex);
points=[x(:)y(:)];
N=X*Y;
%Connect points
edges=[[1:N]‘[(1:N)+1]‘];
edges=[[edges(:1);[1:N]‘][edges(:2);[1:N]‘+X]];
if connect == 1 %8-connected
border=1:N;
border1=find(mod(borderX)-1)‘;
border2=find(mod(borderX))‘;
edges=[edges;[border1border1+X-1;border2border2+X+1]];
end
excluded=find((edges(:1)>N)|(edges(:1)<1)|(edges(:2)>N)| ...
(edges(:2)<1));
edges([excluded;[X:X:((Y-1)*X)]‘]:)=[];
else %Radial connectivity
%Generate points
X=X+2*connect;
Y=Y+2*connect;
rangex=0:(X-1);
rangey=0:(Y-1);
[x y]=meshgrid(rangeyrangex);
points=[x(:)y(:)];
N=X*Y;
%Generate adjacency matrix
distances=(points(:1)-floor(Y/2)).^2 + (points(:2)-floor(X/2)).^2;
inside=find(distances<=(connect^2));
adjVec=sparse(1inside11N);
midPoint=find(points(:1)==floor(Y/2) & points(:2)==floor(X/2));
%Adjust vector to be centered around diagonal
adjVec=adjVec([midPoint:N1:(midPoint-1)]);
adjVec(1)=0; %Remove self-connection
W=circulan
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-04-25 16:57 test_pcnn\
文件 49770 2015-04-24 10:34 test_pcnn\close.bmp
文件 49770 2015-04-25 16:54 test_pcnn\close1.bmp
文件 49770 2015-04-25 16:54 test_pcnn\close2.bmp
文件 3298 2003-08-22 04:43 test_pcnn\lattice.m
文件 144058 2015-04-23 19:53 test_pcnn\lena.bmp
文件 49770 2015-04-24 10:35 test_pcnn\med.bmp
文件 49770 2015-04-25 16:55 test_pcnn\med1.bmp
文件 49770 2015-04-25 16:55 test_pcnn\med2.bmp
文件 49770 2015-04-24 10:34 test_pcnn\moise.bmp
文件 49770 2015-04-24 10:34 test_pcnn\open.bmp
文件 49770 2015-04-25 16:54 test_pcnn\open1.bmp
文件 49770 2015-04-25 16:54 test_pcnn\open2.bmp
文件 49770 2015-04-24 10:35 test_pcnn\original.bmp
文件 49770 2015-04-24 10:33 test_pcnn\pcnn_close.bmp
文件 49770 2015-04-24 10:34 test_pcnn\pcnn_med.bmp
文件 49770 2015-04-24 10:33 test_pcnn\pcnn_open.bmp
文件 3051 2015-04-25 16:54 test_pcnn\pcnn_smooth.m
文件 3148854 2015-04-24 10:38 test_pcnn\result.bmp
文件 809 2015-04-24 10:27 test_pcnn\test_pcnn.m
文件 855004 2015-04-25 16:56 test_pcnn\test_pcnn.zip
文件 12174 2015-04-25 16:57 test_pcnn\test_pcnn1.zip
评论
共有 条评论