Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i = 1:neighbors
- y = spoints(i,1)+origy;
- x = spoints(i,2)+origx;
- % Calculate floors, ceils and rounds for the x and y.
- fy = floor(y); cy = ceil(y); ry = round(y);
- fx = floor(x); cx = ceil(x); rx = round(x);
- % Check if interpolation is needed.
- if (abs(x - rx) < 1e-6) && (abs(y - ry) < 1e-6)
- % Interpolation is not needed, use original datatypes
- N = image(ry:ry+dy,rx:rx+dx);
- D = N >= C;
- else
- % Interpolation needed, use double type images
- ty = y - fy;
- tx = x - fx;
- % Calculate the interpolation weights.
- w1 = (1 - tx) * (1 - ty);
- w2 = tx * (1 - ty);
- w3 = (1 - tx) * ty ;
- w4 = tx * ty ;
- %Compute interpolated pixel values
- N = w1*d_image(fy:fy+dy,fx:fx+dx) + w2*d_image(fy:fy+dy,cx:cx+dx) + ...
- w3*d_image(cy:cy+dy,fx:fx+dx) + w4*d_image(cy:cy+dy,cx:cx+dx);
- D = N >= d_C;
- end
Add Comment
Please, Sign In to add comment