Ask Your Question
0

imread rotating image by 90 degree

asked 2014-07-31 08:02:43 -0500

rahulvg gravatar image

updated 2014-07-31 08:29:24 -0500

I was trying to load the image..but after imread it is rotating the image by 90 degrees.

edit retag flag offensive close merge delete

Comments

rahulvg gravatar imagerahulvg ( 2014-07-31 08:28:15 -0500 )edit

Is this a question? Please share your code and attempts to reproduce/solve this.

boaz001 gravatar imageboaz001 ( 2014-07-31 08:31:17 -0500 )edit

Program :

   Mat input = cv::imread("image.jpg", CV_LOAD_IMAGE_COLOR);

   //If image is larger than 1000*1000 pixels resize the image.


   Size size(700, 800);
Mat output;

if (input.rows > 1000 && input.cols > 1000)
{
    resize(input, output, size);
}
else
{
    output = input;
}

imshow("input image",output);

if u look at output image u will notice that it is rotated. Even if u skip the part of resizing and directly showing the image it will give u rotated image

rahulvg gravatar imagerahulvg ( 2014-07-31 08:38:11 -0500 )edit

it might be due to exif data saved in the jpeg (landscape mode and such)

berak gravatar imageberak ( 2016-08-05 03:55:06 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2016-08-04 14:06:17 -0500

I had the same issues, which turned out to be related to the Preview application on MacOS, which didn't fully save image changes. Simply rotate the image back and forth and make sure you save the image afterwards. By doing so the issue was resolved for me.

edit flag offensive delete link more
0

answered 2014-07-31 09:03:50 -0500

boaz001 gravatar image

Besides the code is formatted quite bad. This is obviously not all the code.

But maybe you are confusing inputImg with input (which is previously declared?).

edit flag offensive delete link more

Comments

Sorry for wrong formatting..but I am doing nothing new..just read the image and show it..u will see that it is rotated.

//read the image

Mat input = cv::imread("image.jpg", CV_LOAD_IMAGE_COLOR);

//display

imshow("Input Image",input); waitkey(-1);

You will notice the image is inverted

rahulvg gravatar imagerahulvg ( 2014-07-31 09:16:32 -0500 )edit

Again, your code contains errors, please check it before submitting. http://i.imgur.com/TXtZTHN.png

boaz001 gravatar imageboaz001 ( 2014-07-31 09:36:42 -0500 )edit

sorry I am new in coding so not aware of this facts.I will try to improve. can u please try this image http://i.imgur.com/8rhAMbP.jpg

rahulvg gravatar imagerahulvg ( 2014-07-31 09:51:55 -0500 )edit

No, it is almost exactly the same as the first image and produces correct results as you can see from my output from previous reply. It has nothing to do with the image. Try adding the cv:: namespace to opencv functions and classes and remove using namespace cv.

boaz001 gravatar imageboaz001 ( 2014-07-31 10:01:15 -0500 )edit
0

answered 2014-08-03 15:43:30 -0500

Athosone gravatar image

Does someone has an answer ? I am facing the same issue... When I load an image from disk using cv::imread, the image is rotated...

edit flag offensive delete link more

Comments

Please share more info. OpenCV version, OS and version, what program do you use to view images and determine rotation, (all) code to try to reproduce, what you have already tried?

boaz001 gravatar imageboaz001 ( 2014-08-04 11:11:30 -0500 )edit

I may be wrong but I think if you are using using image transferred from email or communicator and use the same image as input then this problem occurs.

rahulvg gravatar imagerahulvg ( 2014-08-05 05:46:45 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-07-31 08:02:43 -0500

Seen: 2,321 times

Last updated: Aug 04 '16