Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. A = [1 2 3 4 5
  2. 6 7 8 9 10
  3. -1 3 4 8 13
  4. 4 2 0 9 1]
  5.  
  6. A = [1 2 3 4 5
  7. 6 8 9 10 10
  8. -1 8 9 13 13
  9. 4 2 0 9 1]
  10.  
  11. %%// Dilate to get the max of a 9x9 neighborhood (including the element itself)
  12. A1 = imdilate(A, true(3));
  13.  
  14. %%// Since you are looking to keep the boundary elements
  15. m1 = ones(size(A));
  16. m1(2:end-1,2:end-1)=0;
  17. A1 = m1.*A+~m1.*A1
  18.  
  19. %%// Dilate to get the max of a 8x8 neighborhood (excluding the element itself)
  20. h = true(3);
  21. h(2,2)=false;
  22. A1 = imdilate(A,h);
  23.  
  24. %%// Since you are looking to keep the boundary elements
  25. m1 = ones(size(A));
  26. m1(2:end-1,2:end-1)=0;
  27. A1 = m1.*A+~m1.*A1
  28.  
  29. fun = @(x) max(x(:)),
  30. B = nlfilter(YourImage,[3 3],fun);
  31.  
  32. fun=@(x) max([x(1:3, 1)' x(1,2) x(3,2) x(1:3,3)'])
  33.  
  34. B = ordfilt2(A, 9, ones(3,3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement