Skip to content

Instantly share code, notes, and snippets.

@redrabbit
Last active June 29, 2017 22:50
Show Gist options
  • Save redrabbit/42543879ae3667ffadaf to your computer and use it in GitHub Desktop.
Save redrabbit/42543879ae3667ffadaf to your computer and use it in GitHub Desktop.
OpenCV thresholding
IplImage* createThresholding( IplImage* source, const CvScalar& min, const CvScalar& max )
{
const CvSize imgSize = cvSize( source->width, source->height );
IplImage* hsv = cvCreateImage( imgSize, 8, 3 );
cvCvtColor( source, hsv, CV_BGR2HSV );
IplImage* mask = cvCreateImage( imgSize, 8, 1 );
cvInRangeS( hsv, min, max, mask );
cvReleaseImage( &hsv );
return mask;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment