1

If I upsample an image like this:

A = imread('cameraman.tif');

M = 2;
N = 3;

B = zeros([size(A,1)*M size(A,2)*N]);
B(1:M:end,1:N:end) = A;

Then how do I interpolate B in Matlab to fill in the zeros?

Austin
  • 6,921
  • 12
  • 73
  • 138

1 Answers1

1

I believe you can do this by calling interp2 with a newly defined grid. E.g.

im = imread('cameraman.tif');
im = im2double(im);

M = 2;
N = 3;

x = linspace(1, size(im, 2), size(im, 1)*N);
y = linspace(1, size(im, 1), size(im, 2)*M);

[xs, ys] = meshgrid(x, y);

new_im = interp2(im, xs, ys, 'cubic');
Maurits
  • 2,082
  • 3
  • 28
  • 32