简体   繁体   中英

Image thresholding with my own min-max value with python

I have an image to threshold. But I dont want to classical methods. I have my own min and max threshold value. How can i apply this threshold values to my image and get a binary mask. For example min is 300 and max is 500 if my pixel value is between these I get 255 if not I get 0. Thanks for helping.

Assuming you're using opencv, there's the cv2.inRange(img, min, max) function that does exactly that. If you want a library agnostic solution then you could iterate through your image and build the mask yourself by checking each individual pixel value against your bounds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM