I am editing images using numpy in python, but I don't know how to change BGR. . .
result [np.where (result [::, ::, (2,)]>50)] == 50
But the value of B will be minus 50
result [np.where (result [::, ::, (1,2)]>50)] == 50
Even so, the values ​​of B and G are subtracted.

Finally, if the BGR G and R values ​​are 50 or more, I want to make the G and B values ​​-50. How should I write them?

  • Answer # 1

    For example, if you want to reduce only the value of R, how about writing as follows?
    result [np.where (result>[255,255,50])]-= 50
    For G and R values:
    result [np.where (result>[255,50,50])]-= 50

    In the original coderesult [np.where (result [::, ::, (2,)]>50)],result [::, ::, (2 ,)]to determine the value for the image of the first channel, the index is obtained only for the value of the first channel → the first channel (Blue) to apply it to the image of the third channel ) Seems to have been applied only to.

Related articles