threshold_vector - performs a threshold on a vector Usage: passed = threshold_vector(data, threshold, type) Takes an N by 1 or 1 by N vector and thresholds the values based on threshold. Returns the indices of the elements that pass the threshold. "type" is one of '-signed' or '-unsigned'. This function is part of froi, available from http://froi.sourceforge.net, and is governed by the terms of the Artistic License. $Id: threshold_vector.m,v 1.3 2003/09/23 15:38:19 nknouf Exp $
This function calls:
This function is called by:
0001 function passed = threshold_vector(data, threshold, type) 0002 % threshold_vector - performs a threshold on a vector 0003 % 0004 % Usage: passed = threshold_vector(data, threshold, type) 0005 % 0006 % Takes an N by 1 or 1 by N vector and thresholds the values based on 0007 % threshold. Returns the indices of the elements that pass the threshold. 0008 % "type" is one of '-signed' or '-unsigned'. 0009 % 0010 % This function is part of froi, available from http://froi.sourceforge.net, 0011 % and is governed by the terms of the Artistic License. 0012 % 0013 % $Id: threshold_vector.m,v 1.3 2003/09/23 15:38:19 nknouf Exp $ 0014 0015 passed = []; 0016 0017 if (strncmp(type, '-signed', 7)) 0018 passed = signed_thresh(data, threshold); 0019 elseif (strncmp(type, '-unsigned', 9)) 0020 passed = unsigned_thresh(data, threshold); 0021 end 0022 0023 return; 0024 0025 0026 function passed = signed_thresh(data, threshold) 0027 if (threshold > 0) 0028 passed = find(data>=threshold); 0029 elseif (threshold < 0) 0030 passed = find(data<=threshold); 0031 elseif (threshold == 0) 0032 oops(255); 0033 end 0034 0035 return; 0036 0037 0038 function passed = unsigned_thresh(data, threshold) 0039 passed1 = find(data>=threshold); 0040 passed2 = find(data<=threshold); 0041 0042 passed = [passed1; passed2]; 0043 0044 return;