OpenCV AdaptiveThreshold vs. Otsu Threshold. ROI

I try to use both methods, but the Adaptive Threshold seems to give a better result. I used

cvSmooth( temp, dst,CV_GAUSSIAN,9,9, 0); 

in the original image, then only I used the threshold.

Is there anything I can configure with the Otsu method to make the image better than the adaptive threshold? And one more thing, there are some unwanted fingerprints on the side, any idea how I can get rid of them?

I read from a magazine that by comparing the percentage of white pixels in a self-defined square, I can get an ROI. However, this method requires that I have a threshold value that can be found using the OTSU method, but I'm not too sure about AdaptiveThresholding.

 cvAdaptiveThreshold( temp, dst, 255,CV_ADAPTIVE_THRESH_MEAN_C,CV_THRESH_BINARY,13, 1 ); 

Result:

originaladaptive

 cvThreshold(temp, dst, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU); 

originalotsu

+7
c ++ opencv roi threshold
source share
2 answers

To get rid of unwanted background, you can perform a simple masking operation. The Otsu threshold function provides a threshold value that shortens the foreground image from the background. Use this threshold to create a binary mask by iterating over the entire input image, checking if the current pixel value exceeds the threshold and setting it to 1 if true or 0 if it is false.

You can then apply the binary mask to the original image using a simple matrix multiplication operation or a bit shift operation to remove the background.

+3
source share

Try dividing the image by ROI and applying otsu individually, then combining them back. The separation strategy can be static or dynamic depending on the maximum illumination.

+1
source share

All Articles