OpenCV modifies values through for loop

Take this example: inverting a binary image as an example

        for i in range(binaryImg.shape[0]):
            for j in range(binaryImg.shape[1]):
                if binaryImg[i][j] == 1:
                    binaryImg[i][j] = 0
                else:
                    binaryImg[i][j] = 1

Note: It cannot be used directly for item in something. Item cannot be modified during for traversal in python. Item is a copy.

Guess you like

Origin blog.csdn.net/qq_29391809/article/details/117265194