Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image processing: Rotational alignment of an object

I have a stack of images with a bar close to the center. As the stack progresses the bar pivots around one end and the entire stack contains images with the bar rotated at many different angles up to 45 degrees above or below horizontal.

As shown here:

enter image description here

I'm looking for a way to rotate the bar and/or entire image and align everything horizontally before I do my other processing. Ideally this would be done in Matlab / imageJ / ImageMagick. I'm currently trying to work out a method using first Canny edge detection, followed by a Hough transform, followed by an image rotation, but I'm hoping this is a specific case of a more general problem which has already been solved.

like image 471
user1863037 Avatar asked Nov 30 '12 08:11

user1863037


People also ask

What is image alignment in image processing?

Image alignment is the process of overlaying images of the same scene under different conditions, such as from differ- ent viewpoints, with different illumination, using different sensors, or at different times.


2 Answers

If you have the image processing toolbox you can use regionprops with the 'Orientation' property to find the angle.

http://www.mathworks.com/help/images/ref/regionprops.html#bqkf8ji

like image 59
beaker Avatar answered Oct 21 '22 05:10

beaker


The problem you are solving is known as image registration or image alignment.

-The first thing you need to due is to treshold the image, so you end up with a black and white image. This will simplify the process.

-Then you need to calculate the mass center of the imgaes and then translate them to match each others centers.

  • Then you need to rotate the images to matcheach other. This could be done using the principal axis measure. The principal axis will give you the two axis that explain most of the variance in the population. Which will basically give you a vector showing which way your bar is pointing. Then all you need to due is rotate the bars in the same direction.

-After the principal axis transformation you can try rotating the pictues a little bit more in each direction to try and optimise the rotation.

All the way through your translation and rotation you need a measure for showing you how good a fit your tranformation is. This measure can be many thing. If the picture is black and white a simple subtraction of the pictures is enough. Otherwise you can use measures like mutual information.

...you can also look at procrustes analysis see this link for a matlab function http://www.google.dk/search?q=gpa+image+analysis&oq=gpa+image+analysis&sugexp=chrome,mod=9&sourceid=chrome&ie=UTF-8#hl=da&tbo=d&sclient=psy-ab&q=matlab+procrustes+analysis&oq=matlab+proanalysis&gs_l=serp.3.1.0i7i30l4.5399.5883.2.9481.3.3.0.0.0.0.105.253.2j1.3.0...0.0...1c.1.5UpjL3-8aC0&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&bvm=bv.1355534169,d.Yms&fp=afcd637d8ae07bde&bpcl=40096503&biw=1600&bih=767

like image 23
CG Christen Christensen Avatar answered Oct 21 '22 04:10

CG Christen Christensen