% Chapter 11, Example 11.2, Fig.11.8 % Eric Dubois, updated 2019-01-14 %Tests on upsampling an LxL image by a factor of K close all, clear all; K = 4; A = rgb2gray(im2double(imread('05.tif'))); % motorcycle image imshow(A) %extract a subimage of size LxL at location xpos, ypos L = 128; xpos = 350; ypos = 150; ORIG = A(ypos:ypos+L-1, xpos:xpos+L-1); figure, imshow(ORIG); %resize using matlab function imresize with bilinear interpolation OUTbl = imresize(ORIG,K,'bilinear'); figure, imshow(OUTbl); %upsample by zero-insertion and low pass filter ORIG_zins = zeros(K*L,K*L); off = round(K/2)+1; ORIG_zins(off:K:off+(L-1)*K,off:K:off+(L-1)*K) = ORIG; figure, imshow(ORIG_zins); %Filter with an interpolation filter %bicubic interpolator rng1 = (0:K-1)/K; bcp1 = 1.5*(rng1).^3 -2.5*(rng1).^2 +1; rng2 = (K:2*K-1)/K; bcp2 = -0.5*(rng2).^3 + 2.5*(rng2).^2 - 4*(rng2) + 2; hbic1 = [fliplr(bcp2) fliplr(bcp1) bcp1(2:size(bcp1,2)) bcp2]; OUTbc_exp = imadjust(imfilter(ORIG_zins,hbic1'*hbic1,'symmetric','same')); figure, imshow(OUTbc_exp); Hbic = freqz2(hbic1'*hbic1, 64, 64, [.5, .5]); %K:1 designed interpolator filter load('interp16_qs_coeff.mat'); OUT_des_int = imadjust(imfilter(ORIG_zins,h_int,'symmetric','same')); figure, imshow(OUT_des_int);