ind2patch(IND,M,pty​pe)

버전 1.1.0.0 (8.85 KB) 작성자: Kevin Moerman
Allows plotting of patch data (slices and voxels) for 3D images for selected voxels
다운로드 수: 1.2K
업데이트 날짜: 2015/4/28

라이선스 보기

This function generates patch data (faces “F”, vertices “V” and color data “C”) for 3D images. The patches are only generated for the voxels specified by the linear indices in “IND”. The variable “ptype” indicates
the type of patch:
'v' Voxel patch data with unshared vertices and faces
such that each voxel has 8 unshared vertices and 6
unshared faces (may be faster than 'vu' and 'vb'
options which require UNIQUE costly computations).
'vu' Voxel patch data such that where possible voxels share
vertices and faces (making patch data computation slower
but plotting more memory efficient).
FaceColor data is averaged for shared faces.
'vb' Voxel patch data faces are exported for unique unshared
faces e.g. only boundary for enclosed volume (plotted
data is visually equivalent to 'v' and 'vu' options when
FaceAlpha is 1)
'si', 'sj', 'sk' Mid-voxel slice patch data for i, j and k direction
respectively
'siu', 'sju', 'sku' Same as 'si', 'sj', 'sk' but with double points
removed.
'h' Creates a hexahedral element description instead (e.g
nx8) element data.
'hu' Same as 'h' but with shared unique nodes.

%% EXAMPLE
clear all; close all; clc;

%% Simulating 3D image
[X,Y,Z]=meshgrid(linspace(-4.77,4.77,75));
phi=(1+sqrt(5))/2;
M=2 - (cos(X + phi*Y) + cos(X - phi*Y) + cos(Y + phi*Z) + cos(Y - phi*Z) + cos(Z - phi*X) + cos(Z + phi*X));
M=M./max(M(:)); %Normalise, not required

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]);
hold on; xlabel('X-J','FontSize',20);ylabel('Y-I','FontSize',20);zlabel('Z-K','FontSize',20);

%% Creating and plotting patch data

%Setting up indices for slices to plot
S=round(size(M,2)./2);
L_slices=false(size(M));
L_slices(:,S,:)=1;
IND_slices=find(L_slices);
[Fs,Vs,C_slice]=ind2patch(IND_slices,M,'sx'); %Creating patch data for x mid-voxel slices
hs=patch('Faces',Fs,'Vertices',Vs,'EdgeColor','none', 'CData',C_slice,'FaceColor','flat','FaceAlpha',0.75);

%Setting up indices for slices to plot
S=round(size(M,1)./2);
L_slices=false(size(M));
L_slices(S,:,:)=1;
IND_slices=find(L_slices);
[Fs,Vs,C_slice]=ind2patch(IND_slices,M,'sy'); %Creating patch data for y mid-voxel slices
hs=patch('Faces',Fs,'Vertices',Vs,'EdgeColor','none', 'CData',C_slice,'FaceColor','flat','FaceAlpha',0.75);

%Setting up indices for slices to plot
S=round(size(M,3)./2);
L_slices=false(size(M));
L_slices(:,:,S)=1;
IND_slices=find(L_slices);
[Fs,Vs,C_slice]=ind2patch(IND_slices,M,'sz'); %Creating patch data for z mid-voxel slices
hs=patch('Faces',Fs,'Vertices',Vs,'EdgeColor','none', 'CData',C_slice,'FaceColor','flat','FaceAlpha',0.75);

%Setting up indices for voxels to plot
IND=find(M>-0.2 & M<=0);
[Fs,Vs,C_slice]=ind2patch(IND,M,'v'); %Creating patch data for selection of low voxels
hs=patch('Faces',Fs,'Vertices',Vs,'EdgeColor','k', 'CData',C_slice,'FaceColor','flat','FaceAlpha',1);

%Setting up indices for voxels to plot
IND=find(M>0.9);
[Fs,Vs,C_slice]=ind2patch(IND,M,'v'); %Creating patch data for selection of high voxels
hs=patch('Faces',Fs,'Vertices',Vs,'EdgeColor','k', 'CData',C_slice,'FaceColor','flat','FaceAlpha',1);

axis equal; view(3); axis tight; colormap jet; colorbar; caxis([0 1]); grid on;
set(gca,'FontSize',20);

인용 양식

Kevin Moerman (2024). ind2patch(IND,M,ptype) (https://www.mathworks.com/matlabcentral/fileexchange/28210-ind2patch-ind-m-ptype), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2015a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 3-D Volumetric Image Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

Updated for gibboncode.org

1.0.0.0