Friday, 9 January 2015

Horizontal and vertical Flip using opencv and python

import numpy as np
import cv2

img=cv2.imread('1.png')
rimg=img.copy()
fimg=img.copy()
rimg=cv2.flip(img,1)
fimg=cv2.flip(img,0)
cv2.imshow("Original", img)
cv2.imshow("vertical flip", rimg)
cv2.imshow("horizontal flip", fimg)
cv2.waitKey(0)
cv2.destroyAllWindows()


9 comments:

  1. these two lines are not necesary,since fimg and rimg are overwritten later
    rimg=img.copy()
    fimg=img.copy()
    (they cause unnecessary performance loss)

    ReplyDelete
  2. Thank you, very timely, I used the finished code fragment, got a mirror image, helped out, thanks again

    ReplyDelete
  3. This is way to flip a image but is their any to check image is flipped with respect to original image

    ReplyDelete