2

I have taken a series of photographs of a mechanical device. The device has a clearly marked element in every photo that has a certain rotation and I need to find what that rotation is in degrees.

For that I am attempting to use auto-align algorithms in Photoshop and Hugin. The images auto-align nicely, but I fail to find a method that outputs quantitively how much each image is rotated.

My desired output would look something like this:

Image_001.jpg  0.5 deg
Image_002.jpg  3.4 deg
...
Image_050.jpg  25.6 deg
Image_051.jpg  30.4 deg

Does a method exist that can generate this data?

closed as off-topic by mattdm, Olivier, scottbb, inkista, TFuto Apr 12 '17 at 18:33

  • This question does not appear to be about photography within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    I'm voting to close this question as off-topic because this question is about image analysis for a non-photographic purpose. – mattdm Apr 3 '17 at 14:58
1

ImageJ is a program specifically designed for scientific image analysis. It will take some programming (but so would MATLAB), but I'm reasonably certain ImageJ can do what you want. ImageJ is open source and runs on different platforms. Unlike MATLAB which is very expensive.

4

If you have any experience with tools such as R or MATLAB , then all you need to do is load the image into the workspace, identify the centroid of your marker, and calculate the angle as

theta = atan(row_number/column_number)  

In both R and MATLAB you can manually find the pixel that's at the centroid, by using locator() (R) or the coordinate-identifier tool in MATLAB. If your identifying item had a unique color, you could automate the search for its centroid. Or if you felt like getting fancy, you could do an automated search for its shape using a variety of "blob-matching" tools available. I suspect that's not going to be worth the effort in your case.

I'm interpreting your question as wanting just to know the rotation angle. If you actually need to rotate the images into alignment, I'd do that in one of your image-manipulation tools.

  • 2
    Specifically, here's Matlab's example documentation to Find Image Rotation and Scale Using Automated Feature Matching – scottbb Apr 3 '17 at 19:00
  • @scottbb that's a nice bit of code, but does require a ToolBox or two :-( (insert rant about MathWorks predatory pricing) – Carl Witthoft Apr 4 '17 at 12:08
  • Yeah, I really dislike the toolbox pricing of MathWorks. Technically, it is feasible to code the linked functionality without the Image Processing toolbox, but it does require you to roll your own radon/hough transforms over RGB triple datasets, and then roll your own 2D autocorrelation... that's all. Simple, right? =( – scottbb Apr 4 '17 at 13:57
  • @scottbb hey, for 50% the toolbox price I can port my R -code for those functions :-) . Also, FunFact(TM): if you download a trial version of a toolbox, if the functions you want are m-files, just copy them to some other directory and they'll execute (at least as of version 2011, all MATLAB did was do a "license check" before accessing the toolbox directory). – Carl Witthoft Apr 4 '17 at 15:35
1

I found a way using the align_image_stack command of Hugin, unfortunately it does not seem reliable when I double check it by manually rotating the image in Photoshop. I am placing the answer nonetheless, perhaps someone can improve upon it.

Below command (executed in a folder of numbered jpegs) generates a file output.txt that contains a Hugin project file.

align_image_stack --use-given-order -p "output.txt" *.jpg

In the first section named # image lines the rotation of each image is noted down as the parameter r (example is truncated for readability):

# image lines
#-hugin  cropFactor=1.57275
i w2286 h2238 f0 v22.2426293825203 Ra0 Rb0 Rc0 Rd0 Re0 Eev7.63941033766127 Er1 Eb1 r0 p0 y0 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0  Vm5 n"c__0001.jpg"
#-hugin  cropFactor=1.57275458193554
i w2286 h2238 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev7.63941033766127 Er=0 Eb=0 r0.415525153837992 p0.140870673598968 y0.027787825484654 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"c__0002.jpg"
#-hugin  cropFactor=1.57275458193554
i w2286 h2238 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev7.63941033766127 Er=0 Eb=0 r0.964363183756073 p0.23485788820777 y0.0138123298526572 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"c__0003.jpg"
#-hugin  cropFactor=1.57275458193554
i w2286 h2238 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev7.63941033766127 Er=0 Eb=0 r1.72562957016005 p0.311043964234605 y0.0127864033612948 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"c__0004.jpg"
#-hugin  cropFactor=1.57275458193554
i w2286 h2238 f0 v=0 Ra=0 Rb=0 Rc=0 Rd=0 Re=0 Eev7.63941033766127 Er=0 Eb=0 r2.7002616608102 p0.357917789595762 y0.00726170450171952 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j=0 a=0 b=0 c=0 d=0 e=0 g=0 t=0 Va=0 Vb=0 Vc=0 Vd=0 Vx=0 Vy=0  Vm5 n"c__0005.jpg"

Using below regex and some manual line removal I get the desired output

  • Replace (p.*?")(.*)(") with \2
  • Replace (i.*Eb\=0 r) with nothing
  • Hugin can do it, you should use the custom alignment settings, there you can find the fits for the rotation angles. – Count Iblis Apr 5 '17 at 21:46
1

I think there is no such software tool since very few people mind the angle of misalignment. What they mind is quality of merged image.

On the other hand, every stitching algorithm have data for this perticullar measure and uses it. Your problem is that it is burried deep inside the black box.

All you have to do is to look for the algorithms and dig inside the code and math inside. Something like that.

Another option is to look for characteristic features in given images, find their coordinates, fit a line(s) though them and compare derivatives.

  • The last paragraph seems exactly what I need, I even have a line in the image already that is drawn on the rotating part. Any pointers on how to find coordinates and compare derivates? – Saaru Lindestøkke Apr 3 '17 at 10:04
  • Matlab/Octave can do that :) All you need is to import image, display it and play with callbacks. It is "simple"... – Crowley Apr 3 '17 at 10:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.