Skip to content

Instantly share code, notes, and snippets.

@tferr
Created December 8, 2014 13:27
Show Gist options
  • Save tferr/ed12b72b3db9c3a658ff to your computer and use it in GitHub Desktop.
Save tferr/ed12b72b3db9c3a658ff to your computer and use it in GitHub Desktop.
ImageJ1 macros that create X/Y mirrors of the active ROI
// 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