Guest User

Untitled

a guest
Jan 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.89 KB | None | 0 0
  1. for i = 1:neighbors
  2.   y = spoints(i,1)+origy;
  3.   x = spoints(i,2)+origx;
  4.   % Calculate floors, ceils and rounds for the x and y.
  5.   fy = floor(y); cy = ceil(y); ry = round(y);
  6.   fx = floor(x); cx = ceil(x); rx = round(x);
  7.   % Check if interpolation is needed.
  8.   if (abs(x - rx) < 1e-6) && (abs(y - ry) < 1e-6)
  9.     % Interpolation is not needed, use original datatypes
  10.     N = image(ry:ry+dy,rx:rx+dx);
  11.     D = N >= C;
  12.   else
  13.     % Interpolation needed, use double type images
  14.     ty = y - fy;
  15.     tx = x - fx;
  16.  
  17.     % Calculate the interpolation weights.
  18.     w1 = (1 - tx) * (1 - ty);
  19.     w2 =      tx  * (1  - ty);
  20.     w3 = (1  - tx) *   ty ;
  21.     w4 =      tx  *    ty ;
  22.  
  23.     %Compute interpolated pixel values
  24.     N = w1*d_image(fy:fy+dy,fx:fx+dx) + w2*d_image(fy:fy+dy,cx:cx+dx) + ...
  25.     w3*d_image(cy:cy+dy,fx:fx+dx) + w4*d_image(cy:cy+dy,cx:cx+dx);
  26.  
  27.     D = N >= d_C;
  28.  
  29.  end
Add Comment
Please, Sign In to add comment