python - How to check if an image is flipped or not with respect to base image -


in opencv can flip image horizontally , vertically using code :

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() 

my question is: there way check input image flipped respect base image? want know steps check if image flipped or not.

here pseudo c++ solution:

bool issamesize(image a, image b) {     return a.width() == b.width() && a.height() == b.height(); } bool isnotflipped(image a, image b) {     if(!issamesize(a, b)) return false;     for(int y = 0; y < a.height(); ++y)         for(int x = 0; x < a.width(); ++x)         {             if(a.pixel(x, y) != b.pixel(x, y))                 return false;         }     return true; } bool isflippedhorizontal(image a, image b) {     if(!issamesize(a, b)) return false;     int w = a.width();     for(int y = 0; y < a.height(); ++y)         for(int x = 0; x < a.width(); ++x)         {             if(a.pixel(x, y) != b.pixel(w - x - 1, y))                 return false;         }     return true; } bool isflippedvertical(image a, image b) {     if(!issamesize(a, b)) return false;     int h = a.height();     for(int y = 0; y < a.height(); ++y)         for(int x = 0; x < a.width(); ++x)         {             if(a.pixel(x, y) != b.pixel(x, h - y - 1))                 return false;         }     return true; } bool isflippedboth(image a, image b) {     if(!issamesize(a, b)) return false;     int w = a.width();     int h = a.height();     for(int y = 0; y < a.height(); ++y)         for(int x = 0; x < a.width(); ++x)         {             if(a.pixel(x, y) != b.pixel(w - x - 1, h - y - 1))                 return false;         }     return true; } 

hth


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -