Determining vector Xq and Yq for interp2 with scale

조회 수: 3 (최근 30일)
Katarzyna Wieciorek
Katarzyna Wieciorek 2015년 4월 22일
댓글: Star Strider 2015년 4월 29일
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.

채택된 답변

Star Strider
Star Strider 2015년 4월 22일
Ask your professor what ‘scale’ is supposed to be, and how you would assign it or calculate it.
  댓글 수: 4
Katarzyna Wieciorek
Katarzyna Wieciorek 2015년 4월 29일
I solved my problem. If there is anyone with similar it may be useful:
%y = linspace(x1,x2,n), separation 0.5 = (x2-x1)/(n-1)
[sy,sx] = size(I0grey);
nx = 2*sx-1;
ny = 2*sy-1;
X1 = linspace(1,sx,nx);
Y1 = (linspace(1,sy,ny))';
Star Strider
Star Strider 2015년 4월 29일
Congratulations!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by