I'm trying to flip an image (matrix with RGB values) taken with opencv in Python by switching the columns on the top and bottom:
cv2.imshow('Image',image)
temp = image[0]
row,col,number = image.shape
for i in range (0,col/2) :
temp = image[i]
image[i] = image[col-i-1]
image[col-i-1] = temp
For some reason, temp
changes to image[col-i-1]
after executing image[i] = image[dol-i-1]
.
I printed the first values of each column to see what changed and it showed this:
temp
[ 74 63 167] (old)
[ 85 69 177] (new)
image[i]
[ 85 69 177] (old)
[ 77 66 170] (new)
temp
[ 77 66 170] (old)
[ 77 66 170] (new)
image[col-i-1]
[ 77 66 170] (old)
[ 77 66 170] (new)
So why does temp
change?