how to make 3d voxel in specific range?

10 ビュー (過去 30 日間)
Sierra
Sierra 2022 年 12 月 19 日
回答済み: Tushar 2023 年 3 月 21 日
I want to make 3d voxel in specific range and the voxel size is 20m x 20m x 20m.
xmin(longtitude) is 126.3342 and xmax(longitude) is 126.5541 in geographic coordinates.
ymin(latitude) is 37.3792 and ymax(latitude) is 37.5458.
and z origin is 7m.
I found two functions about makinf voxel.
Please let me know.
Thanks.

回答 (1 件)

Tushar
Tushar 2023 年 3 月 21 日
Hi,
To create a 3D voxel in a specific range with a voxel size of 20m x 20m x 20m, you can use the following steps in MATLAB:
1. Define the range of the voxel by specifying the minimum and maximum values for the x, y, and z coordinates:
xmin = 126.3342;
xmax = 126.5541;
ymin = 37.3792;
ymax = 37.5458;
zorigin = 7;
2. Calculate the number of voxels needed in each direction based on the specified voxel size:
voxelSize = 20;
numVoxelsX = ceil((xmax-xmin)/voxelSize);
numVoxelsY = ceil((ymax-ymin)/voxelSize);
numVoxelsZ = ceil((zorigin+100)/voxelSize); %assuming a height of 100m
3. Create a binary 3D matrix with dimensions equal to the number of voxels in each direction:
voxelMatrix = zeros(numVoxelsX, numVoxelsY, numVoxelsZ);
4. Iterate over the range of the voxel and set the corresponding voxels in the matrix to 1:
for x = 1:numVoxelsX
for y = 1:numVoxelsY
for z = 1:numVoxelsZ
if (xmin+(x-1)*voxelSize <= xmax && ymin+(y-1)*voxelSize <= ymax && (z-1)*voxelSize >= zorigin)
voxelMatrix(x,y,z) = 1;
end
end
end
end
The resulting voxelMatrix should now contain a 3D binary representation of the voxel, where voxels that fall within the specified range are set to 1 and voxels outside the range are set to 0.
Note that the functions you mentioned may provide more advanced features such as color indexing or visualization, but the basic steps above should help you create a simple 3D voxel representation of your specified range.
Hope it helps!!

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by