【发布时间】:2017-10-12 10:04:36
【问题描述】:
我有需要可视化的 3D 图像数据。我已经能够使用imshow3D 使用 2D 切片对其进行可视化,但我希望在 3D 空间中查看图像数据。
我使用的代码如下(礼貌:How do i create a rectangular mask at known angles?),但我不知道为什么它不显示:
% create input image
imageSizeX = 120;
imageSizeY = 200;
imageSizeZ = 50
% generate 3D grid
[columnsInImage, rowsInImage, pagesInImage] = meshgrid(1:imageSizeX, 1:imageSizeY, 1:imageSizeZ);
% create the sphere in the image.
centerY = imageSizeY/2;
centerX = imageSizeX/2;
centerZ = imageSizeZ/2;
diameter = 56;
radius = diameter/2;
sphereVoxels = (rowsInImage - centerY).^2 ...
+ (columnsInImage - centerX).^2 + (pagesInImage - centerZ).^2 <= radius.^2;
% change image from logical to numeric labels.
Img = double(sphereVoxels);
for ii = 1:numel(Img)
if Img(ii) == 0
Img(ii) = 2; % intermediate phase voxels
end
end
% specify the desired angle
angle = 60;
% specify desired pixel height and width of solid
width = imageSizeX;
height = imageSizeY;
page = imageSizeZ;
% Find the row point at which theta will be created
y = centerY - ( radius*cos(angle * pi/180) )
% determine top of the solid bar
y0 = max(1, y-height);
% label everything from y0 to y to be = 3 (solid)
Img(y0:y, 1:width, 1:page)=3;
% figure, imshow3D(Img);
% axis on;
% grid on;
% display it using an isosurface
fv = isosurface(Img, 0);
patch(fv,'FaceColor',[0 0 .7],'EdgeColor',[0 0 1]); title('Binary volume of a sphere');
view(45,45);
axis tight;
grid on;
xlabel('x-axis [pixels]'); ylabel('y-axis [pixels]'); zlabel('z-axis [pixels]')
虽然实心条不是如下图所示的对角线,但我希望图像与此类似:
我不知道我在这里做错了什么。
【问题讨论】:
-
另外,如果您真的想像示例图像中那样渲染体积(即“体素化”的类似 Minecraft 的视图)而不是使用等值面,我可以为您提供解决方案。
-
哦,我明白了!谢谢@gnovice,我很高兴有这个解决方案。非常非常感谢您的好意...
标签: matlab image-processing multidimensional-array plot visualization