avw_binary - return 0 for avw.img <= thresh, 1 otherwise Usage: avw = avw_binary(avw,thresh) avw is the Analyze volume returned by avw_read thresh is the threshold intensity value (default = 0)
0001 function avw = avw_binary(avw,thresh) 0002 0003 % avw_binary - return 0 for avw.img <= thresh, 1 otherwise 0004 % 0005 % Usage: avw = avw_binary(avw,thresh) 0006 % 0007 % avw is the Analyze volume returned by avw_read 0008 % thresh is the threshold intensity value (default = 0) 0009 % 0010 0011 0012 if ~exist('thresh','var'), thresh = 0; end 0013 if isempty(thresh), thresh = 0; end 0014 0015 fprintf('...binarising volume at %g threshold...',thresh); tic; 0016 Vindex = find(avw.img <= thresh); 0017 avw.img(Vindex) = 0; 0018 Vindex = find(avw.img); 0019 avw.img(Vindex) = 1; 0020 t = toc; fprintf('done (%5.2f sec)\n',t); 0021 0022 return