test.m
上传用户:trade789
上传日期:2018-05-10
资源大小:603k
文件大小:2k
源码类别:

2D图形编程

开发平台:

Matlab

  1. %example file for feature detector
  2. %close all
  3. testpat=0; %set to zero to use current contents of img variable
  4. if testpat==1
  5.     
  6.     img=zeros(400,400);
  7.     img(150:200,100:150)=200;
  8.     img(100:110,100:110)=200;
  9.     img(100:118,140:158)=200;
  10.     img(100:120,185:205)=200;
  11.     img(100:125,235:260)=200;
  12.     img(100:130,290:320)=200;
  13.     img(150:185,40:75)=200;
  14.     img(190:290,190:290)=200;
  15.     img(300:302,100:102)=200;
  16.         
  17.     img=filter_gaussian(img,7,sqrt(2));
  18.     img=img+randn(400,400)*5;
  19.     
  20. elseif testpat==2
  21.     
  22.     img=zeros(400,400);
  23.     img(200:400,190:210) = 200;
  24.     img=filter_gaussian(img,7,sqrt(2));
  25.     img=img+randn(400,400)*5;
  26.     
  27. elseif testpat==3
  28.     
  29.     img=zeros(400,400);
  30.     img(1:400,190:210) = 200;
  31.     img=filter_gaussian(img,7,sqrt(2));
  32.     img=img+randn(400,400)*5;
  33.     
  34. elseif testpat==4
  35.     
  36.     img=zeros(400,400);
  37.     img(200:400,190:210) = 200;
  38.     img(200:220,200:400) = 200;
  39.     img=filter_gaussian(img,7,sqrt(2));
  40.     img=img+randn(400,400)*0;
  41.     
  42. elseif testpat==5
  43.     
  44.     img=zeros(400,400);
  45.     img(200:400,200:210) = 200;
  46.     img(200:210,1:400) = 200;
  47.     img=filter_gaussian(img,7,sqrt(2));
  48.     img=img+randn(400,400)*5;
  49.     
  50. elseif testpat==6
  51.     
  52.     img=zeros(400,400);
  53.     img(1:400,200:210) = 200;
  54.     img(200:210,1:400) = 200;
  55.     img=filter_gaussian(img,7,sqrt(2));
  56.     img=img+randn(400,400)*5;
  57.     img=-img;
  58. end    
  59. close all
  60. if size(img,3)>1 
  61.     img = rgb2gray(img);
  62. end
  63. %imagesc(img);
  64. threshold=3;        %Threshold value for rejecting maxima/minima
  65. disp_flag = 0;      %change to a zero for a combined view of all scales
  66. img_flag = 1;       %change to a zero to see features plotted on original image
  67. radius = 4;
  68. radius2 = 4;
  69. radius3 = 4;
  70. min_sep = .04;
  71. edgeratio = 5;
  72. scl = 1.5;
  73. %img = imread(file_name);
  74. %[pyr,imp] = build_pyramid(img,12,scl);
  75. %pts = find_features(pyr,img,scl, threshold,radius,radius2,min_sep,edgeratio,disp_flag,img_flag);
  76. %[features] = getpts(img,pyr,scl,imp,pts,6,radius3,min_sep,edgeratio);
  77. [features,pyr,imp,keys] = detect_features(img,scl,disp_flag,threshold,radius,radius2,radius3, min_sep,edgeratio);
  78. showfeatures(features,img);
  79. axis equal;
  80. %enjoy...