0

I have an image in upside down and how I can make it upright so that people inside the image are in correct orientation. The image is attached as shown. Thanks below

batuman
  • 7,066
  • 26
  • 107
  • 229
  • possible duplicate of [OpenCV: how to rotate IplImage?](http://stackoverflow.com/questions/2289690/opencv-how-to-rotate-iplimage) – yuyoyuppe Nov 19 '13 at 07:43

1 Answers1

4

I think you should use cv::flip method. http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#flip

with -1 flipcode it will be:

cv::namedWindow("X");
Mat img_X=imread("D:\\ImagesForTest\\2FXT6.jpg",0);
cv::flip(img_X,img_X,-1);
imshow("X",img_X);
cv::waitKey(0);

enter image description here

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • yeah I tried and flipped with 0. But I got the same orientation. – batuman Nov 19 '13 at 08:19
  • May be I don't understand what do you want to do? I see that image should be flipped around horizontal axis, if you need flip around vertical axis too, you should use negative flipcode. – Andrey Smorodov Nov 19 '13 at 08:28
  • Yeah flipping around vertical axis works, but don't know why in horizontal axis doesn't work – batuman Nov 19 '13 at 08:33
  • Just tested cv::flip and edit my answer. It seems works fine. – Andrey Smorodov Nov 19 '13 at 08:45
  • @Smorodov; yes that way, it works. But it has mirror effect. Two persons at the right edge are shifted to the left edge. How can I keep those to be at the same side and just inverted. Thanks – batuman Nov 20 '13 at 01:38
  • You can use flipcode=0, then image will not flipped around vertical, You should understand that transform applied to all pixels at once. If you want flip only blobs you need find contours, find bounding rectangles, then flip every distinct rectangle. But it will change real information to fake image. – Andrey Smorodov Nov 20 '13 at 04:16
  • Can you get image editor load you image and flip it as you want? – Andrey Smorodov Nov 20 '13 at 04:23