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

2D图形编程

开发平台:

Matlab

  1. %/////////////////////////////////////////////////////////////////////////////////////////////
  2. %
  3. % showfeatures - visualize features generated by detect_features
  4. % Usage:  showfeatures(features,img)
  5. %
  6. % Parameters:  
  7. %            
  8. %            img :      original image
  9. %            features:  matrix generated by detect_features
  10. %
  11. % Returns:   nothing, generates figure
  12. %
  13. % Author: 
  14. % Scott Ettinger
  15. % scott.m.ettinger@intel.com
  16. %
  17. % May 2002
  18. %/////////////////////////////////////////////////////////////////////////////////////////////
  19. function [] = showfeatures(features,img,num_flag)
  20. if ~exist('num_flag')
  21.     num_flag = 0;
  22. end
  23. figure(gcf);
  24. imagesc(img)
  25. hold on
  26. colormap gray
  27. for i=1:size(features,1)
  28.     x = features(i,1);
  29.     y = features(i,2);
  30.     sz = features(i,4);
  31.     
  32.     if x>size(img,2)
  33.         x
  34.     end
  35.     
  36.     if features(i,5) > 0        %check edge flag
  37.         
  38.         if num_flag ~= 1
  39.             plot(x,y,'g+');         %draw box around real feature
  40.         else
  41.             text(x,y,sprintf('%d',i),'color','m');
  42.         end
  43.         
  44.         if abs(features(i,7))>1.8
  45.             drawbox(0,sz,x,y,[0 0 1]);
  46.         else
  47.             drawbox(0,sz,x,y,[0 .9 .2]);
  48.         end
  49.     else                        %draw as edge
  50.             
  51.         ang = features(i,6);
  52.         px = [x-sz*cos(ang) x+sz*cos(ang)];
  53.         py = [y-sz*sin(ang) y+sz*sin(ang)];
  54.         plot(px,py,'r');
  55.     end
  56. end
  57. hold off;