Otsu thresholding with mask

asked 2017-08-30 04:44:14 -0500

xczhang1024 gravatar image

Hi, It appears that Otsu threshold type in cv::threshold is taking the whole image into account when calculating a threshold value to use. Is there any easy way to get it to only calculate the threshold for the masked (non-black) areas of an image?

Thanks

edit retag flag offensive close merge delete

Comments

Otsu algorithm calculates threshold value from histogram data using (getThreshVal_Otsu_8u) You'll have to remove dark pixels from histogram then access Mat pixels directly to be able to threshold while ignoring dark pixels.

Ziri gravatar imageZiri ( 2017-08-30 06:09:28 -0500 )edit