Created
December 8, 2014 13:27
-
-
Save tferr/ed12b72b3db9c3a658ff to your computer and use it in GitHub Desktop.
ImageJ1 macros that create X/Y mirrors of the active ROI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ImageJ1 macros that create X/Y mirrors of the active ROI | |
// http://thread.gmane.org/gmane.comp.java.imagej/35570 | |
macro "Contralateral in X [F1]" { | |
mirrorROI(-1, 1); | |
} | |
macro "Contralateral in Y [F2]" { | |
mirrorROI(1, -1); | |
} | |
function mirrorROI(fx, fy) { | |
roi = selectionType(); | |
if (roi>8 || roi<0) | |
exit("Cannot mirror current selection"); | |
getSelectionBounds(upperLeftX, upperLeftY, null, null); | |
getSelectionCoordinates(x, y); | |
aX = newArray(x.length); | |
aY = newArray(x.length); | |
for (i=0; i<x.length; i++) { | |
aX[i] = fx * x[i]; | |
aY[i] = fy * y[i]; | |
} | |
makeSelection(roi, aX, aY); | |
setSelectionLocation(upperLeftX, upperLeftY); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment