I am new to the OpenCV library and I'm trying to using threshold for binarisation. I have a few questions.
- What is the difference between threshold and adaptive threshold?
- What is the benefit of calculating the block mean variance as showed in this answer: OpenCV Adaptive Threshold OCR?
Normal Thresholding is like our college placements, where they put a cgpa cutoff for shortlisting. Now in or out depends on which side of the cgpa you fall under.
Adaptive Thresholding is like segregating students on discipline and then deciding the cutoff.
If the employer wants best of all, then Normal Thresholding is good. But if he wants the best from each discipline, Adaptive Thresholding is better.
Input:
Details:
In normal threshold, you choose an intensity value and pass it to the function. The pixels of the gray image you pass are divided with this value as the boundary and are assigned an intensity, which is the third parameter you pass to the function. In OpenCV you get many variants of this same idea with parameters like THRESH_BINARY ,THRESH_BINARY_INV ,THRESH_TOZERO etc.
In Adaptive threshold, you select a small region around the pixel for threshold. To the OpenCV function you pass the gray image, the max intensity value to assign to the True pixels, adaptive method, the size of your neighborhood and a constant value.
The size of neighborhood is the region around the pixel within which the threshold is calculated. There are two types of adaptive methods- One is where the average of all the pixel values in this box minus the constant is the boundary and another is the weighted mean minus constant value, where the center pixels are given better say in deciding the boundary.
Which one to use:
This totally depends on what you are trying to perform.
If you have an image and want to get the shiny parts of the image, go for normal threshold.
If your image has partial lighting differences and you want to highlight the apparent objects distinctive from their surroundings, choose adaptive threshold. Now if you have boundaries with a shadow and you don't want that shadow to sneak in to your threshold, Gaussian adaptive method in particular would be a better try i'd say.
If you think your image has noise or if the values vary a lot around the mean, then operating with block mean variance is an option.