Digital Image Processing: This problem investigates nearest neighbor and bilinea
ID: 669168 • Letter: D
Question
Digital Image Processing:
This problem investigates nearest neighbor and bilinear interpolation. For simplicity, we will focus on estimating the image intensity at a single location. Interpolation is used when transforming an image through resizing, rotating, etc. in which case, the image intensity will need to be estimated at a number of locations.
Consider the diagram below of four pixels
a) Provide an estimate for p5 using nearest neighbor interpolation.
b) Provide an estimate for p5 using bilinear interpolation. Round your value to the nearest integer.
2 3 4 where the dots () represent the locations where we know the image intensity and the X represents the location where we would like to estimate the image intensity. By convention, the vertical axis is the x-axis and the horizontal axis is the y-axisExplanation / Answer
% scale up using interpolation
img = imread('t1.gif');
prompt = 'Enter the scale up value ';
zoom_scale = input(prompt);
a = size(img);
x = a(:,1);
y = a(:,2);
%z = a(:,3);
for i = 1:zoom_scale*x
xx = i/zoom_scale;
x1 = max(1,floor(xx));
x2 = ceil(xx);
x_int = rem(xx,1);
for j = 1:zoom_scale*y
yy = j/zoom_scale;
y1 = max(1,floor(yy));
y2 = ceil(yy);
y_int = rem(yy,1);
BL = img(x1,y1,:);
TL = img(x1,y2,:);
BR = img(x2,y1,:);
TR = img(x2,y2,:);
R1 = BR*y_int+BL*(1-y_int);
R2 = TR*y_int+TL*(1-y_int);
res_img(i,j,:) = R1*x_int+R2*(1-x_int);
end
end
I = mat2gray(res_img);
imshow(I);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.