Skip to main content

Posts

Showing posts with the label Threshold

OpenCV : Threshold (Binary Image)

1. What is binary Image? It is an image made up of two colors, black and white. It is useful to tracking shape or recognizing object. result binary images 2. How to make Binary Image? It can be made by using Threshold method and d epending on the type of flag, you can use various binarizations. double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type); Type : - THRESH_BINARY : if (src(x,y) > thresh) maxval else 0 - THRESH_BINARY_INV : if (src(x,y) > thresh) 0 else maxval - THRESH_TRUNC : if (src(x,y) > thresh) threshold else src(x,y) - THRESH_TOZERO : if (src(x,y) > thresh) src(x,y) else 0 - THRESH_TOZERO_INV : if (src(x,y) > thresh) 0 else src(x,y) Mat img = imread( "./res/text2.jpeg" ); Mat gray , binary , binary2 , binary3 , otsuBinary ; cvtColor( img , gray , CV_RGB2GRAY); // convert to gray color image // if scalar value is bigger then 128, the va...