hello all, am a beginner to image processing can anybody kindly explain what is the purpose of using the code from the line 44 to line 52 in harris corner detection pls help me out. am try to understand it form past 2 days . pls help me out.

1 view (last 30 days)
  1. imshow(frame);
  2. k = waitforbuttonpress;
  3. point1 = get(gca,'CurrentPoint');
  4. rectregion = rbbox;
  5. point2 = get(gca,'CurrentPoint');
  6. point1 = point1(1,1:2);
  7. point2 = point2(1,1:2);
  8. lowerleft = min(point1, point2);
  9. upperright = max(point1, point2);
  10. ymin = round(lowerleft(1));
  11. ymax = round(upperright(1));
  12. xmin = round(lowerleft(2));
  13. xmax = round(upperright(2));
  14. Aj=6;
  15. cmin=xmin-Aj; cmax=xmax+Aj; rmin=ymin-Aj; rmax=ymax+Aj;
  16. min_N=12;max_N=16;
  17. sigma=2; Thrshold=20; r=6; disp=1;
  18. dx = [-1 0 1; -1 0 1; -1 0 1]; % The Mask
  19. dy = dx';
  20. Ix = conv2(I(cmin:cmax,rmin:rmax), dx, 'same');
  21. Iy = conv2(I(cmin:cmax,rmin:rmax), dy, 'same');
  22. g = fspecial('gaussian',max(1,fix(6*sigma)), sigma); %%%%%% Gaussien Filter
  23. Ix2 = conv2(Ix.^2, g, 'same');
  24. Iy2 = conv2(Iy.^2, g, 'same');
  25. Ixy = conv2(Ix.*Iy, g,'same');
  26. k = 0.04;
  27. R11 = (Ix2.*Iy2 - Ixy.^2) - k*(Ix2 + Iy2).^2;
  28. R11=(1000/max(max(R11)))*R11;
  29. R=R11;
  30. ma=max(max®);
  31. sze = 2*r+1;
  32. MX = ordfilt2(R,sze^2,ones(sze));
  33. R11 = (R==MX)&(R>Thrshold);
  34. count=sum(sum(R11(5:size(R11,1)-5,5:size(R11,2)-5)));
  35. loop=0;
  36. while (((count<min_N)|(count>max_N))&(loop<30))
  37. if count>max_N
  38. Thrshold=Thrshold*1.5;
  39. elseif count < min_N
  40. Thrshold=Thrshold*0.5;
  41. end
  42. R11 = (R==MX)&(R>Thrshold);
  43. count=sum(sum(R11(5:size(R11,1)-5,5:size(R11,2)-5)));
  44. loop=loop+1;
  45. end
  46. R=R*0;
  47. R(5:size(R11,1)-5,5:size(R11,2)-5)=R11(5:size(R11,1)-5,5:size(R11,2)-5);
  48. [r1,c1] = find®;
  49. PIP=[r1+cmin,c1+rmin]%% IP
  50. Size_PI=size(PIP,1);
  51. for r=1: Size_PI
  52. I(PIP(r,1)-2:PIP(r,1)+2,PIP(r,2)-2)=255;
  53. I(PIP(r,1)-2:PIP(r,1)+2,PIP(r,2)+2)=255;
  54. I(PIP(r,1)-2,PIP(r,2)-2:PIP(r,2)+2)=255;
  55. I(PIP(r,1)+2,PIP(r,2)-2:PIP(r,2)+2)=255;
  56. end
  57. imshow(uint8(I))

Answers (1)

David Young
David Young on 27 Jul 2014
Lines 44 and 45 implement the central definition of the Harris-Stephens corner measure. To undertand this, look preferably at the original paper, or failing that, at the Wikipedia article.
Lines 46 and 47 do some scaling, but their purpose is mysterious to me.
Line 48 is probably intended to find the maximum of the array, but looks corrupted since it has an unusual symbol where I would expect to see (R). I don't see how this is used.
Lines 49-51 appear to be finding local maxima of the corner measure, provided that they exceed some threshold.
Line 52 appears to be counting the number of such maximum in the image.
I guess this is not your code, since you are asking for help understanding it. You will probably get a better explanation of it if you consult its author.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!