Skip to content

Instantly share code, notes, and snippets.

@miura
Created September 11, 2012 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miura/3702732 to your computer and use it in GitHub Desktop.
Save miura/3702732 to your computer and use it in GitHub Desktop.
Code fragments for registering two images
//20120911
// Kota Miura
// Code fragments for registering two images
// & printing out shift in positions.
// refer to
// http://bigwww.epfl.ch/thevenaz/turboreg/turboRegMacro.txt
// for more examples.
//using opened image opened and refering their title.
frame1 = "t1.tif"; // a frame in a sequence
frame2 = "t2.tif"; // next frame in the sequence
selectWindow(frame1);
width = getWidth();
height = getWidth();
run("TurboReg ",
"-align"
+ "-window " + frame1 + " "// Source (window reference).
+ " 0 0 " + (width - 1) + " " + (height - 1)
+ "-window " + frame2 + " "// Target (window reference).
+ " 0 0 " + (width - 1) + " " + (height - 1)
+ " -translation"
+ " " + (width / 2) + " " + (height / 2)
+ " " + (width / 2) + " " + (height / 2)
+ " -hideOutput"
);
sourceX0 = getResult("sourceX", 0); // First line of the table.
sourceY0 = getResult("sourceY", 0);
targetX0 = getResult("targetX", 0);
targetY0 = getResult("targetY", 0);
print(sourceX0, sourceY0, targetX0, targetY0);
// another way accessing image file in the file system.
// in this case, you should know the image size (width and height)
// by first opeing the file and check its width and height.
run("TurboReg ",
"-align"
+ " -file " + sourcePathAndFileName
+ " 0 0 " + (width - 1) + " " + (height - 1)
+ " -file " + targetPathAndFileName
+ " 0 0 " + (width - 1) + " " + (height - 1)
+ " -translation"
+ " " + (width / 2) + " " + (height / 2)
+ " " + (width / 2) + " " + (height / 2)
+ " -hideOutput"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment