I'm trying to flip an image vertically without using any default flip() or similar functions.I tried to iterate along the pixels and by using loops tried to reverse it so i can flip the image vertically.
image=cv2.imread('boat.jpg',1)
height,width,channel=image.shape
list1=[]
list2=[]
for i in range(height):
for j in range(width):
list1.append(image[i,j])
for a in range(len(list1)-1,-1,-1):
list2.append(list1[a])
b=0
for i in range(height):
for j in range(width):
image[i,j]=list2[b]
b+=1
But the flipped image is looking like this: https://ibb.co/KKVkd2d What am i doing wrong?
flipfor this? I'd be something likeflipped_image = cv2.flip(image, 0). Do you explicitly want to use a loop to do the flipping manually?cv2tag, since it's pending removal (see tag wiki excerpt).pythonandopencvtags are preferred here.len(list)works fine here