简体   繁体   中英

Thresholding an image with a low and high threshold in Python

I want to threshold an image with a low and high threshold. I already performed thresholding on a hue channel of a HSV picture, but I want to threshold it between two numbers. Is there a way to do two thresholding operations in one?

rgb = io.imread("image.jpg")
hsv = rgb2hsv(rgb)
hue = hsv[:, :, 0] > 0.5

您可以使用布尔索引

hsv[(hsv[:,:,0] > upper_thresh) | (hsv[:,:,0] < lower_thresh)] = value

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