Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should binarise the image. <code>findContours</code> only works well when there is e.g. only black and white in the image. </p> <p>So you should look at each pixel in the image and threshold. If it's below a certain value make it black, other wise make it white. To me the provided image looks like there are some grey pixels too. </p> <p>Also you should know that find contours 'destroys' the provided image. It does not create a copy on it's own. So if you want to keep the original, you should pass in a copy.</p> <p>After you found the contours you can use that information on the original image and change the color values of the pixels in the found areas.</p> <p><strong>Edit :</strong></p> <p>Okay after I read your update I would recommend the following:<br> Make the background, that is kind of blueish, to black.<br> For that you need to inspect each pixel and look at the color values. </p> <p>If it has enough blue in it make it black.<br> Everything else you make white.</p> <p>After that your background should be black and your numbers should be white. You could now do findContours, or if you just want the numbers to be black and the background to be white: invert the image or swap black and white in the binarizing process.</p> <blockquote> <p><strong>Important:</strong><br> What you did with your image is actually not binarize it. You took the color out. Binarize means only TWO colors. A pixel will EITHER be black OR white. Not gray.<br> Your threshold is actually not thresholding because the value you took(255) is the maximum(because that is the highest number you can have with 8 bit). Thresholding works differently: for a binary threshold you have a value everything that is below or equal will be one color, everything that is above will be another. For 255 the whole image should turn to one color....<br> With thresholds you usualy play around a bit until they fit your needs</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload