Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
your code is having a few errors, you are iterating same number multiple times so incrementing and decrementing the same number multiple times.
Here is the corrected version, replace 20 to 38 lines in your code with this:
for i in range(beb.shape[0]):
for j in range(beb.shape[1]):
if (not beb[i][j] and mask[i,j]) or (beb[i][j] and not mask[i,j]):
if not copiv[i,j,1] % 2:
copiv[i,j,1] += 1
else:
copiv[i,j,1] -= 1
let me know if there is any further doubt in the above code.