Login  Register

Re: plugin/macro for x-y-shift correction?

Posted by Wayne Rasband on Mar 07, 2006; 5:52pm
URL: http://imagej.273.s1.nabble.com/window-manager-specifics-tp3703459p3703463.html

> I have several multi-colour confocal images with a slight x-y-shift
> between the channels. As a first step before re-align the system,
> is there a plugin or a macro that allows me to correct this shift?
> It would mean to shift a layer for a defined number of pixels.

Here is a macro that shifts the red, green or blue channel in an RGB
image by a specified number of pixels.

-wayne

   if (bitDepth!=24 || nSlices!=1)
       exit("RGB Image required");
   Dialog.create("RGB Shift");
   Dialog.addChoice("Channel:", newArray("Red", "Green", "Blue"));
   Dialog.addNumber("X Shift:", 10);
   Dialog.addNumber("Y Shift:", 10);
   Dialog.addCheckbox("Create New Image", true);
   Dialog.show();
   xshift = Dialog.getNumber();
   yshift = Dialog.getNumber();
   channel = Dialog.getChoice();
   create = Dialog.getCheckbox();
   setBatchMode(true);
   if (create) {
       setKeyDown("alt");
       run("Duplicate...");
   }
   run("RGB Stack");
   if (channel=="Green")
       setSlice(2);
   else if (channel=="Blue")
       setSlice(3);
   run("Select All");
   setBackgroundColor(0, 0, 0);
   run("Cut");
   makeRectangle(xshift, yshift, getWidth, getHeight);
   run("Paste");
   run("RGB Color");
   setBatchMode(false);