Applying a threshold on an image in order to create a binary image could be a good way to extract the meaningful elements of an image. Suppose that you have the following image of a book:
![](/api/v2/epubs/9781789340723/files/assets/c0a64f08-ddb2-4592-ae48-fd02c41241ba.png)
Since you are interested in analyzing the text in this image, you apply a threshold to this image, as follows:
// using a fixed threshold cv::Mat binaryFixed; cv::threshold(image,binaryFixed,70,255,cv::THRESH_BINARY);
You obtain the following result:
![](/api/v2/epubs/9781789340723/files/assets/81f67b8d-db0b-4782-b18c-c30ee0521d74.png)
In fact, no matter what value you choose for the threshold, in some parts of the image, ...