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

2 ビュー (過去 30 日間)
Thijs Knoop
Thijs Knoop 2022 年 1 月 15 日
コメント済み: Star Strider 2022 年 1 月 15 日
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 件のコメント
Star Strider
Star Strider 2022 年 1 月 15 日
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 2022 年 1 月 15 日
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)

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2022 年 1 月 15 日
@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 件のコメント
Thijs Knoop
Thijs Knoop 2022 年 1 月 15 日
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 2022 年 1 月 15 日
@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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by