使用边缘跟踪,边缘提取,各种算法的程序。

  • 虫虫123456
    了解作者
  • matlab
    开发工具
  • 38.1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-06-27 23:22
    上传日期
使用边缘跟踪,边缘提取,各种算法的程序。
W7PvjfXl5lO3Vw.rar
  • fast_distance_map_caculate
  • IterSelThres.m
    2.4KB
  • IsRgPt.m
    434B
  • EdgeDetectionUseThres.m
    3KB
  • EdgeDetection.m
    5.9KB
  • ParallelComputeDisMap.m
    3KB
  • main.m
    615B
  • ScanLineSeedFill.m
    7.5KB
  • Brain1_dst_256256.bmp
    65.1KB
  • DirToIndex8.m
    551B
  • pushArray.m
    91B
  • CacuMedianGray.m
    309B
  • DirToIndex4.m
    371B
  • AngleToDirection.m
    470B
  • popArray.m
    370B
  • www.pudn.com.txt
    218B
内容介绍
function [edgePt allSeqEdgePt]= ScanLineSeedFill(srcImg) PI = 3.1415927; [hei,wid]=size(srcImg); dImage = double(srcImg); DX = zeros(hei,wid); DY = zeros(hei,wid); DA = zeros(hei,wid); % 梯度幅值矩阵 for i=2:hei for j=2:wid DX(i,j) = dImage(i,j)-dImage(i,j-1); DY(i,j) = dImage(i,j)-dImage(i-1,j); DA(i,j) = sqrt(DX(i,j)*DX(i,j)+DY(i,j)*DY(i,j)); end end % get pos of all the input startPt hold on; allstartPts = []; but = 1; iterTime = 0; while but == 1 [xi,yi,but] = ginput(1); plot(xi,yi,'r.') iterTime = iterTime+1; allstartPts = [allstartPts; [xi yi]]; end allSeqEdgePt = []; % iteration for handle each startPt and save the edge pt info in a % total array DGate = 30; % set the thres of the gradient for ii = 1:iterTime bFindFirst = 0; rgGGate = 0; startPt = allstartPts(ii,:); for i=startPt(2)+1:hei for j=startPt(1)+1:wid if DA(i,j)>DGate % if the gradient up the threshold % cacu the average gray value of pixels in 3*3 adjacent % region as the threshold of the edge gray value rgGGate = CacuMedianGray(dImage,i,j,hei,wid); bFindFirst = 1; break; end end if bFindFirst == 1 break; end end newImage = zeros(hei,wid); % create the two-value image matrix for i=1:hei for j=1:wid if dImage(i,j)>rgGGate newImage(i,j)=1; else newImage(i,j)=0; end end end % median filter the two-value image ,to eliminate the noisy and small % islands newImage = medfilt2(newImage); % figure,imshow(newImage); color = 2;% the value mark the region rgVal = newImage(startPt(2)+1,startPt(1)+1); seed = startPt+1; seedNum = 1; while(seedNum~=0) [curx cury seed] = popArray(seed); if cury<2||cury>hei-1 break; end newImage(cury,curx) = color; x0 = curx+1; while x0<=wid&&newImage(cury,x0)==rgVal newImage(cury,x0) = color; x0 = x0+1; end xr = x0 - 1; x0 = curx - 1; while x0>=1&&newImage(cury,x0)==rgVal newImage(cury,x0) = color; x0 = x0-1; end xl = x0+1; % the lower scanline x0 = xl; cury = cury+1; while(x0<=xr) flag = 0; while (newImage(cury,x0)==rgVal)&&(newImage(cury,x0)~=color)&&(x0<xr) if flag==0 flag = 1; end x0 = x0+1; end if flag==1 if x0==xr&&newImage(cury,x0)==rgVal&&newImage(cury,x0)~=color seed = pushArray(seed,x0,cury); else seed = pushArray(seed,x0-1,cury); end flag = 0; end xnextspan = x0; while x0<=xr&&newImage(cury,x0)~=rgVal||newImage(cury,x0)==color x0 = x0+1; end if xnextspan==x0 x0 = x0+1; end end % the upper scanline x0 = xl; cury = cury-2; while(x0<=xr) flag = 0; while (newImage(cury,x0)==rgVal)&&(newImage(cury,x0)~=color)&&(x0<xr) if flag==0 flag = 1; end x0 = x0+1; end if flag==1 if x0==xr&&newImage(cury,x0)==rgVal&&newImage(cury,x0)~=color seed = pushArray(seed,x0,cury); else seed = pushArray(seed,x0-1,cury); end flag = 0; end xnextspan = x0; while x0<=xr&&newImage(cury,x0)~=rgVal||newImage(cury,x0)==color x0 = x0+1; end if xnextspan==x0 x0 = x0+1; end end % update the length of seed array, if it is zero, exit the while [seedNum,col] = size(seed); end edgeImg = zeros(hei,wid); edgePt = []; for i=1:hei for j=1:wid bflag = IsRgPt(j-1,i-1,newImage,1); if bflag == 0 && newImage(i,j)==2 edgePt = [edgePt; [j-1 i-1]]; edgeImg(i,j) = 1; end end end % maxVal = max(max(newImage)); % sNewImage = newImage./maxVal; % figure; % imshow(sNewImage); % axis([0 wid-1 0 hei-1]); % axis ij; % hold on; % plot(edgePt(:,1), edgePt(:,2), 'g.'); % hold off; for i = 1:hei for j = 1:wid if edgeImg(i,j)~=1 continue; end firstPX = j-1; firstPY = i-1; end end % array for store the edge pixels seqEdgePt = [firstPX firstPY]; P0 = seqEdgePt; edgeImg(P0(2)+1,P0(1)+1) = 2; curPt = zeros(1,2); prePt = zeros(1,2); dir = 0; curPt = P0; prePt = P0; bSetP1 = 0; P1 = zeros(1,2); % find P1 and first step dir while(1) [deltaI,deltaJ] = DirToIndex8(dir); tmpx = curPt(1)+deltaJ; tmpy = curPt(2)+deltaI; if edgeImg(tmpy+1,tmpx+1)==1 P1 = [tmpx tmpy]; curPt = P1; seqEdgePt = [seqEdgePt;P1]; edgeImg(curPt(2)+1,curPt(1)+1) = 2; break; end dir = mod(dir+7,8); end times = 0; dirType = 0; while (1) [deltaI,deltaJ] = DirToIndex8(dir); tmpx = curPt(1)+deltaJ; tmpy = curPt(2)+deltaI; flag = IsRgPt(tmpx,tmpy,edgeImg,0); if edgeImg(tmpy+1,tmpx+1)==1&&flag==0 prePt = curPt; curPt = [tmpx tmpy]; seqEdgePt = [seqEdgePt;curPt]; edgeImg(curPt(2)+1,curPt(1)+1) = 2; dirType = 0; else dir = mod(dir+7,8); dirType = dirType+1; end if dirType>=8 break; end if tmpx==P1(1)&&tmpy==P1(2)&&prePt(1)==P0(1)&&prePt(2)==P0(2) break; end end % store seqEdgePt generated in every iteration allSeqEdgePt = [allSeqEdgePt; seqEdgePt]; end % end of for ii=1: hold off; figure; imshow(srcImg); hold on; plot(allSeqEdgePt(:,1)+1, allSeqEdgePt(:,2)+1, 'm.') hold off;
评论
    相关推荐
    • 内边界边缘轮廓跟踪算法.rar
      可以识别图像的边缘,提取图像边缘轮廓,且程序简单易懂,方便初学者学习。
    • 跟踪中的自动检测与跟踪程序
      目标检测,与目标跟踪。输入视频后,对视频每一帧进行自动检测出目标,而后进行跟踪
    • 建模图像处理目标跟踪程序.rar
      数学建模搜集的资料 各种跟踪算法 视频处理 图像处理 动态捕捉 在参加建模比赛时候搜集的大量的代码 想深究的可以一点点来
    • 粒子PHD程序
      可直接执行的粒子PHD滤波算法代码,适用于多目标跟踪
    • 利用OpenCV的视频跟踪程序
      OpenC实现的meanshift程序,其中包含边缘检测,霍夫变换,meanshift,可以执行,大家试试吧
    • 多特征融合目标跟踪程序
      本程序是多特征融合的目标跟踪程序,基于粒子滤波框架,融合边缘和TED特征的跟踪算法,可以运行程序,适合用于对多特征融合的学习
    • RfTrack:射频跟踪
      射频跟踪 开发 Android 程序 Rftrack 的目的是允许对 TVWS 频率(电视空白空间)进行低成本监控,这些频率在各个国家/地区通过电视传输到数字地面后部分空置。 例如,从技术上讲,这些频率可用于在农村、边缘和偏远...
    • myTrack:一个小型 GPS 跟踪应用程序
      myTrack 旨在跟踪您去过的地方,并按地点和时间组织您生活中的重要时刻。 myTrack 适用于 Android 4.0 及更高版本。 用 要使用 myTrack,只需将 APK 文件安装到您的设备上并启动应用程序。 要记录您的位置,请按...
    • 8邻域算法边缘跟踪
      图像边缘获取,自己实现的基于matlab的8邻域算法,获取图像的边缘。需要手动设置阈值对图像进行二值化。包涵实现程序和测试程序
    • libiconv-1.1.tar.gz
      字符集转换程序