This post was updated on .
Hi!
I am using transform function in imageJ 1.43U. As it turns out the translation in a chosen direction cuts out that part of the image which leaves the view window and fills the other side with white. This means that I lose information that i still need. I am trying to work out how to keep the sample symmetry like on the picture below: Does anyone know if this can be fixed or if any adequate plugin exists? Thank you, Jerry |
Hi Jerry,
for translation with periodic boundary conditions, I am not aware of any ImageJ built-in function or external plugin (it would be easy to write one). What you could do is replicating the image, and then crop it at the desired position. I have a macro that replicates a single image (not a stack) by creating a stack of identical slices, then making a montage of the slices. I'll paste the code at the very bottom. Mind possible line breaks introduced by the mailer; the line starting with run("Make Montage... should end with font=12"); Michael ________________________________________________________________ On Jul 9, 2015, at 13:50, jerry novakk wrote: > Hi! > > I am using transform function in imageJ 1.43U. As it turns out the > translation in a chosen direction > cuts out that part of the image which leaves the view window and fills the > other side with white. > This means that I lose information that i still need. > I am trying to work out how to keep the sample symmetry like on the picture > below: > > Jerry <http://imagej.1557.x6.nabble.com/file/n5013479/TRANS.png> > > Does anyone know if this can be fixed or if any adequate plugin exists? > > Thank you, > Jerry ________________________________________________________________ macro 'Replicate 3x3 [F2]' { // Replicate an image periodically in x and y // Michael Schmid, Version May 2015 xRepetitions=3; yRepetitions=3; nTotal = xRepetitions*yRepetitions; title = getTitle(); run("Duplicate...", "title=tmp"); dupID = getImageID(); run("Select All"); run("Copy"); for (i=0; i<nTotal; i++) { run("Add Slice"); run("Paste"); } run("Make Montage...", "columns=&xRepetitions rows=&yRepetitions scale=1 first=1 last=&nTotal increment=1 border=0 font=12"); rename(title+"_"+ xRepetitions+"x"+ yRepetitions); selectImage(dupID); close(); } -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by jerry novakk
Dear Jerry,
Maybe the code below does what you want. Open your image and make an ROI of the area you want to translate. waitForUser ("make selection"); getSelectionBounds(x, y, width, height); run("Copy"); run("Select None"); run("Translate...", "x="+width+" y=0 interpolation=None"); makeRectangle(0, 0, width, height); run("Paste"); Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of jerry novakk Sent: 09 July 2015 12:51 To: [hidden email] Subject: Cyclic translation transform Hi! I am using transform function in imageJ 1.43U. As it turns out the translation in a chosen direction cuts out that part of the image which leaves the view window and fills the other side with white. This means that I lose information that i still need. I am trying to work out how to keep the sample symmetry like on the picture below: Jerry <http://imagej.1557.x6.nabble.com/file/n5013479/TRANS.png> Does anyone know if this can be fixed or if any adequate plugin exists? Thank you, Jerry -- View this message in context: http://imagej.1557.x6.nabble.com/Cyclic-translation-transform-tp5013479.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you both very much for your help! I'll try it out and see if it works.
|
This post was updated on .
Here are three versions of macros for translations, wich I made from your propositions. The code is a little bit trashy and definitely not optimized, but it works fine for me. I had problems with translations with negative input so I had to combine makeRectangle.. and Specify.. to paste back out of bound parts of an image.
I thank you both again for your help and hope someone else finds this usefull. -------------------------------------------------------------------------------------- //Periodic_Translation_TopLeft.txt getDimensions(W, H, dummy, dummy, dummy); //Open your image and make an ROI of the area you want to translate to top left corner. waitForUser ("select area"); getSelectionBounds(X, Y, dummy, dummy); Xc=W-X; Xm=-X; Yc=H-Y; Ym=-Y; //translate horizontal run("Select All"); run("Specify...", "Width=X Height=H x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=Xm y=0 interpolation=None"); run("Specify...", "Width=X Height=H x=Xc y=0"); run("Paste"); //translate vertical run("Select All"); run("Specify...", "Width=W Height=Y x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=Ym interpolation=None"); run("Specify...", "Width=W Height=H x=0 y=Yc"); run("Paste"); run("Select None"); ----------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- //Periodic_Translation_Center.txt getDimensions(W, H, dummy, dummy, dummy); //Open your image and make an ROI of the area you want to center translate. waitForUser ("select area to center"); getSelectionBounds(X, Y, width, height); a=round((W-width)*0.5); b=round((H-height)*0.5); //translate horizontal if (a<=X){ dx=X-a; Xcopy= W-dx; run("Select All"); run("Specify...", "Width="+dx+" Height="+H+" x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=-"+dx+" y=0 interpolation=None"); // makeRectangle(Xcopy, 0, dx, H); run("Specify...", "Width=dx Height=H x=Xcopy y=0"); run("Paste"); } else { dx=a-X; Xcopy= W-dx; run("Select All"); run("Specify...", "Width="+dx+" Height="+H+" x="+Xcopy+" y=0"); run("Copy"); run("Select None"); run("Translate...", "x="+dx+" y=0 interpolation=None"); makeRectangle(0, 0, dx, H); run("Paste"); } //translate vertical if (b<=Y) { dy=Y-b; ycopy= H-dy; run("Select All"); run("Specify...", "Width="+W+" Height="+dy+" x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=-"+dy+" interpolation=None"); run("Specify...", "Width=W Height=dy x=0 y=ycopy"); run("Paste"); } else { dy=b-Y; ycopy= H-dy; run("Select All"); run("Specify...", "Width="+W+" Height="+dy+" x=0 y="+ycopy+""); run("Copy"); run("Select None"); run("Translate...", "x=0 y="+dy+" interpolation=None"); makeRectangle(0, 0, W, dy); run("Paste"); } run("Select None"); ----------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- //Periodic_Translation_Input.txt getDimensions(W, H, dummy, dummy, dummy); //translate horizontal Dialog.create("Translate horizontal"); Dialog.addNumber("X", 0); Dialog.show(); X= Dialog.getNumber(); if (X<0) { Xa=W+X; run("Select All"); run("Specify...", "Width=abs(X) Height=H x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=X y=0 interpolation=None"); run("Specify...", "Width=abs(X) Height=H x=Xa y=0"); run("Paste"); } else { Xb=W-X; run("Select All"); run("Specify...", "Width=abs(X) Height=H x=Xb y=0"); run("Copy"); run("Select None"); run("Translate...", "x=X y=0 interpolation=None"); makeRectangle(0, 0, abs(X), H); run("Paste"); } //translate vertical Dialog.create("Translate vertical"); Dialog.addNumber("Y", 0); Dialog.show(); Y= Dialog.getNumber(); if (Y<0) { Ya=H+Y; run("Select All"); run("Specify...", "Width=W Height=abs(Y) x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=Y interpolation=None"); run("Specify...", "Width=W Height=abs(Y) x=0 y=Ya"); run("Paste"); } else { Yb=H-Y; run("Select All"); run("Specify...", "Width=W Height=abs(Y) x=0 y=Yb"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=Y interpolation=None"); makeRectangle(0, 0, W, abs(Y)); run("Paste"); } run("Select None"); ---------------------------------------------------------------------------------- |
This post was updated on .
Below I've added a Macro that periodically Translates all images in a stack for the same input amount in x & y direction.
__________________________________________________________________________________________ //Stack needs to be open!! Dialog.create("Translate horizontal"); Dialog.addNumber("X", 0); Dialog.show(); X= Dialog.getNumber(); Dialog.create("Translate vertical"); Dialog.addNumber("Y", 0); Dialog.show(); Y= Dialog.getNumber(); for(i=1;i<=nSlices;i++){ setSlice(i); getDimensions(W, H, dummy, dummy, dummy); //translate horizontal if (X<0) { Xa=W+X; run("Select All"); run("Specify...", "Width=abs(X) Height=H x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=X y=0 interpolation=None"); run("Specify...", "Width=abs(X) Height=H x=Xa y=0"); run("Paste"); } else { Xb=W-X; run("Select All"); run("Specify...", "Width=abs(X) Height=H x=Xb y=0"); run("Copy"); run("Select None"); run("Translate...", "x=X y=0 interpolation=None"); makeRectangle(0, 0, abs(X), H); run("Paste"); } //translate vertical if (Y<0) { Ya=H+Y; run("Select All"); run("Specify...", "Width=W Height=abs(Y) x=0 y=0"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=Y interpolation=None"); run("Specify...", "Width=W Height=abs(Y) x=0 y=Ya"); run("Paste"); } else { Yb=H-Y; run("Select All"); run("Specify...", "Width=W Height=abs(Y) x=0 y=Yb"); run("Copy"); run("Select None"); run("Translate...", "x=0 y=Y interpolation=None"); makeRectangle(0, 0, W, abs(Y)); run("Paste"); } run("Select None"); } __________________________________________________________________________________________ |
Free forum by Nabble | Edit this page |