Increase one of the dimensions of an array

조회 수: 7 (최근 30일)
Sebastian Dahl Sandbu
Sebastian Dahl Sandbu 2023년 6월 17일
댓글: Sebastian Dahl Sandbu 2023년 6월 17일
I have a 190x190x20 array with intensity values of medical images (nifti). The resolution is (1mm, 1mm, 2mm), and I would like to have the same resolution in all directions. In other words, I want 40 pages instead of 20 pages.
Is there any way to increase the number of pages or increase the resolution in one direction? I have looked at interpolation, but I'm not sure if it will work in my case.
Greatful for any ideas.
  댓글 수: 2
Stephen23
Stephen23 2023년 6월 17일
편집: Stephen23 2023년 6월 17일
"In other words, I want 40 pages instead of 20 pages."
You are making an off-by-one error. Consider:
V = 1:4
V = 1×4
1 2 3 4
W = 1:0.5:4
W = 1×7
1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000
W has twice the resolution of V, but does it have twice the number of elements in it?
" I have looked at interpolation, but I'm not sure if it will work in my case."
Probably: what you describe is some kind of interpolation (using what method is another question entirely).
What have you tried so far?
Sebastian Dahl Sandbu
Sebastian Dahl Sandbu 2023년 6월 17일
I see, thanks for the explanation.
So for mye array A, I have tried interp3(A), but that will increase the resolution in all dimension. I did also try the following, but without success.
[X, Y, Z] = size(A);
[Xq,Yq,Zq] = meshgrid(1:1:190,1:1:190,1:.5:39.5);
B = interp3(X, Y, Z, A, Xq, Yq, Zq);

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

채택된 답변

Image Analyst
Image Analyst 2023년 6월 17일
help interp3
Something like (untested)
[rows, columns, slices] = size(img)
z = linspace(1, slices, 2 * slices); % Need twice as many slices as the original.
[X, Y, Z] = meshgrid(1:columns, 1:rows, z);
img2 = interp3(img, X, Y, Z);

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by