0

Imagine I have a picture in size 512 * 512, opened with opencv in python. Now I want to change the value of all pixels that are containing values between 120 and 180 to something else. How can I get the index of all elements with that condition?

In Matlab, it would be like this: image(image >= 120 & image <= 180) = X;

But I don't know how to write it in python in one line. Thanks for any help.

img3[(img3 >= 120 and img3 <= 180)] = 50

I tried this but doesn't work...

beaker
  • 16,331
  • 3
  • 32
  • 49
hessam_kk
  • 310
  • 1
  • 12

0 Answers0