Skip to content
Snippets Groups Projects
Commit 29382563 authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

gtRenderGrains : useful function adapted to the DCT code to make 3D...

gtRenderGrains : useful function adapted to the DCT code to make 3D visualization of grains in the volume...

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@638 4c865b51-4357-4376-afb4-474e03ccb993
parent abcb1038
No related branches found
No related tags found
No related merge requests found
function p=gtRenderGrains(grains,map,varargin); function p=gtRenderGrains(grains,map,varargin)
% %
if nargin==3 if nargin==3
...@@ -9,29 +9,17 @@ else ...@@ -9,29 +9,17 @@ else
list=unique(grains); list=unique(grains);
end end
list(find(list==0))=[];%don't render the background list(find(list==0))=[];%don't render the background
list(find(list==-1))=[];%don't render the conflicts
figure; figure;
%go through graini by grain %go through graini by grain
for i=1:length(list) for i=1:size(list,1)
disp(sprintf('rendering grain %d of %d...', i, length(list))) fprintf('rendering grain %d of %d...\n', i, length(list))
voltest = zeros(size(grains));
voltest=zeros(size(grains)); voltest = grains==list(i);
voltest2=smooth3(voltest, 'box', 3);
voltest(find(grains==list(i)))=1; p(i)=patch(isosurface(voltest2, 0.5), 'FaceColor', map(list(i)+1, :), 'EdgeColor', 'none');
%pad for smoothing
voltest2=zeros(size(voltest)+10);
voltest2(6:end-5, 6:end-5, 6:end-5)=voltest;
voltest2=smooth3(voltest2, 'box', 3);
p(i)=patch(isosurface(voltest2, 0.5));
%set colour according to map (note map(1,:)=[0 0 0] for background, so +1
set(p(i), 'FaceColor', map(list(i)+1, :), 'EdgeColor', 'none');
end end
camlight camlight
lighting phong lighting phong
...@@ -40,3 +28,5 @@ axis vis3d ...@@ -40,3 +28,5 @@ axis vis3d
set(gca, 'xTick', []); set(gca, 'xTick', []);
set(gca, 'yTick', []); set(gca, 'yTick', []);
set(gca, 'zTick', []); set(gca, 'zTick', []);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment