That's because the FFT returns values corresponding to the discrete (spatial) frequencies from 0 through Fs, where Fs is the (spatial) sampling rate. You need to insert zeros at high frequencies, which are located at the center of the returned FFT, not in its end.
You can use fftshift
to shift the high frequencies to the end, pad with zeros, and then shift back with ifftshift
(thanks to @Shai for the correction):
bigger = ifftshift(padarray(fftshift(imFFT),[10,10]));
Also, note that padding with zeros decreases the values in the enlarged image. You can correct that using a suitable amplification factor amp
, which in this case would be equal to (1+2*10/length(im))^2
:
bigger = ifftshift(padarray(fftshift(amp*imFFT),[10,10]));