Description: This simple function creates a structure array containing coordinate and colour data for 3D images. The example below shows how the function allows one to use the patch function to plot the whole image or a selection of voxels in 3D. The CData is generated using the voxel intensities.
N.B. The function has not been optimised for large images. Large images (function has been tested for images under 100x100x100) may produce memory problems.
%% EXAMPLE M=rand(15,15,15); [IMAGE_3D_DATA]=image3Ddata(M);
%Getting faces and vertices for full image voxel_no=1:1:numel(M); voxel_face_no=IMAGE_3D_DATA.voxel_patch_face_numbers(voxel_no,:); M_faces=IMAGE_3D_DATA.voxel_patch_faces(voxel_face_no,:); M_vertices=IMAGE_3D_DATA.corner_coordinates_columns_XYZ;
%Getting faces and vertices for selection of voxels voxel_no2=M>0.95; voxel_face_no2=IMAGE_3D_DATA.voxel_patch_face_numbers(voxel_no2,:); M_faces2=IMAGE_3D_DATA.voxel_patch_faces(voxel_face_no2,:); M_vertices2=IMAGE_3D_DATA.corner_coordinates_columns_XYZ;
figure;fig=gcf; clf(fig); colordef (fig, 'white'); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); set(fig,'Color',[1 1 1]);
subplot(1,2,1); hp=patch('Faces',M_faces,'Vertices',M_vertices,'EdgeColor','black', 'CData',IMAGE_3D_DATA.voxel_patch_CData(voxel_face_no,:),'FaceColor','flat'); hold on; view(45,30); axis equal; axis tight; colormap jet; colorbar; caxis([0 1]); xlabel('J'); ylabel('I'); zlabel('K'); title('Full image');
subplot(1,2,2); hp2=patch('Faces',M_faces2,'Vertices',M_vertices2,'EdgeColor','black', 'CData',IMAGE_3D_DATA.voxel_patch_CData(voxel_face_no2,:),'FaceColor','flat'); hold on; view(45,30); axis equal; axis tight; colormap jet; colorbar; caxis([0 1]); grid on; set(hp2,'FaceAlpha',0.8); xlabel('J'); ylabel('I'); zlabel('K'); title('Selection of voxels'); License: Shareware Related: colordef, clffig, White, units dgetfig units, setfig color, setfig units units, figurefig dgcf, voxel dmgt, image data dimage ddatam, drand O/S:BSD, Linux, Solaris, Mac OS X File Size: 10.0 KB Downloads: 8
|
|