Thresholding an image with a low and high threshold in Python

Viewed 177

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
1 Answers

You can use boolean- indexing

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