├── sift_bin ├── maci │ ├── aib │ ├── mser │ ├── sift │ ├── test_gmm │ ├── test_nan │ ├── test_host │ ├── test_imopv │ ├── test_liop │ ├── test_rand │ ├── test_sqrti │ ├── test_svd2 │ ├── libvl.dylib │ ├── test_heap-def │ ├── test_kmeans │ ├── test_mathop │ ├── test_stringop │ ├── test_threads │ ├── test_vec_comp │ ├── test_mathop_abs │ ├── test_qsort-def │ ├── test_getopt_long │ └── test_gauss_elimination ├── glnx86 │ ├── aib │ ├── mser │ ├── sift │ ├── libvl.so │ ├── test_gmm │ ├── test_nan │ ├── test_host │ ├── test_imopv │ ├── test_kmeans │ ├── test_liop │ ├── test_mathop │ ├── test_rand │ ├── test_sqrti │ ├── test_svd2 │ ├── test_heap-def │ ├── test_stringop │ ├── test_threads │ ├── test_vec_comp │ ├── test_getopt_long │ ├── test_mathop_abs │ ├── test_qsort-def │ └── test_gauss_elimination ├── maci64 │ ├── aib │ ├── mser │ ├── sift │ ├── test_gmm │ ├── test_nan │ ├── libvl.dylib │ ├── test_host │ ├── test_imopv │ ├── test_kmeans │ ├── test_liop │ ├── test_mathop │ ├── test_rand │ ├── test_sqrti │ ├── test_svd2 │ ├── test_heap-def │ ├── test_stringop │ ├── test_threads │ ├── test_vec_comp │ ├── test_getopt_long │ ├── test_mathop_abs │ ├── test_qsort-def │ └── test_gauss_elimination ├── glnxa64 │ ├── aib │ ├── mser │ ├── sift │ ├── libvl.so │ ├── test_gmm │ ├── test_host │ ├── test_imopv │ ├── test_liop │ ├── test_nan │ ├── test_rand │ ├── test_sqrti │ ├── test_svd2 │ ├── test_kmeans │ ├── test_mathop │ ├── test_threads │ ├── test_heap-def │ ├── test_mathop_abs │ ├── test_qsort-def │ ├── test_stringop │ ├── test_vec_comp │ ├── test_getopt_long │ └── test_gauss_elimination ├── win32 │ ├── aib.exe │ ├── vl.dll │ ├── vl.lib │ ├── mser.exe │ ├── sift.exe │ ├── msvcr90.dll │ ├── test_gmm.exe │ ├── test_nan.exe │ ├── test_host.exe │ ├── test_imopv.exe │ ├── test_liop.exe │ ├── test_rand.exe │ ├── test_sqrti.exe │ ├── test_svd2.exe │ ├── test_heap-def.exe │ ├── test_kmeans.exe │ ├── test_mathop.exe │ ├── test_stringop.exe │ ├── test_threads.exe │ ├── test_vec_comp.exe │ ├── test_mathop_abs.exe │ ├── test_qsort-def.exe │ ├── test_getopt_long.exe │ ├── test_gauss_elimination.exe │ └── Microsoft.VC90.CRT.manifest └── win64 │ ├── aib.exe │ ├── vl.dll │ ├── vl.exp │ ├── vl.lib │ ├── mser.exe │ ├── sift.exe │ ├── msvcr100.dll │ ├── msvcr90.dll │ ├── test_gmm.exe │ ├── test_nan.exe │ ├── test_host.exe │ ├── test_imopv.exe │ ├── test_liop.exe │ ├── test_rand.exe │ ├── test_sqrti.exe │ ├── test_svd2.exe │ ├── test_heap-def.exe │ ├── test_kmeans.exe │ ├── test_mathop.exe │ ├── test_stringop.exe │ ├── test_threads.exe │ ├── test_vec_comp.exe │ ├── test_mathop_abs.exe │ ├── test_qsort-def.exe │ ├── test_getopt_long.exe │ ├── test_gauss_elimination.exe │ └── test_gauss_elimination.obj ├── gist_bin ├── glnx86 │ └── gist ├── glnxa64 │ └── gist ├── win32 │ ├── 25.pgm │ ├── ar.ppm │ ├── gist.exe │ ├── msvcr100.dll │ ├── msvcr90.dll │ ├── libfftw3-3.dll │ ├── pthreadVC2.dll │ ├── libfftw3f-3.dll │ └── libfftw3l-3.dll └── win64 │ ├── 25.pgm │ ├── ar.ppm │ ├── gist.exe │ ├── msvcr100.dll │ ├── msvcr90.dll │ ├── libfftw3-3.dll │ ├── pthreadVC2.dll │ ├── libfftw3f-3.dll │ ├── libfftw3l-3.dll │ └── 1.txt ├── Metric.py ├── colorhist.py ├── gist.py ├── sift.py ├── FisherVector.py ├── BoVW.py ├── hog.py ├── lbp.py └── VLAD.py /sift_bin/maci/aib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/aib -------------------------------------------------------------------------------- /sift_bin/glnx86/aib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/aib -------------------------------------------------------------------------------- /sift_bin/maci/mser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/mser -------------------------------------------------------------------------------- /sift_bin/maci/sift: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/sift -------------------------------------------------------------------------------- /sift_bin/maci64/aib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/aib -------------------------------------------------------------------------------- /gist_bin/glnx86/gist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/glnx86/gist -------------------------------------------------------------------------------- /gist_bin/glnxa64/gist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/glnxa64/gist -------------------------------------------------------------------------------- /gist_bin/win32/25.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/25.pgm -------------------------------------------------------------------------------- /gist_bin/win32/ar.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/ar.ppm -------------------------------------------------------------------------------- /gist_bin/win64/25.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/25.pgm -------------------------------------------------------------------------------- /gist_bin/win64/ar.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/ar.ppm -------------------------------------------------------------------------------- /sift_bin/glnx86/mser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/mser -------------------------------------------------------------------------------- /sift_bin/glnx86/sift: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/sift -------------------------------------------------------------------------------- /sift_bin/glnxa64/aib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/aib -------------------------------------------------------------------------------- /sift_bin/glnxa64/mser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/mser -------------------------------------------------------------------------------- /sift_bin/glnxa64/sift: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/sift -------------------------------------------------------------------------------- /sift_bin/maci/test_gmm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_gmm -------------------------------------------------------------------------------- /sift_bin/maci/test_nan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_nan -------------------------------------------------------------------------------- /sift_bin/maci64/mser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/mser -------------------------------------------------------------------------------- /sift_bin/maci64/sift: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/sift -------------------------------------------------------------------------------- /sift_bin/win32/aib.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/aib.exe -------------------------------------------------------------------------------- /sift_bin/win32/vl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/vl.dll -------------------------------------------------------------------------------- /sift_bin/win32/vl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/vl.lib -------------------------------------------------------------------------------- /sift_bin/win64/aib.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/aib.exe -------------------------------------------------------------------------------- /sift_bin/win64/vl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/vl.dll -------------------------------------------------------------------------------- /sift_bin/win64/vl.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/vl.exp -------------------------------------------------------------------------------- /sift_bin/win64/vl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/vl.lib -------------------------------------------------------------------------------- /gist_bin/win32/gist.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/gist.exe -------------------------------------------------------------------------------- /gist_bin/win64/gist.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/gist.exe -------------------------------------------------------------------------------- /sift_bin/glnx86/libvl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/libvl.so -------------------------------------------------------------------------------- /sift_bin/glnx86/test_gmm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_gmm -------------------------------------------------------------------------------- /sift_bin/glnx86/test_nan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_nan -------------------------------------------------------------------------------- /sift_bin/maci/test_host: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_host -------------------------------------------------------------------------------- /sift_bin/maci/test_imopv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_imopv -------------------------------------------------------------------------------- /sift_bin/maci/test_liop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_liop -------------------------------------------------------------------------------- /sift_bin/maci/test_rand: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_rand -------------------------------------------------------------------------------- /sift_bin/maci/test_sqrti: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_sqrti -------------------------------------------------------------------------------- /sift_bin/maci/test_svd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_svd2 -------------------------------------------------------------------------------- /sift_bin/maci64/test_gmm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_gmm -------------------------------------------------------------------------------- /sift_bin/maci64/test_nan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_nan -------------------------------------------------------------------------------- /sift_bin/win32/mser.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/mser.exe -------------------------------------------------------------------------------- /sift_bin/win32/sift.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/sift.exe -------------------------------------------------------------------------------- /sift_bin/win64/mser.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/mser.exe -------------------------------------------------------------------------------- /sift_bin/win64/sift.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/sift.exe -------------------------------------------------------------------------------- /gist_bin/win32/msvcr100.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/msvcr100.dll -------------------------------------------------------------------------------- /gist_bin/win32/msvcr90.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/msvcr90.dll -------------------------------------------------------------------------------- /gist_bin/win64/msvcr100.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/msvcr100.dll -------------------------------------------------------------------------------- /gist_bin/win64/msvcr90.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/msvcr90.dll -------------------------------------------------------------------------------- /sift_bin/glnx86/test_host: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_host -------------------------------------------------------------------------------- /sift_bin/glnx86/test_imopv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_imopv -------------------------------------------------------------------------------- /sift_bin/glnx86/test_kmeans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_kmeans -------------------------------------------------------------------------------- /sift_bin/glnx86/test_liop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_liop -------------------------------------------------------------------------------- /sift_bin/glnx86/test_mathop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_mathop -------------------------------------------------------------------------------- /sift_bin/glnx86/test_rand: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_rand -------------------------------------------------------------------------------- /sift_bin/glnx86/test_sqrti: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_sqrti -------------------------------------------------------------------------------- /sift_bin/glnx86/test_svd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_svd2 -------------------------------------------------------------------------------- /sift_bin/glnxa64/libvl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/libvl.so -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_gmm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_gmm -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_host: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_host -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_imopv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_imopv -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_liop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_liop -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_nan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_nan -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_rand: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_rand -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_sqrti: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_sqrti -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_svd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_svd2 -------------------------------------------------------------------------------- /sift_bin/maci/libvl.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/libvl.dylib -------------------------------------------------------------------------------- /sift_bin/maci/test_heap-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_heap-def -------------------------------------------------------------------------------- /sift_bin/maci/test_kmeans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_kmeans -------------------------------------------------------------------------------- /sift_bin/maci/test_mathop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_mathop -------------------------------------------------------------------------------- /sift_bin/maci/test_stringop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_stringop -------------------------------------------------------------------------------- /sift_bin/maci/test_threads: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_threads -------------------------------------------------------------------------------- /sift_bin/maci/test_vec_comp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_vec_comp -------------------------------------------------------------------------------- /sift_bin/maci64/libvl.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/libvl.dylib -------------------------------------------------------------------------------- /sift_bin/maci64/test_host: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_host -------------------------------------------------------------------------------- /sift_bin/maci64/test_imopv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_imopv -------------------------------------------------------------------------------- /sift_bin/maci64/test_kmeans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_kmeans -------------------------------------------------------------------------------- /sift_bin/maci64/test_liop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_liop -------------------------------------------------------------------------------- /sift_bin/maci64/test_mathop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_mathop -------------------------------------------------------------------------------- /sift_bin/maci64/test_rand: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_rand -------------------------------------------------------------------------------- /sift_bin/maci64/test_sqrti: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_sqrti -------------------------------------------------------------------------------- /sift_bin/maci64/test_svd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_svd2 -------------------------------------------------------------------------------- /sift_bin/win32/msvcr90.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/msvcr90.dll -------------------------------------------------------------------------------- /sift_bin/win32/test_gmm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_gmm.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_nan.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_nan.exe -------------------------------------------------------------------------------- /sift_bin/win64/msvcr100.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/msvcr100.dll -------------------------------------------------------------------------------- /sift_bin/win64/msvcr90.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/msvcr90.dll -------------------------------------------------------------------------------- /sift_bin/win64/test_gmm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_gmm.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_nan.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_nan.exe -------------------------------------------------------------------------------- /gist_bin/win32/libfftw3-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/libfftw3-3.dll -------------------------------------------------------------------------------- /gist_bin/win32/pthreadVC2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/pthreadVC2.dll -------------------------------------------------------------------------------- /gist_bin/win64/libfftw3-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/libfftw3-3.dll -------------------------------------------------------------------------------- /gist_bin/win64/pthreadVC2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/pthreadVC2.dll -------------------------------------------------------------------------------- /sift_bin/glnx86/test_heap-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_heap-def -------------------------------------------------------------------------------- /sift_bin/glnx86/test_stringop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_stringop -------------------------------------------------------------------------------- /sift_bin/glnx86/test_threads: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_threads -------------------------------------------------------------------------------- /sift_bin/glnx86/test_vec_comp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_vec_comp -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_kmeans: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_kmeans -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_mathop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_mathop -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_threads: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_threads -------------------------------------------------------------------------------- /sift_bin/maci/test_mathop_abs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_mathop_abs -------------------------------------------------------------------------------- /sift_bin/maci/test_qsort-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_qsort-def -------------------------------------------------------------------------------- /sift_bin/maci64/test_heap-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_heap-def -------------------------------------------------------------------------------- /sift_bin/maci64/test_stringop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_stringop -------------------------------------------------------------------------------- /sift_bin/maci64/test_threads: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_threads -------------------------------------------------------------------------------- /sift_bin/maci64/test_vec_comp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_vec_comp -------------------------------------------------------------------------------- /sift_bin/win32/test_host.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_host.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_imopv.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_imopv.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_liop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_liop.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_rand.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_rand.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_sqrti.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_sqrti.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_svd2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_svd2.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_host.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_host.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_imopv.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_imopv.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_liop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_liop.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_rand.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_rand.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_sqrti.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_sqrti.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_svd2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_svd2.exe -------------------------------------------------------------------------------- /gist_bin/win32/libfftw3f-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/libfftw3f-3.dll -------------------------------------------------------------------------------- /gist_bin/win32/libfftw3l-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win32/libfftw3l-3.dll -------------------------------------------------------------------------------- /gist_bin/win64/libfftw3f-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/libfftw3f-3.dll -------------------------------------------------------------------------------- /gist_bin/win64/libfftw3l-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/gist_bin/win64/libfftw3l-3.dll -------------------------------------------------------------------------------- /sift_bin/glnx86/test_getopt_long: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_getopt_long -------------------------------------------------------------------------------- /sift_bin/glnx86/test_mathop_abs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_mathop_abs -------------------------------------------------------------------------------- /sift_bin/glnx86/test_qsort-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_qsort-def -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_heap-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_heap-def -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_mathop_abs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_mathop_abs -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_qsort-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_qsort-def -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_stringop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_stringop -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_vec_comp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_vec_comp -------------------------------------------------------------------------------- /sift_bin/maci/test_getopt_long: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_getopt_long -------------------------------------------------------------------------------- /sift_bin/maci64/test_getopt_long: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_getopt_long -------------------------------------------------------------------------------- /sift_bin/maci64/test_mathop_abs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_mathop_abs -------------------------------------------------------------------------------- /sift_bin/maci64/test_qsort-def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_qsort-def -------------------------------------------------------------------------------- /sift_bin/win32/test_heap-def.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_heap-def.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_kmeans.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_kmeans.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_mathop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_mathop.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_stringop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_stringop.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_threads.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_threads.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_vec_comp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_vec_comp.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_heap-def.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_heap-def.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_kmeans.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_kmeans.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_mathop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_mathop.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_stringop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_stringop.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_threads.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_threads.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_vec_comp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_vec_comp.exe -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_getopt_long: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_getopt_long -------------------------------------------------------------------------------- /sift_bin/win32/test_mathop_abs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_mathop_abs.exe -------------------------------------------------------------------------------- /sift_bin/win32/test_qsort-def.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_qsort-def.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_mathop_abs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_mathop_abs.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_qsort-def.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_qsort-def.exe -------------------------------------------------------------------------------- /sift_bin/maci/test_gauss_elimination: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci/test_gauss_elimination -------------------------------------------------------------------------------- /sift_bin/win32/test_getopt_long.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_getopt_long.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_getopt_long.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_getopt_long.exe -------------------------------------------------------------------------------- /sift_bin/glnx86/test_gauss_elimination: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnx86/test_gauss_elimination -------------------------------------------------------------------------------- /sift_bin/glnxa64/test_gauss_elimination: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/glnxa64/test_gauss_elimination -------------------------------------------------------------------------------- /sift_bin/maci64/test_gauss_elimination: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/maci64/test_gauss_elimination -------------------------------------------------------------------------------- /sift_bin/win32/test_gauss_elimination.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win32/test_gauss_elimination.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_gauss_elimination.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_gauss_elimination.exe -------------------------------------------------------------------------------- /sift_bin/win64/test_gauss_elimination.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeromewang-github/computer_vision/HEAD/sift_bin/win64/test_gauss_elimination.obj -------------------------------------------------------------------------------- /sift_bin/win32/Microsoft.VC90.CRT.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Metric.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/python3 2 | #enconding=uft-8 3 | """ 4 | Metric fucntions 5 | @author: jerome 6 | @E-mail: yunfeiwang@hust.edu.cn 7 | """ 8 | import numpy as np 9 | 10 | 11 | def distEuclidean(vecA,vecB): 12 | ''' 13 | calculate Euclidean distance between two vectors or two data matrix 14 | ''' 15 | return np.sqrt(np.sum((vecA-vecB)**2)) 16 | 17 | 18 | def distCosine(vecA,vecB): 19 | ''' 20 | calculate Cosine distance between two vectors 21 | ''' 22 | return np.inner(vecA,vecB)/np.sqrt(np.inner(vecA,vecA)*np.inner(vecB,vecB)) 23 | 24 | 25 | def distPearson(vecA,vecB): 26 | ''' 27 | Pearson correlation 28 | ''' 29 | N=len(vecA) 30 | meanA=np.mean(vecA) 31 | meanB=np.mean(vecB) 32 | devA=np.sqrt(np.sum((vecA-meanA)**2)/(N-1)) #standard deviation of vecA 33 | devB=np.sqrt(np.sum((vecB-meanB)**2)/(N-1)) 34 | return (np.inner(vecA,vecB)-N*meanA*meanB)/((N-1)*devA*devB) 35 | 36 | if __name__=='__main__': 37 | vecA=np.random.random_sample((10,)) 38 | vecB=np.random.random_sample((10,)) 39 | Eucdist=distEuclidean(vecA,vecB) 40 | Cosdist=distCosine(vecA,vecB) 41 | Peadist=distPearson(vecA,vecB) 42 | print('Euc:',Eucdist,'Cos:',Cosdist,'Pea:',Peadist) 43 | -------------------------------------------------------------------------------- /colorhist.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import numpy as np 3 | 4 | def colorHistogram(img,nRange=4,window_sz=(5,5)): 5 | img=np.atleast_2d(img) 6 | if img.ndim!=3: 7 | raise ValueError('Currently only supports RGB images') 8 | row,col,_=img.shape 9 | dim=nRange**3 10 | base=256/nRange 11 | num_wx,num_wy=window_sz 12 | sz_x=row//num_wx 13 | sz_y=col//num_wy 14 | nElem_per_win=sz_x*sz_y 15 | res=np.zeros((num_wx,num_wy,dim)) 16 | for w_rid in range(num_wx): 17 | for w_cid in range(num_wy): 18 | start_x=w_rid*sz_x 19 | end_x=start_x+sz_x 20 | start_y=w_cid*sz_y 21 | end_y=start_y+sz_y 22 | window=img[start_x:end_x,start_y:end_y,:] 23 | for p_rid in range(sz_x): 24 | for p_cid in range(sz_y): 25 | val=window[p_rid,p_cid] 26 | #x=int(val[0]/base) 27 | #y=int(val[1]/base) 28 | #z=int(val[2]/base) 29 | x,y,z=map(lambda x:int(x/base),val) 30 | index=x*nRange*nRange+y*nRange+z 31 | res[w_rid,w_cid,index]+=1 32 | res[w_rid,w_cid]/=nElem_per_win 33 | return res.flatten() 34 | -------------------------------------------------------------------------------- /gist.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import os,platform,subprocess 3 | from PIL import Image 4 | import numpy as np 5 | 6 | def getSystemInfo(): 7 | sys_str=platform.system() 8 | arch_str=platform.architecture()[0] 9 | return sys_str+'_'+arch_str 10 | 11 | def GISTFeatures(filename,params='-nblocks 4 -orientationsPerScale 8,8,4',tmpfile='gist_tmp.ppm'): 12 | if not os.path.exists(filename): 13 | raise ValueError('File %s does not exists!' %filename) 14 | pos=filename.rfind('/') 15 | print(filename[pos+1:]) 16 | if filename[-3:] not in ('ppm','pgm'): 17 | im=Image.open(filename) 18 | im.save(tmpfile) 19 | tmpfilename=os.path.abspath(tmpfile) 20 | tmpfilename=tmpfilename.replace('\\','/') 21 | workdir=os.path.abspath('.') 22 | 23 | sysinfo=getSystemInfo().lower() 24 | gist_path='.' 25 | gist_exe='gist' 26 | if sysinfo=='windows_64bit': 27 | gist_path='gist_bin/win64' 28 | elif sysinfo=='windwos_32bit': 29 | gist_path='gist_bin/win32' 30 | elif sysinfo=='linux_64bit': 31 | gist_path='gist_bin/glnxa64' 32 | elif sysinfo=='linux_32bit': 33 | gist_path='gist_bin/glnx32' 34 | else: 35 | raise ValueError('Unknown platform %s' %sysinfo) 36 | 37 | os.chdir(gist_path) 38 | cmd_str=' '.join([gist_exe,params,tmpfilename]) 39 | res_str=subprocess.check_output(cmd_str.split()) 40 | gist_fea=np.asarray(res_str.split()).astype('float') 41 | os.chdir(workdir) 42 | return gist_fea 43 | 44 | if __name__=='__main__': 45 | filename='bird.jpg' 46 | gist_fea=GISTFeatures(filename) 47 | print(gist_fea) 48 | print(len(gist_fea)) -------------------------------------------------------------------------------- /gist_bin/win64/1.txt: -------------------------------------------------------------------------------- 1 | 0.1489 0.1532 0.1404 0.1507 0.1538 0.1537 0.1520 0.1369 0.1406 0.1312 0.1440 0.1235 0.1298 0.1347 0.1269 0.1390 0.0960 0.0977 0.0919 0.0924 0.0984 0.1078 0.1069 0.0855 0.0856 0.0946 0.1082 0.0897 0.0915 0.0866 0.0882 0.1023 0.0972 0.1002 0.0954 0.0910 0.1020 0.1111 0.1096 0.0964 0.1002 0.1033 0.1090 0.0926 0.0915 0.0932 0.0993 0.0898 0.1148 0.1283 0.1143 0.1018 0.1081 0.1284 0.1201 0.1131 0.1177 0.1134 0.1188 0.1137 0.1198 0.1186 0.1059 0.1056 0.1280 0.1393 0.1138 0.1177 0.1261 0.1313 0.1231 0.1352 0.1428 0.1155 0.1257 0.1261 0.1434 0.1183 0.1133 0.1183 0.0968 0.0983 0.0909 0.0953 0.1025 0.0999 0.0999 0.0972 0.0964 0.0931 0.0941 0.0854 0.0874 0.0887 0.0926 0.0853 0.1145 0.1138 0.1041 0.1055 0.1232 0.1236 0.1165 0.1054 0.1149 0.1136 0.1080 0.0998 0.1053 0.1070 0.1050 0.0932 0.1010 0.1045 0.0979 0.1125 0.1128 0.1143 0.1082 0.0986 0.1045 0.1020 0.1118 0.0842 0.0887 0.1010 0.1037 0.0952 0.1933 0.2045 0.2249 0.1838 0.1840 0.2179 0.2261 0.1895 0.1537 0.2036 0.1983 0.1877 0.1518 0.1885 0.2032 0.1877 0.1354 0.1258 0.1193 0.1036 0.1126 0.1374 0.1352 0.1044 0.0986 0.1134 0.1331 0.1126 0.1038 0.1019 0.1130 0.1296 0.1128 0.1117 0.1122 0.1095 0.1121 0.1174 0.1210 0.1027 0.1086 0.1085 0.1206 0.1001 0.1045 0.1045 0.1139 0.1077 0.1444 0.1555 0.1653 0.1610 0.1470 0.1651 0.1678 0.1595 0.1417 0.1534 0.1662 0.1389 0.1312 0.1395 0.1704 0.1470 0.1562 0.1855 0.2148 0.2090 0.1715 0.2100 0.2331 0.2078 0.1568 0.1994 0.2288 0.1826 0.1382 0.1548 0.2423 0.1788 0.1104 0.1323 0.1444 0.1349 0.1257 0.1422 0.1509 0.1318 0.1172 0.1385 0.1487 0.1181 0.1058 0.1242 0.1533 0.1186 0.1157 0.1274 0.1126 0.1035 0.1225 0.1334 0.1246 0.1048 0.1140 0.1204 0.1245 0.1030 0.1156 0.1136 0.1144 0.1045 0.1338 0.1526 0.1095 0.1039 0.1176 0.1578 0.1481 0.1185 0.1243 0.1053 0.1581 0.1339 0.1501 0.1148 0.1088 0.1374 0.2879 0.2836 0.3214 0.2792 0.2760 0.3140 0.3135 0.2905 0.2402 0.2884 0.2873 0.2827 0.2405 0.2509 0.2984 0.2753 0.2020 0.1892 0.1683 0.1643 0.1651 0.2154 0.1993 0.1550 0.1400 0.1604 0.2041 0.1766 0.1711 0.1429 0.1721 0.1962 0.1831 0.1798 0.1825 0.1715 0.1818 0.1875 0.1928 0.1599 0.1737 0.1721 0.1932 0.1599 0.1742 0.1699 0.1843 0.1703 0.2176 0.2273 0.2541 0.2498 0.2318 0.2370 0.2494 0.2413 0.2201 0.2332 0.2464 0.2033 0.2007 0.2119 0.2649 0.2139 0.2757 0.3090 0.3716 0.3520 0.3026 0.3480 0.3800 0.3493 0.2645 0.3310 0.3649 0.3018 0.2576 0.2532 0.4091 0.2777 0.1899 0.2073 0.2350 0.2225 0.2122 0.2261 0.2397 0.2125 0.1983 0.2222 0.2401 0.1971 0.1835 0.2009 0.2467 0.1947 0.1865 0.1900 0.1782 0.1754 0.1971 0.2104 0.1897 0.1679 0.1747 0.1885 0.2005 0.1714 0.1885 0.1733 0.1863 0.1745 0.2095 0.2078 0.1570 0.1648 0.1870 0.2528 0.2104 0.1658 0.1630 0.1706 0.2452 0.2026 0.2205 0.1591 0.1788 0.2146 2 | -------------------------------------------------------------------------------- /sift.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import os,platform,subprocess 3 | import numpy as np 4 | from PIL import Image 5 | from matplotlib import pyplot as plt 6 | 7 | 8 | def getSystemInfo(): 9 | sys_str=platform.system() 10 | arch_str=platform.architecture()[0] 11 | return sys_str+'_'+arch_str 12 | 13 | 14 | def SIFTFeatures(filename,outfile,params='--edge-thresh 10 --peak-thresh 5'): 15 | if not os.path.exists(filename): 16 | raise ValueError('File %s does not exists!' %filename) 17 | if filename[-3:]!='pgm':#must use the image in pgm format 18 | img=Image.open(filename).convert('L') 19 | img.save('tmp.pgm') 20 | tmpfilename=os.path.abspath('tmp.pgm') 21 | workdir=os.path.abspath('.') 22 | siftdir='.' 23 | sysinfo=getSystemInfo().lower() 24 | exe_str='sift' 25 | if sysinfo=='windows_64bit': 26 | siftdir='sift_bin/win64' 27 | elif sysinfo=='windows_32bit': 28 | siftdir='sift_bin/win32' 29 | elif sysinfo=='linux_64bit': 30 | siftdir='sift_bin/glnxa64' 31 | elif sysinfo=='linux_32bit': 32 | siftdir='sift_bin/glnx86' 33 | elif sysinfo=='darwin_64bit': 34 | siftdir='sift_bin/maci64' 35 | elif sysinfo=='darwin_32bit': 36 | siftdir='sift_bin/maci' 37 | else: 38 | raise ValueError('Unknown platform %s' %sysinfo) 39 | os.chdir(siftdir) 40 | call_cmd=str(exe_str+' '+tmpfilename+' --output='+outfile+' '+params) 41 | #os.system(call_cmd) 42 | subprocess.call(call_cmd) 43 | sift_fea=np.genfromtxt(outfile,dtype=np.float) 44 | location=sift_fea[:,:4] #(row,col,scale,orientation of each feature 45 | sift=sift_fea[:,4:] 46 | pos=filename.rfind(r'/') 47 | print(filename[pos+1:]) 48 | os.chdir(workdir) 49 | return sift,location 50 | 51 | 52 | def plot_features(img,locs,circle=False): 53 | """ 54 | Show image with features. 55 | locs:row,col,scale,orientation of each feature 56 | """ 57 | def draw_circle(pos,radius): 58 | t=np.arange(0,1.01,.01)*2*np.pi 59 | x=radius*np.cos(t)+pos[0] 60 | y=radius*np.sin(t)+pos[1] 61 | plt.plot(x,y,'b',linewidth=2) 62 | 63 | plt.figure() 64 | plt.gray() 65 | plt.imshow(img) 66 | if circle: 67 | for p in locs: 68 | draw_circle(p[:2],p[2]) 69 | else: 70 | plt.plot(locs[:,0],locs[:,1],'ob') 71 | plt.axis('off') 72 | plt.show() 73 | 74 | 75 | if __name__=='__main__': 76 | filename='25.jpg' 77 | img=Image.open(filename) 78 | img=img.convert('L') 79 | im=np.array(img) 80 | fea,locs=SIFTFeatures(filename,'tmp') 81 | plot_features(im,locs,False) 82 | -------------------------------------------------------------------------------- /FisherVector.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #encoding=utf-8 3 | ''' 4 | The Fisher Vector(FV) is an extension of the BOV representation, obtained by 5 | pooling local image features.It is frequently used as a global image descriptor 6 | in visual classification. Instead of characterizing an image by the number of 7 | occurrences of each visual word, it is characterized by a gradient vector derived 8 | from a generative probabilistic model(Gaussian Mixture Model). The gradient of the 9 | log-likelihood describes the contribution of the parameters to the generation process. 10 | @author: jerome 11 | @Constact:yunfeiwang@hust.edu.cn 12 | ''' 13 | 14 | import numpy as np 15 | from sklearn import mixture 16 | 17 | EPS=np.finfo(float).eps 18 | 19 | def FVFeatures(dataLearn,dataEncode,nClus,normalize=0): 20 | ''' 21 | Extracting Fisher vector descriptors for given data. 22 | FVFeatures(dataLearn,dataEncode,nClus,distfun=distEuclidean,normalize=0) 23 | @Parameters: 24 | dataLearn: n*dim ndarray,used to train a GMM model 25 | dataEncode: m*dim ndarray,data to be encoded 26 | nClus: number of cluster centers in GMM 27 | normalize: normalization strategy 28 | 0-Power normalization. 29 | Applying the function sqrt(|z|)signz to each dimension of the vector Φ(I). 30 | Other additive kernels can also be used at an increased space or time cost. 31 | 1-L2 Normalization. 32 | Before using the representation in a linear model (e.g. SVM), the vector Φ(I) is 33 | further normalized by the l2 norm (note that the standard Fisher 34 | vector is normalized by the number of encoded feature vectors). 35 | ''' 36 | print('Clustering for visual word dictionary..') 37 | gmm=FV_trainGMM(dataLearn,nClus) 38 | print('Generating Fisher Vector features...') 39 | fv_desc=FVEncoding(dataEncode, gmm, normalize) 40 | return fv_desc 41 | 42 | 43 | def FV_trainGMM(dataLearn,nClus): 44 | #1.model dictionary of visual words with GMM 45 | gmm=mixture.GMM(n_components=nClus) 46 | gmm.fit(dataLearn) 47 | return gmm 48 | 49 | def FVEncoding(dataEncode,gmm,normalize=0): 50 | ''' 51 | Encoding the given data with fisher vector descriptors. 52 | FVEncoding(dataEncode,Phi,Mu,Sigma,distfun=distEuclidean,normalize=0) 53 | @Parameters: 54 | dataEncode: m*dim ndarray,data to be encoded 55 | gmm: Gaussian Mixture Model trained 56 | normalize: normalization strategy 57 | 0-Power normalization. 58 | Applying the function sqrt(|z|)signz to each dimension of the vector Φ(I). 59 | Other additive kernels can also be used at an increased space or time cost. 60 | 1-Normalization. 61 | Before using the representation in a linear model (e.g. SVM), the vector Φ(I) is 62 | further normalized by the l2 norm (note that the standard Fisher 63 | vector is normalized by the number of encoded feature vectors). 64 | ''' 65 | if normalize not in (0,1): 66 | raise ValueError('Invalid normalization option') 67 | 68 | if dataEncode.ndim==1: 69 | dataEncode=dataEncode[:,np.newaxis] 70 | nSmp,nDim=dataEncode.shape 71 | Phi,Mu,Sigma=gmm.weights_, gmm.means_, gmm.covars_ 72 | nClus=len(Phi) 73 | prob=np.empty((nSmp,nClus)) 74 | for i in range(nClus): 75 | prob[:,i]=-0.5*(np.sum((dataEncode**2)/Sigma[i],axis=1) 76 | +np.sum((Mu[i]**2)/Sigma[i]) 77 | -2*np.sum(dataEncode*Mu[i]/Sigma[i],axis=1) 78 | +nDim*np.log(2*np.pi)+np.sum(np.log(Sigma[i]))) 79 | 80 | prob+=np.log(Phi) 81 | prob=np.exp(prob) 82 | for i in range(nSmp): 83 | prob[i]/=np.sum(prob[i]) 84 | 85 | fv_desc=np.empty((nDim,2*nClus)) 86 | for i in range(nClus): 87 | t=((dataEncode-Mu[i])/Sigma[i]).T 88 | fv_desc[:,2*i]=np.sum(t*prob[:,i],axis=1)/(nSmp*np.sqrt(Phi[i])) 89 | fv_desc[:,2*i+1]=np.sum((t**2-1)*prob[:,i],axis=1)/(nSmp*np.sqrt(2*Phi[i])) 90 | 91 | fv_desc=fv_desc.flatten() 92 | 93 | if normalize==0: 94 | fv_desc=np.sign(fv_desc)*np.sqrt(np.abs(fv_desc)) 95 | elif normalize==1: 96 | fv_desc/=np.sum(fv_desc**2) 97 | return fv_desc 98 | 99 | 100 | if __name__=='__main__': 101 | nSmp=1000 102 | nDim=3 103 | dataLearn=np.random.rand(nSmp,nDim) 104 | fv=FVFeatures(dataLearn, dataLearn,3,1) 105 | print(fv) 106 | -------------------------------------------------------------------------------- /BoVW.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #encoding=utf-8 3 | ''' 4 | Bag of visual words (BoVW) is a popular technique for image classification 5 | inspired by models used in natural language processing. BoVW downplays word 6 | arrangement (spatial information in the image) and classifies based on a histogram 7 | of the frequency of visual words. The set of visual words forms a visual vocabulary, 8 | which is constructed by clustering a large corpus of features. 9 | 10 | @author: jerome 11 | @Constact:yunfeiwang@hust.edu.cn 12 | ''' 13 | 14 | import numpy as np 15 | from Metric import distEuclidean 16 | from sklearn import mixture 17 | from sklearn.cluster import KMeans,MiniBatchKMeans 18 | 19 | 20 | def BoVWFeatures(dataLearn,dataEncode,nClus,method='kMeans',encode='hard',distfun=distEuclidean): 21 | ''' 22 | BoVWFeatures(dataLearn,dataEncode,nClus,encode='hard',distfun=distEuclidean) 23 | @Parameters: 24 | dataLearn: nSmp*nDim ndarray, low level features 25 | dataEncode: N*nDim ndarray, low level features to be encoded 26 | nClus: int, number of word in the visual dictionary 27 | encode: string 'soft' or 'hard',the way used to encode the faetures 28 | distfun: metric used to compute distance.(distEuclidean or distCosine) 29 | @Return: 30 | ndarray of size (nClus,) 31 | ''' 32 | #1.Visual vocabulary construction 33 | print('Clustering for visual word dictionary...') 34 | centers=BoVWDictionary(dataLearn, nClus, method, distfun) 35 | 36 | #2. Extract the BoVW representation for an image 37 | print('Generating BoVW features...') 38 | desc=BoVWEncoding(dataEncode, centers, encode, distfun) 39 | return desc 40 | 41 | 42 | def BoVWDictionary(dataLearn,nClus,method='kMeans',distfun=distEuclidean): 43 | ''' 44 | BoVWDictionary(dataLearn,nClus,distfun=distEuclidean) 45 | @Parameters: 46 | dataLearn: nSmp*nDim ndarray, low level features 47 | nClus: int, number of word in the visual dictionary 48 | distfun: metric used to compute distance.(distEuclidean or distCosine) 49 | @Return: 50 | ndarray of size (nClus,nDim) 51 | ''' 52 | #Visual vocabulary construction 53 | method=str.lower(method) 54 | if method not in ('kmeans','gmm'): 55 | raise ValueError('Invalid method for constructing visual dictionary') 56 | 57 | if method=='kmeans': 58 | nSmp=dataLearn.shape[0] 59 | if nSmp<3e4: 60 | km=KMeans(n_clusters=nClus,init='k-means++',n_init=3,n_jobs=-1)#use all the cpus 61 | else: 62 | km=MiniBatchKMeans(n_clusters=nClus,init='k-means++',n_init=3) 63 | km.fit(dataLearn) 64 | centers=km.cluster_centers_ 65 | else: 66 | gmm=mixture.GMM(n_components=nClus) 67 | gmm.fit(dataLearn) 68 | centers=gmm.means_ 69 | return centers 70 | 71 | 72 | def BoVWEncoding(dataEncode,centers,encode='hard',distfun=distEuclidean): 73 | ''' 74 | BoVWEncoding(dataEncode,centers,encode='hard',distfun=distEuclidean) 75 | Extract the BoVW representation for an image 76 | @Parameters: 77 | dataEncode: N*nDim ndarray, low level features to be encoded 78 | centers: nClus*nDim ndarray, clustering centers as the coodbook in the visual dictionary 79 | encode: string 'soft' or 'hard',the way used to encode the faetures 80 | distfun: metric used to compute distance.(distEuclidean or distCosine) 81 | @Return: 82 | ndarray of size (nClus,) 83 | ''' 84 | encode=str.lower(encode) 85 | if encode not in ('soft','hard'): 86 | raise ValueError('Invalid encoding scheme(\'soft\' or \'hard\')') 87 | nClus=centers.shape[0] 88 | desc=np.zeros(nClus) 89 | nSmp=dataEncode.shape[0] 90 | if encode=='hard': 91 | for i in range(nSmp): 92 | # dist_iter=map(lambda x,y:(distfun(dataEncode[i],x),y),centers,range(nSmp)) 93 | # nn=max(dist_iter,key=lambda x:x[0])[1] 94 | dist_iter=map(lambda x:distfun(dataEncode[i],x),centers) 95 | # nn=np.argmin(list(dist_iter)) #this code do the following things 96 | dist=np.Inf 97 | nn=-1 98 | for (cnt,item) in enumerate(dist_iter): 99 | if item2: 8 | raise ValueError('Currently only supports grey-level images') 9 | 10 | if img.dtype.kind=='u':#convert uint image to float 11 | img=img.astype('float') 12 | """ 13 | The first stage applies an optional global image normalisation(sqrt or log) 14 | equalisation that is designed to reduce the influence of illumination 15 | effects. In practice we use gamma (power law) compression, either 16 | computing the square root or the log of each colour channel. 17 | Image texture strength is typically proportional to the local surface 18 | illumination so this compression helps to reduce the effects of local 19 | shadowing and illumination variations. 20 | """ 21 | if normalise: 22 | img=np.sqrt(img) 23 | 24 | """ 25 | The second stage computes first order image gradients with centered operators[-1,0,1] and [-1,0,1]^T. 26 | These capture contour, silhouette and some texture information, while providing 27 | further resistance to illumination variations. The locally dominant 28 | colour channel is used, which provides colour invariance to a large 29 | extent. Variant methods may also include second order image derivatives, 30 | which act as primitive bar detectors - a useful feature for capturing, 31 | e.g. bar like structures in bicycles and limbs in humans. 32 | """ 33 | row,col=img.shape#size of the image 34 | conx_data=np.zeros((row,col)) 35 | cony_data=np.zeros((row,col)) 36 | for cid in range(1,col-1):#horizonal gradient with operator [-1,0,1] 37 | conx_data[:,cid]=img[:,cid+1]-img[:,cid-1] 38 | for rid in range(1,row-1):#vertical gradient with operator [-1,0,1]^T 39 | cony_data[rid,:]=img[rid+1,:]-img[rid-1,:] 40 | con_data=np.sqrt(conx_data**2+cony_data**2) #magnitude of gradient 41 | angle_data=np.abs(np.arctan2(cony_data,conx_data))%np.pi#undirected 42 | 43 | ## newImg=Image.new('L',(row,col),0) 44 | ## for rid in range(0,row): 45 | ## for cid in range(0,col): 46 | ## newImg.putpixel((rid,cid),con_data[rid,cid]) 47 | ## newImg.show() 48 | ## newImg.save('test.jpg','JPEG') 49 | 50 | """ 51 | The third stage aims to produce an encoding that is sensitive to 52 | local image content while remaining resistant to small changes in 53 | pose or appearance. The adopted method pools gradient orientation 54 | information locally in the same way as the SIFT [Lowe 2004] 55 | feature. The image window is divided into small spatial regions, 56 | called "cells". For each cell we accumulate a local 1-D histogram 57 | of gradient or edge orientations over all the pixels in the 58 | cell. This combined cell-level 1-D histogram forms the basic 59 | "orientation histogram" representation. Each orientation histogram 60 | divides the gradient angle range into a fixed number of 61 | predetermined bins. The gradient magnitudes of the pixels in the 62 | cell are used to vote into the orientation histogram. 63 | """ 64 | cellsizex,cellsizey=cellSize 65 | blocksizex,blocksizey=blockSize #number of cells a block contains 66 | n_cellx=row//cellsizex #number of cells along x-axis 67 | n_celly=col//cellsizey #number of cells along y-axis 68 | hogWidth=n_celly-blocksizey+1 69 | hogHeight=n_cellx-blocksizex+1 70 | hogFea=np.zeros((hogWidth*hogHeight,blocksizex*blocksizey*numGrad)) 71 | 72 | base=np.pi/numGrad #the width of the range of angle split 73 | angle_index=np.floor(angle_data/base).astype('int') #generate the index for each orientation 74 | 75 | #histgram of gradient for each cell 76 | con_cell_data=np.zeros((n_cellx,n_celly,numGrad)) 77 | for rid in range(n_cellx): 78 | for cid in range(n_celly): 79 | start_x=rid*cellsizex 80 | end_x=start_x+cellsizex 81 | start_y=cid*cellsizey 82 | end_y=start_y+cellsizey 83 | cell_angle_index=angle_index[start_x:end_x,start_y:end_y] 84 | cell_con=con_data[start_x:end_x,start_y:end_y] 85 | for ori_index in range(numGrad): 86 | pos=np.where(cell_angle_index==ori_index,cell_angle_index,-1) 87 | cell_con_filter=np.where(pos>-1,cell_con,0) 88 | con_cell_data[rid,cid,ori_index]=np.sum(cell_con_filter)#sum of all elements 89 | #collect histogram of gradient across cells 90 | blockcnt=0 91 | for block_rid in range(hogHeight): 92 | for block_cid in range(hogWidth): 93 | b_startx=block_rid 94 | b_endx=b_startx+blocksizex 95 | b_starty=block_cid 96 | b_endy=b_starty+blocksizey 97 | block_con=con_cell_data[b_startx:b_endx,b_starty:b_endy,:] 98 | hogFea[blockcnt]=block_con.flatten()#cascade of HoG for the cells in a block 99 | blockcnt+=1 100 | """ 101 | The fourth stage computes normalisation with L2-norm, which takes local groups of 102 | cells and contrast normalises their overall responses before passing 103 | to next stage. Normalisation introduces better invariance to illumination, 104 | shadowing, and edge contrast. It is performed by accumulating a measure 105 | of local histogram "energy" over local groups of cells that we call 106 | "blocks". The result is used to normalise each cell in the block. 107 | Typically each individual cell is shared between several blocks, but 108 | its normalisations are block dependent and thus different. The cell 109 | thus appears several times in the final output vector with different 110 | normalisations. This may seem redundant but it improves the performance. 111 | We refer to the normalised block descriptors as Histogram of Oriented 112 | Gradient (HOG) descriptors. 113 | """ 114 | eps = 1e-5 115 | for rid in range(hogHeight*hogWidth): 116 | denominator = np.sqrt(np.sum(hogFea[rid] ** 2) + eps) 117 | hogFea[rid] = hogFea[rid] / denominator 118 | 119 | return hogFea.flatten() 120 | -------------------------------------------------------------------------------- /lbp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import sys,os 3 | import math 4 | import numpy as np 5 | from PIL import Image 6 | 7 | 8 | def LBPFeatures(img,radius=1,npoints=8,window_size=(3,3),mode='uniform'): 9 | """ 10 | LBPFeatures(img,radius=1,npoints=8,window_size=(3,3),mode='normal') 11 | Extract Local Binary Pattern(LBP) feature for a grey-level image 12 | Parameters 13 | ---------- 14 | image:(M,N) ndarray 15 | input image(greyscale) 16 | radius:float 17 | radius of a circle 18 | npoints:int 19 | number of sampling points on a circle 20 | window_size: 2 tuple(int,int) 21 | number of sampling windows 22 | mode:'normal','uniform','uniform-ror' 23 | 'normal':the original LBP descriptors(2^P patterns) 24 | 'uniform':extention to LBP with uniform patterns(P(P-1)+2 patterns) 25 | 'uniform-ror':extention to LBP with both rotatin invarient and uniform patterns(P+1 patterns) 26 | Returns 27 | --------- 28 | lbp:ndarray 29 | LBP feature for the image as a 1D array 30 | """ 31 | img=np.atleast_2d(img) 32 | if img.ndim>2: 33 | raise ValueError('Currently only supports grey-level images') 34 | if mode not in ('normal','uniform','uniform-ror'): 35 | raise ValueError("Invalid mode for LBP features:'normal','uniform','uniform-ror'") 36 | row,col=img.shape 37 | table=LBP_genHistTable(npoints, mode) 38 | sorted_keys=sorted(table.keys()) 39 | nDim=len(table) #dimensionality of the histogram 40 | w_numx,w_numy=window_size 41 | w_sizex=row//w_numx 42 | w_sizey=col//w_numy 43 | if(w_sizex<2*radius or w_sizey<2*radius): 44 | raise ValueError('Radius is large for the scaning window') 45 | lbp_hist=np.zeros((w_numx,w_numy,nDim)) 46 | 47 | binary_pattern=np.zeros(npoints).astype('int') 48 | coordinate_bias=np.zeros((2,npoints)) 49 | theta=2*math.pi*np.arange(npoints)/npoints 50 | coordinate_bias[0]=-np.sin(theta) 51 | coordinate_bias[1]=np.cos(theta) 52 | coordinate_bias*=radius 53 | 54 | eps=1e-15 55 | val=0 #value for a specific pixel 56 | for w_rid in range(w_numx): 57 | for w_cid in range(w_numy): 58 | w_startx=w_rid*w_sizex 59 | w_endx=w_startx+w_sizex 60 | w_starty=w_cid*w_sizey 61 | w_endy=w_starty+w_sizey 62 | window=img[w_startx:w_endx,w_starty:w_endy] 63 | p_startx=int(np.ceil(radius)) 64 | p_endx=w_sizex-1-p_startx 65 | p_starty=int(np.ceil(radius)) 66 | p_endy=w_sizey-1-p_starty 67 | for p_rid in range(p_startx,p_endx+1): 68 | for p_cid in range(p_starty,p_endy+1): 69 | binary_pattern[:]=0 #clear the binary pattern 70 | for point_id in range(npoints): 71 | new_x=p_rid+coordinate_bias[0,point_id] 72 | new_y=p_cid+coordinate_bias[1,point_id] 73 | 74 | new_x_r=np.round(new_x) 75 | new_y_r=np.round(new_y) 76 | if np.abs(new_x_r-new_x)=window[p_rid,p_cid]: 93 | binary_pattern[point_id]=1 94 | index=-1 95 | if mode=='normal': 96 | index=LBP_binary2int(binary_pattern) 97 | elif LBP_hopCounter(binary_pattern)<=2: 98 | if mode=='uniform-ror': 99 | binary_pattern=LBP_rotate4Min(binary_pattern) 100 | index=LBP_binary2int(binary_pattern) 101 | try: 102 | table[index]+=1 103 | except KeyError: 104 | raise ValueError('Invalid key:%d' %index) 105 | 106 | lbp_hist[w_rid,w_cid]=np.asarray([table[x] for x in sorted_keys]) 107 | lbp_hist[w_rid,w_cid]/=np.sum(lbp_hist[w_rid,w_cid]) 108 | #print([(x,table[x]) for x in sorted(table.keys())]) 109 | for x in table.keys():#clear the data in the histogram 110 | table[x]=0 111 | return lbp_hist.flatten() 112 | 113 | 114 | def LBP_hopCounter(binaryArr): 115 | sz=binaryArr.size 116 | cnt=0 117 | for i in range(1,sz): 118 | if(binaryArr[i]!=binaryArr[i-1]): 119 | cnt+=1 120 | if(binaryArr[0]!=binaryArr[sz-1]): 121 | cnt+=1 122 | return cnt 123 | 124 | 125 | def LBP_rotate4Min(binaryArr): 126 | sz=binaryArr.size 127 | res=np.zeros(sz) 128 | maxPos=0 129 | maxCnt=0 130 | start=0 131 | while(startmaxCnt: 143 | maxPos=pos 144 | maxCnt=buf[pos] 145 | pos=(pos-1+sz)%sz 146 | validDigit=sz-maxCnt 147 | copypos=(maxPos-validDigit+sz)%sz 148 | for idx in range(validDigit): 149 | res[maxCnt+idx]=binaryArr[(copypos+idx)%sz] 150 | return res 151 | 152 | 153 | def LBP_binary2int(binaryArr): 154 | sz=binaryArr.size 155 | res=0 156 | for i in range(sz): 157 | if binaryArr[sz-i-1]: 158 | res+=1<