Determining vector Xq and Yq for interp2 with scale

3 Ansichten (letzte 30 Tage)
Katarzyna Wieciorek
Katarzyna Wieciorek am 22 Apr. 2015
Kommentiert: Star Strider am 29 Apr. 2015
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.

Akzeptierte Antwort

Star Strider
Star Strider am 22 Apr. 2015
Ask your professor what ‘scale’ is supposed to be, and how you would assign it or calculate it.
  4 Kommentare
Katarzyna Wieciorek
Katarzyna Wieciorek am 29 Apr. 2015
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 am 29 Apr. 2015
Congratulations!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by