简体   繁体   English

在MATLAB中如何从具有中心点和X,Y,Z长度的3D体积中提取立方体?

[英]how to extract a cube from a 3D volume having a centre point and lengths of X, Y, Z in MATLAB?

In MATLAB, if we assume the starting point of a cube is up-left corner, 在MATLAB中,如果我们假设立方体的起点是左上角,

3D_vol(Start_x : Start_x + SizeX-1, Start_y : Start_y + SizeY-1, Start_z : Start_z + SizeZ-1);

gets a cube having starting points of X, Y, Z and size of each. 得到一个具有X,Y,Z和每个大小的起点的立方体。 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. 我尝试了以下操作,但是当X / Y / Z的大小为偶数时,这是不正确的。

3D_vol(start_x - (SizeX/2) - 1 : Start_x + (SizeX/2) - 1, ......

3D_vol is a 3d matrix. 3D_vol是3d矩阵。

I am assuming the start points are integers. 我假设起点是整数。
If SizeX is odd it is easier. 如果SizeX为奇数, SizeX容易。 You have you centre point and (SizeX-1)/2 in each side: 您有中心点,每边都有(SizeX-1)/2

start_x + (-(SizeX-1)/2:(SizeX-1)/2)

That would give you a total of 1+2*(SizeX-1)/2 = SizeX points. 这将使您总共获得1+2*(SizeX-1)/2 = SizeX点。
In case SizeX is even, your start_x is not actually the centre but one of the closest points to it. 如果SizeX是偶数,则start_x实际上不是中心,而是最接近它的点之一。 You should decide if its left or right of centre. 您应该确定它是居中还是居中。 Let's assume left. 让我们假设离开。 Then, on the left side you need the start_x point and SizeX/2-1 more points. 然后,在左侧,您需要start_x点和SizeX/2-1更多点。 the rest would be on the right: 其余的将在右边:

start_x + (-(SizeX/2-1):SizeX/2)

That would give you a total of 1+(SizeX-1)/2-1+SizeX/2 = SizeX points. 这将使您总共获得1+(SizeX-1)/2-1+SizeX/2 = SizeX点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 3D 图像 alignment:如何从 matlab 中的 3x3 旋转矩阵中提取关于“静态”x、y、z 轴的旋转角度 - 3D image alignment: How to extract rotation angles about “static” x,y,z axes from a 3x3 rotation matrix in matlab 如何分别对X * Y * Z(3D)矩阵matlab进行子图绘制? - How to separately subplot a X*Y*Z (3D) matrix matlab? 如何使用MATLAB将2D(x,y)坐标转换为3D(x,y,z)坐标? - How to convert 2D(x,y) coordinates to 3D(x,y,z) coordinates using MATLAB? 如何使用Matlab在3D大数据散点图中用不同的颜色标记一个点(我有x,y,z)? - How to mark a point (I have x,y,z for it) in a 3D big data scatter plot with different color using matlab? 给定x,y和z间隔绘制3D表面或体积 - Plotting a 3D surface or volume, given x, y and z intervals 从两个2D立体图像生成3D(x,y,z)点云 - Generating 3D (x,y,z) Point Clouds from Two 2D Stereo Images 基于x,y,z数据的matlab 3d图形 - matlab 3d graph based on x,y,z data 如何在MATLAB中从三维点云中提取xyz坐标 - How to extract xyz coordinates from 3D point cloud in MATLAB 如何在 MATLAB 中围绕一个点绘制立方体(3D 框)? - How to draw a cube (3D box) around a point in MATLAB? Matlab:如何在(x,y,z)坐标中绘制堆叠的3D条形图? - Matlab: how to plot a stacked 3D bar plot in (x,y,z)-coordinates?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM