Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. image = load('boat.mat');
  2. image = image.imageOrig;
  3.  
  4. image = mat2gray(image);
  5.  
  6. I = image;
  7. figure, imshow(mat2gray(I)); %first image
  8.  
  9. dim = size(image);
  10.  
  11. sigma1 = 2;
  12. sigma2 = 2;
  13. k = 0.06;
  14.  
  15. gauss1 = fspecial('gaussian', [3 3], sigma1);
  16. gauss2 = fspecial('gaussian', [3 3], sigma2);
  17.  
  18. image = imfilter(image, gauss1);
  19.  
  20. [Ix, Iy] = imgradientxy(image);
  21.  
  22. figure, imshow(Ix); %image gradient x-dirn
  23. figure, imshow(Iy); %image gradient y-dirn
  24.  
  25. Ix2 = imfilter(Ix.^2, gauss2);
  26. Iy2 = imfilter(Iy.^2, gauss2);
  27. IxIy = imfilter(Ix.*Iy, gauss2);
  28.  
  29. E1 = zeros(dim);
  30. E2 = zeros(dim);
  31. R = zeros(dim);
  32.  
  33. for i = 2:dim(1)-1
  34. for j = 2:dim(2)-1
  35. M = [Ix2(i,j), IxIy(i,j); IxIy(i,j), Iy2(i,j)];
  36. e = eig(M);
  37. E1(i,j)=min(e);
  38. E2(i,j)=max(e);
  39. R(i,j) = ((Ix2(i,j)*Iy2(i,j)) - (IxIy(i,j))^2 ) - k*(Ix2(i,j) + Iy2(i,j)).^2;
  40. end
  41. end
  42.  
  43. figure, imshow(mat2gray(E1));
  44. figure, imshow(mat2gray(E2));
  45.  
  46. R = R*1000/(max(max(R)));
  47.  
  48. cornerMeasure = (R>10);
  49.  
  50. maxR = max(max(R));
  51.  
  52. figure, imshow(mat2gray(cornerMeasure) + I);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement