Guest User

Untitled

a guest
Nov 21st, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.11 KB | None | 0 0
  1. clear;
  2. close all;
  3.  
  4. graphics_toolkit fltk;
  5. pkg load signal;
  6. pkg load image;
  7.  
  8. inImg = imread("pattern1.bmp");
  9.  
  10. tRadius = 20;
  11. pRadius = 2;
  12.  
  13. curPatch = zeros((2*pRadius+1),(2*pRadius+1));
  14. curSurrPatch = zeros((2*pRadius+1),(2*pRadius+1));
  15. curDiff = zeros((2*pRadius+1),(2*pRadius+1));
  16.  
  17. distSurface = zeros((2*tRadius+1),(2*tRadius+1));
  18.  
  19. outImg = zeros((rows(inImg)-40)/(2*pRadius+1),(columns(inImg)-40)/(2*pRadius+1));
  20.  
  21. size(outImg)
  22. pause
  23.  
  24. oI = 0;
  25. oJ = 0;
  26.  
  27. for i=(1+pRadius+tRadius):(2*pRadius+1):(rows(inImg)-pRadius-tRadius)
  28.    
  29.     oI = oI+1;
  30.     oJ = 0;
  31.    
  32.     for j=(1+pRadius+tRadius):(2*pRadius+1):(columns(inImg)-pRadius-tRadius)
  33.          oJ = oJ + 1;
  34.  
  35.         curPatch(:,:) = inImg(i-pRadius:i+pRadius,j-pRadius:j+pRadius);
  36.        
  37.         for u=(i-tRadius):1:(i+tRadius)
  38.             for v=(j-tRadius):1:(j+tRadius)
  39.                 curSurrPatch(:,:) = inImg(u-pRadius:u+pRadius,v-pRadius:v+pRadius);
  40.                 curDiff(:,:) = curPatch .- curSurrPatch;           
  41.                 distSurface(u+1-(i-tRadius),v+1-(j-tRadius)) = sqrt(sum(sum(curDiff.^2)));
  42.             endfor
  43.         endfor
  44.        
  45.         outImg(oI,oJ) = max(max(distSurface));
  46.     endfor
  47.    
  48.     oI
  49.     oJ
  50.     fflush(stdout);
  51. endfor
Advertisement
Add Comment
Please, Sign In to add comment