Using interp1 to resample an image, results in NaN values.

8 visualizaciones (últimos 30 días)
Hello all,
I've run into an issue with a assignment I am doing. For this assignment it states: "Now, use an interpolation method (in Matlab®, ‘interp1’) to interpolate, i.e. resample, the spectrum from its original sampling to the linearized k-space sampling." During my tries I have come up with the following:
A = 807.6660554599425;
B = 0.06950484773532092;
C = -7.056743126149048e-6;
D = -3.62624279344136e-11;
N = linspace(1, 1024, 1024);
lambda = A*N.^3 + B*N.^2 + C*N + D;
k_n = (2*pi)./lambda;
max = max(k_n);
min = min(k_n);
maxmin = linspace(max,min,1024);
F_resampled = interp1(raw_plak, maxmin);
F_k = fft(F_resampled);
F4 = log(abs(F_k));
Where A through D are device specific settings and 'raw_plak' is the original image given by:
raw_plak = im2double(imread('plakband.tif'));
When using the interp1 fuction returns an array full of NaN values. What am I doing wrong?
Sorry if this has been answered already, I have looked but could not find an answer to my problem.
With regards.
  2 comentarios
Star Strider
Star Strider el 15 de En. de 2022
The assignment says to resample a spectrum. (To me, that implies a vector.)
Where does the image (a 2D or 3D array) enter into this?
Thijs Knoop
Thijs Knoop el 15 de En. de 2022
Thanks for looking into it.
As my current understanding goes, the image in question is a collection of several "A-lines" or vectors filled with data. I have 1024 of these A lines which fill up the image. Each of these vectors needs to be resampled to the "maxmin" vector. I also understood that "interp1" allows for multiple lines to be resampled.
After the resampling the next step will be to fourier transform the resampled image into an image seen through an OCT device. (If this helps paint a better picture of the overal assignment)

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 15 de En. de 2022
@Star Strider spectra can be 2-D. For example a diffraction pattern is a 2-D spectrum. You can get a spatial frequency spectrum from an image using fft2().
Because they say use interp1, that implies the input is 1-D. But since you say raw_plak is a 2-D image gotten from imread(), you'll need to use interp2() not interp1(). If that doesn't get rid of the nan's, then attach 'plakband.tif' in a .zip file along with your m-file with the paperclip icon.
Don't destroy the max and min values by overwriting the functions with values like you did here:
max = max(k_n);
min = min(k_n);
  3 comentarios
Thijs Knoop
Thijs Knoop el 15 de En. de 2022
As your original comment stated interp2 seems to have worked. My resampled array is now filled with data. If this data is correct or not, that will be up to me.
A great many thanks.
"Don't destroy the max and min values by overwriting the functions with values like you did here"
I am such an f'ing idiot, you don't want to know how long I have stupidly worked around this.
Again thanks a bunch. <3
Star Strider
Star Strider el 15 de En. de 2022
@Image Analyst — I am well aware of that!
However the initial problem was to use interp1 (that interpolates vectors) on an image that was not provided.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by