| Home | Trees | Indices | Help |
|---|
|
|
1 # PyCV - A Computer Vision Package for Python Incorporating Fast Training of Face Detection 2 3 # Copyright 2007 Nanyang Technological University, Singapore. 4 # Authors: Minh-Tri Pham, Viet-Dung D. Hoang, and Tat-Jen Cham. 5 6 # This file is part of PyCV. 7 8 # PyCV is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU General Public 10 # License as published by the Free Software Foundation, either version 11 # 3 of the License, or (at your option) any later version. 12 13 # PyCV is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 18 # You should have received a copy of the GNU General Public License 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 21 # --------------------------------------------------------------------- 22 #!/usr/bin/env python 23 24 25 __all__ = ['argsort','argsort_and_cut'] 26 27 from numpy import zeros, arange, array 28 29 from pycv import ext 3032 """Take a 1D array of type '[u]int<8|16|32|64>' or 'float<32|64>', and return a 1D array of indices that sorts the former in ascending order. 33 """ 34 if a.ndim != 1: 35 raise TypeError("Input a is not 1D") 36 37 id = zeros(len(a),'int') 38 39 try: 40 eval('ext.dm_argsort_'+a.dtype.name+'(a, id)') 41 except KeyError: 42 raise TypeError("Input has an unknown dtype") 43 44 return id4547 """Find argsort and 'list of cuts' of a 1D 'double' array 48 49 Input: 50 a: a 1D 'double' array 51 Output: 52 id: an index array that sorts a in ascending orders 53 B: an array of thresholds that cuts a properly 54 """ 55 if a.ndim != 1: 56 raise TypeError("Input a is not 1D") 57 if a.dtype.name != 'float64': 58 raise TypeError("dtype of a is not 'float64'") 59 60 bid = argsort(a) 61 B = zeros(len(a)+1) 62 63 n = ext.dm_argsort_and_cut(a, bid, B) 64 65 return (bid,B[:n])66
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Mon Feb 25 10:24:20 2008 | http://epydoc.sourceforge.net |