Determining vector Xq and Yq for interp2 with scale
Show older comments
Hello,
I am studying how to make interpolation in image processing.
My error: Undefined function or variable 'scale'. Error in PL7ex3 (line 4) X1 = 1:1/scale:size(I0grey,2);
%PL7. Compare different methods for interpolation.
I0 = imread('glomeruli.tif'); %MxNx3
I0grey = im2double(rgb2gray(I0)); %grey, MxN
%interp2
X1 = 1:1/scale:size(I0grey,2);
Y1 = (1:1/scale:size(I0grey,1))';
X2 = 1:1/scale:size(I0grey,2);
Y2 = (1:1/scale:size(I0grey,1))';
I01 = interp2(I0grey, X1, Y1);
I02 = interp2(I0grey, X1, Y1, 'nearest');
I03 = interp2(I0grey, X1, Y1, 'cubic');
I04 = interp2(I0grey, X1, Y1, 'spline');
%Vq = interp2(___,method) specifies an optional, trailing input argument
%that you can pass with any of the previous syntaxes. The method argument
%can be any of the following strings that specify alternative interpolation
%methods: 'linear', 'nearest', 'cubic', or 'spline'. The default method is
%'linear'.
figure(1) % create new figure
subplot(2,3,1) % first subplot
imshow(I0)
title('Original')
subplot(2,3,2)
imshow(I0gray)
title('Original in greyscale')
subplot(2,3,3)
imshow(I01)
title('Linear interpolation')
subplot(2,3,4)
imshow(I02)
title('Interpolation 2: Nearest sample grid point.')
subplot(2,3,5)
imshow(I03)
title('Interpolation 3: Cubic convolution')
subplot(2,3,7)
imshow(I04)
title('Interpolation 4: Cubic spline')
figure(2) % create new figure
subplot(2,3,1) % first subplot
plot(I0(:,50))
title('Original')
subplot(2,3,2)
plot(I0gray(:,50))
title('Original in greyscale')
subplot(2,3,3)
plot(I01(:,50))
title('Linear interpolation')
subplot(2,3,4)
plot(I02(:,50))
title('Interpolation 2: Nearest sample grid point.')
subplot(2,3,5)
plot(I03(:,50))
title('Interpolation 3: Cubic convolution')
subplot(2,3,7)
plot(I04(:,50))
title('Interpolation 4: Cubic spline')
I rewrote this line from the example that prof. was showing us. Is there any misspelling? How can I correct it?
Thank you in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!