• 大小: 2KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-04-21
  • 语言: Matlab
  • 标签: 链码直线  

资源简介

链码直线检测,采用求取图像边界,然后边界跟踪,判别直线

资源截图

代码片段和文件信息

clcclear;close all;
tic;
%I= rgb2gray(imread(‘000.bmp‘));%jaynes-thesis
%H=fspecial(‘average‘3);
%Z=imfilter(RGBH);
%I=Z;  % 图片用的是灰度图像,% I=histeq(I256);
%BW=edge(I‘canny‘);
% figure;imshow(I);title(‘原图‘);
% figureimshow(Z);title(‘均值滤波‘);
% figure;imshow(BW);title(‘边缘检测图像‘);axis on
%BW = bwareaopen(BW608);
%%%%%%%%%%%%%%%%%%%%%%%实际灰度图像%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% clear;
% close all;
 RGB=imread(‘000.bmp‘);
 ratio1=0.5;
 I=rgb2gray(imresize(RGBratio1));
% % I0=imresize(I0[256256]‘bicubic‘);
% % figure;
% % imshow(I0);
% % title(‘original image‘);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 类型转换 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% info=imfinfo(‘000.bmp‘);
%  switch info.ColorType
%     case ‘truecolor‘
%         I1=rgb2gray(I0);
%     case ‘indexed‘    
%         I1=ind2gray(I0);
%     case ‘grayscale‘
%         I1=I0;
%  end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 边缘提取 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BW=edge(I‘canny‘);
% figure;
% imshow(BW);
% title(‘edge image‘);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  去掉一些交叉点
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BW1=BW;
w=2;          % window size=2*w+1
for i=1+w:size(BW11)-w
    for j=1+w:size(BW12)-w
    temp=BW1(i-w:i+wj-w:j+w);    
     tt=sum(sum(temp));  
     if tt>5;
         BW1(ij)=0;                %  去掉交叉点
     end    
    end
end
% figure;
% imshow(BW1[]);
% title(‘delete cross point‘);
%                selected interest curve segment去掉小线段去掉了长度小于15的线段
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I1=BW1;
L = bwlabel(I18);
I2=zeros(size(I1));
for i=1:max(max(L))
    [rc] = find(L == i);   
    if length(r)>=25      % delete small line segment
        for j=1:length(r)
            I2(r(j1)c(j1))=1;
        end
        
    end
end
% figure;
% imshow(I2[]);
B=boundaries(I28‘cw‘);
% figure;imshow(BW);title(‘8联通领域图像标记‘);axis on;hold on;
% %figure
% for i=1:size(B1)
%     i
%     a=rand;
%     b=rand;
%     c=rand;
%     for j=1:size(B{i}1)
%         plot(B{i}(j2)B{i}(j1)‘color‘[abc]);
%         hold on;
%     end
%     text(B{i}(12)B{i}(11)num2str(i)‘color‘[111]);
% end
Code=cell(size(B1)1);
for i=1:size(B1)
    Code{i}=creatcodel(B{i});
end
SubCode=cell(size(B1)1);
for i=1:size(B1)
    SubCode{i}=creatsubcode(Code{i});
end
%%%%%%%差分链码统计
% FreS=cell(size(SubCode2)1);
% for i=1:size(SubCode2) 
%     Frequence=[00000000];
%     for j=1:size(SubCode{i}2)         %对SubCode中各成分数目的统计      
%         switch(SubCode{i}(j))
%             case {0}
%                 Frequence(1)=Frequence(1)+1;
%             case {1}
%                 Frequence(2)=Frequence(2)+1;
%        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4734  2012-09-13 19:53  链码检测直线.m

评论

共有 条评论

相关资源