How can I rotate a series of photos to a desired orientation without knowing the initial orientation of each photo?

9 views (last 30 days)
I have a large photo folder full of photos and need to orient them all in the same direction. They all have a tube in the picture that needs to be going to the left side of the photo. I would like to locate the position of the tube and then orient the photo with respect to that.

Answers (2)

Kristen Amaddio
Kristen Amaddio on 28 Jul 2017
The Image Processing Toolbox could help you with this. If all of your images contain the same tube at different orientations, but you want to rotate them all so the tube is at the same orientation in all images (i.e. the left side of the photo), you could try using image alignment.
The following example in the MATLAB documentation could help you with this:
Basically, you could choose one image to be the 'target' image, the image with the orientation you desire all of your images to have. You might need to orient this one manually with imrotate depending on your use case. Then, you could use alignment in order to transform and rotate the other images to match the same orientation.
If you have the Computer Vision System Toolbox, you could also try something similar to the following example:
Take a look at other Image Processing Toolbox examples for more information about image registration, segmentation, and other tools that could help you with this workflow:

Image Analyst
Image Analyst on 28 Jul 2017
Segment out the tube and ask regionprops() for the orientation. If the orientation angle is not right, then call imrotate() to rotate the image 90 or -90 degrees. Pretty easy but attach your image if you need more help. Or see my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
  2 Comments
Haley Albers
Haley Albers on 31 Jul 2017
So your tutorial was pretty helpful but I have a further question...if I have the segment that I need to orient distinguished, how do I call that specific segment? I attached an image that might be helpful. I need to rotate the tube.
Image Analyst
Image Analyst on 31 Jul 2017
Rotate the tube and have nothing else in the image rotate? If so, why?
You'd have to define your center of rotation first. Then rotate the image and the ROI mask both about that point. Then use the mask to replace the original pixels in the rotated mask with the rotated pixels

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!