0

I have an image, and would like to modify the image based on a given threshold. The function such as

binary = image > threshold 

will create a binary image. What I want is the image pixels will remain the same if it is higher than the threshold. Are there any convenient function to do that?

user288609
  • 12,465
  • 26
  • 85
  • 127
  • .. `numpy.clip`? – Divakar Oct 24 '19 at 20:44
  • Possible duplicate of [Replacing Numpy elements if condition is met](https://stackoverflow.com/questions/19766757/replacing-numpy-elements-if-condition-is-met) – AMC Oct 24 '19 at 22:28

1 Answers1

1
image[image < threshold] = 0

will clip every pixel below the threshold to 0 and will leave the rest intact

Lior Cohen
  • 5,570
  • 2
  • 14
  • 30