DIP Lab ASSIGMENT 1
DIP Lab ASSIGMENT 1
ASSIGNMENT NO.1
DIP LAB
SUBMITTED TO:
Mam Nazia
SUBMITTED BY:
Noor-Ul-Ain (21-SE-78)
1
QUESTION NO.1 CODE:
%Bilinear interpolation with MATLAB builtin Function I
= imread('rice.png');
J_bilinear_builtin = imresize(I, 2, 'bilinear');
for x = 2:columns2-1
for y = 2:rows2-1
if (mod(x, 2) == 0)
v = round(x / cx);
w = round(y / cy);
Image2_bilinear(y, x) = Image1(w, v);
else
Image2_bilinear(y, x) = -1;
end end end
for x = 2:columns2-1
for y = 2:rows2-1
if (Image2_bilinear(y, x) == -1)
Image2_bilinear(y, x) = (Image2_bilinear(y - 1, x) + Image2_bilinear(y +
1, x) + ...
Image2_bilinear(y, x - 1) + Image2_bilinear(y, x + 1)) / 4;
end end end
for x = 2:columns2-1
for y = 2:rows2-1
if (mod(x, 2) == 0)
v = round(x / cx);
w = round(y / cy);
Image2_bicubic(y, x) = Image1(w, v);
else
Image2_bicubic(y, x) = -1;
end end end
for x = 2:columns2-1
for y = 2:rows2-1
if (x ~= 1 && x ~= columns2 && y ~= 1 && y ~= rows2)
Image2_bicubic(y, x) = (Image2_bicubic(y - 1, x - 1) + Image2_bicubic(y
- 1, x) + ...
Image2_bicubic(y - 1, x + 1) + Image2_bicubic(y, x - 1) +
Image2_bicubic(y, x + 1) + ...
Image2_bicubic(y + 1, x - 1) + Image2_bicubic(y + 1, x) +
Image2_bicubic(y + 1, x + 1)) / 8;
end end end
2
OUTPUT:
QUESTION NO.2:
CODE:
% Read the image
originalImage = imread('cameraman.tif');
3
subplot(2, 2, 3);
imshow(rotatedBicubic);
title('Bicubic Interpolation');
OUTPUT:
4
QUESTION NO.3:
CODE:
% Define the binary image
bw = zeros(5, 5); bw(2,
2) = 1; bw(4, 4) = 1;
% Display the original binary image and distance transform matrices in the same
window figure;
5
OUTPUT: