MATLAB Answers

MX Zhang
0

Image interpolation with a sample image

Asked by MX Zhang
on 28 Jul 2017
Latest activity Commented on by Image Analyst
on 31 Jul 2017
I am trying out image interpolation on Matlab, with the following sample image.
I'm not exactly sure why my code isn't working.
%Interpolation
figure
imagesc(V);
colormap gray;
axis image;
axis off;
title("Original");
grayImage = rgb2gray(V);
Vn = interp2(grayImage,3);
imagesc(Vn);
title("Modified");

  0 Comments

Sign in to comment.

2 Answers

Answer by Image Analyst
on 28 Jul 2017

Try using imresize() instead of interp2().

  0 Comments

Sign in to comment.


Answer by Vipresh Gangwal on 28 Jul 2017
Edited by Vipresh Gangwal on 28 Jul 2017

what do you mean it is not working? Also there seems to be a lot of salt and pepper noise in your image . That might be impacting the interpolation.
There is an example on the interp2 doc page. Try replicating same steps for your data.
https://www.mathworks.com/help/matlab/ref/interp2.html

  2 Comments

I did try the sample on the link. Here's my code:
figure
imagesc(cdata);
colormap gray;
axis image;
axis off;
title("Original");
%grayImage = rgb2gray(V);
%Vn = interp2(grayImage,3);
Vn = interp2(cdata);
imagesc(Vn);
title("Modified");
But I get an error when I perform it:
Error using .'
Transpose on ND array is not defined. Use PERMUTE instead.
Error in interp2 (line 96)
V = V.';
Error in Interpolation (line 14)
Vn = interp2(cdata);
cdata is a color image, which is a 3-D image. You can't use interp2() on a color image.
Any reason why you didn't like my solution?

Sign in to comment.