not sure what are you doing, but try something like this:
def autoinvert(binarized_img, tresh=0.5):
"""Invert binarized image if amount of black pixels is higher than
tresh.
"""
height, width = binarized_img.shape
non_zero = cv2.countNonZero(binarized_img)
white_rate = non_zero
decimal point is not a problem, I can devide by 100 or 10 and it works :)
could you share my the whole code ? thanks
Le lundi 27 juin 2022 à 20:44:42 UTC+2, zdenop a écrit :
> not sure what are you doing, but try something like this:
>
> def autoinvert(binarized_img, tresh=0.5):
> """Invert
2 matches
Mail list logo