Histograms and Matching 主講人:虞台文
Content Overview Basic Histogram Structure Accessing Histograms Basic Manipulations with Histograms Color Spaces Histogram Comparisons Back Projection
Histograms and Matching Overview
Histograms
Histogram of an Image
Histogram for Skin Color
Applications Object Detection Image Retrieval Gesture Recognition
Histograms and Matching Basic Histogram Structure
CvHistogram Multidimensional Histograms typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2; // for nonuniform histograms CvMatND mat; // embedded matrix header // for array histograms } CvHistogram; typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2; // for nonuniform histograms CvMatND mat; // embedded matrix header // for array histograms } CvHistogram;
Create Histogram CvHistogram* cvCreateHist( int dims, int* sizes, int type, float** ranges = NULL, int uniform = 1 ); CvHistogram* cvCreateHist( int dims, int* sizes, int type, float** ranges = NULL, int uniform = 1 );
Defer Set Ranges Used when calling cvCreateHist with ranges = NULL.
Clear and Release Histogram
Histograms and Matching Accessing Histograms
Access Bin Data
Direct Access of Bin Data typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2; // for nonuniform histograms CvMatND mat; // embedded matrix header // for array histograms } CvHistogram; typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2;// for nonuniform histograms CvMatND mat;// embedded matrix header // for array histograms } CvHistogram; hist->mat.data.fl
Direct Access of Histogram Information typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2; // for nonuniform histograms CvMatND mat; // embedded matrix header // for array histograms } CvHistogram; typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2];// for uniform histograms float** thresh2; // for nonuniform histograms CvMatND mat; // embedded matrix header // for array histograms } CvHistogram;
Histograms and Matching Basic Manipulations with Histograms
Calculate Histogram void cvCalcHist( IplImage** image, CvHistogram* hist, int accumulate=0, const CvArr* mask=NULL ); void cvCalcHist( IplImage** image, CvHistogram* hist, int accumulate=0, const CvArr* mask=NULL );
More Operations
Example Graylevel Histogram
Download Test Program Download Test Program
Histograms and Matching Color Spaces
RGB Color Space
HSV Color Space
YCbCr Color Space
Color Space Conversion Article Some Algorithms Applet
OpenCV Color Space Conversion void cvCvtColor( const CvArr* src, CvArr* dst, int code ) void cvCvtColor( const CvArr* src, CvArr* dst, int code )
Skin Color Detection by HSV and RGB
Automatic Face Detection
Histogram Usage Examples
Example Hue-Sat Histogram
Download Test Program Download Test Program
Histograms and Matching Histogram Comparisons
Histogram Comparisons in OpenCV #define CV_COMP_CORREL 0 #define CV_COMP_CHISQR 1 #define CV_COMP_INTERSECT 2 #define CV_COMP_BHATTACHARYYA 3
Histogram Comparisons in OpenCV #define CV_COMP_CORREL 0 #define CV_COMP_CHISQR 1 #define CV_COMP_INTERSECT 2 #define CV_COMP_BHATTACHARYYA 3 Correlation Method (CV_COMP_CORREL) maximum mismatch perfect match
Histogram Comparisons in OpenCV #define CV_COMP_CORREL 0 #define CV_COMP_CHISQR 1 #define CV_COMP_INTERSECT 2 #define CV_COMP_BHATTACHARYYA 3 Chi-square Method (CV_COMP_CHISQR) bad mismatch perfect match
Histogram Comparisons in OpenCV #define CV_COMP_CORREL 0 #define CV_COMP_CHISQR 1 #define CV_COMP_INTERSECT 2 #define CV_COMP_BHATTACHARYYA 3 Intersection Method (CV_COMP_INTERSECT) total mismatch perfect match H 1 and H 2 are normalized to one before comparing
Histogram Comparisons in OpenCV #define CV_COMP_CORREL 0 #define CV_COMP_CHISQR 1 #define CV_COMP_INTERSECT 2 #define CV_COMP_BHATTACHARYYA 3 BHATTACHARYYA Method (CV_COMP_BHATTACHARYYA) total mismatch perfect match
Histogram Comparisons in OpenCV
Histograms and Matching Back Projection
Back projection is a way of recording how well the pixels or patches of pixels fit the distribution of pixels in a histogram model – cvCalcBackProject() – cvCalcBackProjectPatch()
Back Projection Back projection is a way of recording how well the pixels or patches of pixels fit the distribution of pixels in a histogram model – cvCalcBackProject() – cvCalcBackProjectPatch()
cvCalcBackProject
Example Download Test Program Download Test Program
Patch-Based Projection