% NAME: % test_get_intensity_interp_01.m % % DESC: % test the interpolation routines close all clear all clc I = imread('cameraman.tif'); % create points on the patch w = 16; [xx yy] = ndgrid(-w:w, -w:w); xx = transpose(xx(:)); yy = transpose(yy(:)); % map the patch ont the image xx0 = 88; yy0 = 158; phi = 60*pi/180; x(1, :) = xx0 + cos(phi)*xx - sin(phi)*yy; x(2, :) = yy0 + sin(phi)*xx + cos(phi)*yy; % interpolate mode = 0; Ii0 = get_intensity_interp(I, x, mode); Ii0 = reshape(Ii0, 2*w+1, 2*w+1); mode = 1; Ii1 = get_intensity_interp(I, x, mode); Ii1 = reshape(Ii1, 2*w+1, 2*w+1); mode = 2; Ii2 = get_intensity_interp(I, x, mode); Ii2 = reshape(Ii2, 2*w+1, 2*w+1); % display the results figure; pp = 1; qq = 4; subplot(pp, qq, 1); imshow(I) hold on plot(x(2, :), x(1, :), '.r') subplot(pp, qq, 2); imshow(imscale(Ii0)) title('Nearest Neighbour') subplot(pp, qq, 3); imshow(imscale(Ii1)) title('Bilinear') subplot(pp, qq, 4); imshow(imscale(Ii2)) title('Cubic')