Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. % NOTE1: This code is not efficient. You shall Vectorize it easily
  2. % and get rid of the for-loops, yielding a substantial boost in efficiency.
  3. % NOTE2: boundary rows/columns may be left untouched which needs a simple fix
  4. % The transform that you want to appply is (x,y)=T(n,m)
  5. % The transform that we will use is its inverse (n,m)=invT(x,y) (you shall invert your transform)
  6. % Original image I1 is of size S1xS2, transformed image I2 is of size N1xN2
  7. for x=1:N1 % let N1 = S1 and N2= S2 for this example WAVE1
  8. for y=1:N2
  9.  
  10. % s1- compute back coordinates in the original image domain
  11. % [n m] = invT(x,y);
  12. m = y;
  13. n = x - 20*sin(2*pi*y/128);
  14.  
  15. % s2-s3 Apply (bilinear) interpolation to find the image intensity, if
  16. % n,m does not fall into integer indices
  17. d1 = n - floor(n);
  18. d2 = m - floor(m);
  19.  
  20. % s3- define the image pixel
  21. if ( ((n>=1)&(n<S(1))) & ((m>=1)&(m<S(2))) )
  22. I2(x,y) = (1-d1)*(1-d2) * I1(floor(n),floor(m)) + ...
  23. (1-d1)*d2 * I1(floor(n),floor(m)+1) + ...
  24. d1*(1-d2) * I1(floor(n)+1,floor(m)) + ...
  25. d1*d2 * I1(floor(n)+1,floor(m)+1) ;
  26. end%if
  27.  
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement