Skip to content

Instantly share code, notes, and snippets.

@tonyfast
Created September 10, 2014 20:04
Show Gist options
  • Select an option

  • Save tonyfast/797c6a7e8db48da14259 to your computer and use it in GitHub Desktop.

Select an option

Save tonyfast/797c6a7e8db48da14259 to your computer and use it in GitHub Desktop.
Example Script for COmputing on Hazelnut Data
filename = 'macadamia.mat'
if ~exist( filename, 'file' );
urlwrite( ... Write a url to a file
'https://dl.dropboxusercontent.com/u/22455492/natural-3d/macadamia.mat', ... The requested url
filename )
end % if:~exist
%%
load( filename ); % Variable is input as structure
%% Calculate Volume Fraction
volumefraction = mean( structure(:) );
return
%%
shift = [eye(3); -1*eye(3)];
edge = zeros( size( structure ) );
for ii = 1 : size( shift,1);
temp = structure - circshift( structure, shift(ii,:));
temp(:) = abs(temp);
edge = edge | temp;
end
%% Visualize the dataset
if ~exist( 'slices', 'dir' )
mkdir( 'slices' );
end
clc;
for ii = 1 : 80 : 500
pcolor( double(structure(:,:,ii)) );
figure(gcf)
axis off
colormap gray
title(sprintf('Black::Pore and White::Solid @ Slice::%i',ii),...
'Fontsize',16 );
saveas( gcf,fullfile('.','slices',sprintf('Slice-%i.png',ii) ) )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment