How to extract a cube from a 3D volume/matrix?

2 ビュー (過去 30 日間)
ML
ML 2016 年 5 月 17 日
コメント済み: Image Analyst 2016 年 5 月 17 日
if we assume the starting point of a cube is up-left corner,
3D_vol(Start_x : Start_x + SizeX-1, Start_y : Start_y + SizeY-1, Start_z : Start_z + SizeZ-1);
gives voxel values in a cube having starting points of X, Y, Z and size of each. Now, if the starting point is the *center* of the cube, how can I get the cube?
I tried the following, but it is not correct when the size of X/Y/Z is even.
3D_vol(start_x - (SizeX/2) - 1 : Start_x + (SizeX/2) - 1, ......
3D_vol is a 3d matrix.

採用された回答

Image Analyst
Image Analyst 2016 年 5 月 17 日
Use floor(SizeX/2) instead of (SizeX/2) because (SizeX/2) might have a 0.5 fractional part and fractional indexes are not allowed.
  3 件のコメント
Ahmet Cecen
Ahmet Cecen 2016 年 5 月 17 日
You cannot have a center point resolve as a voxel in even cube sizes. You can either have an 11x11x11 cube with a center voxel, or 10x10x10 with a center node(corner).
Image Analyst
Image Analyst 2016 年 5 月 17 日
If you want the values "in between" voxel locations, you'd need to do a 3-D interpolation. Try looking into interp3(). Sorry - I don't have a demo for you but there are examples.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFrequently-used Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by