I converted an image into a gray scale numpy array using opencv:
im_g=cv2.imread("smallgray.png",0)
print(im_g)
[[187 158 104 121 143]
[198 125 255 255 147]
[209 134 255 97 182]]
I want to darken the image for those values that are higher than 200 for example, being 255 white and 0 black. If I do this I get the correct result:
im_g[im_g>200] = 150
print(im_g)
[[187 158 104 121 143]
[198 125 150 150 147]
[150 134 150 97 182]]
But my question is, if I don't want to use a constant (like 150 in the example) and instead perform some calculation on the current element, how do I refer to that element??
Thanks in advance
im_g[im_g>(255-im_g)]?255 - im_gwith any vectorized numpy function that performs the computation you need.