Dear all,
I would like to perform something quite easy, which is namelly : - Open 2 stack pictures - Concatenate them - Transform them into an hyperstack And I would like to perform all this in java, thus I launched the macro recorder (set to java) and I obtained the following plugin: import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; public class My_Plugin implements PlugIn { public void run(String arg) { ImagePlus imp = IJ.openImage("Z:\\p1.tif"); imp = IJ.openImage("Z:\\p2.tif"); IJ.run("Concatenate...", " title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None --]"); imp2 = HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); imp.show(); } } Which once compiled wasnt working.:( Thus I made some corrections to fix some of the found errors to finally obtain the following code: ImagePlus imp = IJ.openImage("Z:\\p1.tif"); imp.show(); imp = IJ.openImage("Z:\\p2.tif"); imp.show(); IJ.run("Concatenate...", " title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None --]"); imp = IJ.getImage(); ImagePlus imp2 = HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); imp2.show(); But as this code isnt giving any more errors it is not making the HyperStack conversion either. Thus how should I need to write the code in order to perform the HyperStack conversion? I thank you very much in advance for your help. My best regards, Philippe Philippe CARL Laboratoire de Biophotonique et Pharmacologie UMR 7213 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 41 84 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> On Jun 24, 2016, at 6:08 AM, Philippe CARL <[hidden email]> wrote:
> > Dear all, > > I would like to perform something quite easy, which is namelly : > > - Open 2 stack pictures > > - Concatenate them > > - Transform them into an hyperstack Use code similar to this JavaScript example (requires 1.51e13 or later): img1 = IJ.createImage("stack1","8-bit ramp",500,500,50); img2 = IJ.createImage("stack2","8-bit random",500,500,50); img3 = Concatenator.run(img1,img2); img3.show(); The output stack is automatically transformed into an hyperstack. Use IJ.run(img3,"Hyperstack to Stack", "”); to convert it to a normal stack. The Recorder in 1.51e13 or later generates code similar to the example above. -wayne > And I would like to perform all this in java, thus I launched the macro > recorder (set to java) and I obtained the following plugin: > > import ij.*; > > import ij.process.*; > > import ij.gui.*; > > import java.awt.*; > > import ij.plugin.*; > > > public class My_Plugin implements PlugIn { > > public void run(String arg) { > > ImagePlus imp = IJ.openImage("Z:\\p1.tif"); > > imp = IJ.openImage("Z:\\p2.tif"); > > IJ.run("Concatenate...", " > title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None > --]"); > > imp2 = HyperStackConverter.toHyperStack(imp, > 1, 14, 60, "default", "Grayscale"); > > imp.show(); > > } > > } > > Which once compiled wasn't working.:( > > Thus I made some corrections to fix some of the found errors to finally > obtain the following code: > > ImagePlus imp = IJ.openImage("Z:\\p1.tif"); > > imp.show(); > > imp = IJ.openImage("Z:\\p2.tif"); > > imp.show(); > > IJ.run("Concatenate...", " > title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None > --]"); > > imp = IJ.getImage(); > > ImagePlus imp2 = > HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); > > imp2.show(); > > But as this code isn't giving any more errors it is not making the > HyperStack conversion either. > > Thus how should I need to write the code in order to perform the HyperStack > conversion? > > I thank you very much in advance for your help. > > My best regards, > > Philippe -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Wayne,
I thank you very much for your answer and apologize really for making you work so hard in the week-end. I have updated ImageJ to the Daily build version, but the stacks I want to concatenete don't have a similar size, and thus I get the following error: "Cannot create 4D image because stack sizes are not equal." when I use the code "imp = Concatenator.run(imp1, imp2);". I even tried to fix the problem by doing: Concatenator concatenator = new Concatenator(); concatenator .setIm5D(false); imp = concatenator.concatenate(imp1, imp2, false); But this didn't make it either. It seems there is no access (unless I missed it) in the plugin to turn off the "Open as 4D image" option which I would need. Kindest regards, Philippe Le Dimanche 26 Juin 2016 18:25 CEST, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> a écrit: > > On Jun 24, 2016, at 6:08 AM, Philippe CARL <[hidden email]> wrote: > > > > Dear all, > > > > I would like to perform something quite easy, which is namelly : > > > > - Open 2 stack pictures > > > > - Concatenate them > > > > - Transform them into an hyperstack > > Use code similar to this JavaScript example (requires 1.51e13 or later): > > img1 = IJ.createImage("stack1","8-bit ramp",500,500,50); > img2 = IJ.createImage("stack2","8-bit random",500,500,50); > img3 = Concatenator.run(img1,img2); > img3.show(); > > The output stack is automatically transformed into an hyperstack. Use > > IJ.run(img3,"Hyperstack to Stack", "”); > > to convert it to a normal stack. > > The Recorder in 1.51e13 or later generates code similar to the example above. > > -wayne > > > And I would like to perform all this in java, thus I launched the macro > > recorder (set to java) and I obtained the following plugin: > > > > import ij.*; > > > > import ij.process.*; > > > > import ij.gui.*; > > > > import java.awt.*; > > > > import ij.plugin.*; > > > > > > public class My_Plugin implements PlugIn { > > > > public void run(String arg) { > > > > ImagePlus imp = IJ.openImage("Z:\\p1.tif"); > > > > imp = IJ.openImage("Z:\\p2.tif"); > > > > IJ.run("Concatenate...", " > > title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None > > --]"); > > > > imp2 = HyperStackConverter.toHyperStack(imp, > > 1, 14, 60, "default", "Grayscale"); > > > > imp.show(); > > > > } > > > > } > > > > Which once compiled wasn't working.:( > > > > Thus I made some corrections to fix some of the found errors to finally > > obtain the following code: > > > > ImagePlus imp = IJ.openImage("Z:\\p1.tif"); > > > > imp.show(); > > > > imp = IJ.openImage("Z:\\p2.tif"); > > > > imp.show(); > > > > IJ.run("Concatenate...", " > > title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None > > --]"); > > > > imp = IJ.getImage(); > > > > ImagePlus imp2 = > > HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); > > > > imp2.show(); > > > > But as this code isn't giving any more errors it is not making the > > HyperStack conversion either. > > > > Thus how should I need to write the code in order to perform the HyperStack > > conversion? > > > > I thank you very much in advance for your help. > > > > My best regards, > > > > Philippe > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Check to make sure the xy dimensions of your two stacks are the same.
If not, you will likely need to resize or crop one of your stacks to concatenate them. On 6/27/2016 2:24 AM, CARL Philippe (PHA) wrote: > Dear Wayne, > I thank you very much for your answer and apologize really for making you work so hard in the week-end. > I have updated ImageJ to the Daily build version, but the stacks I want to concatenete don't have a similar size, and thus I get the following error: "Cannot create 4D image because stack sizes are not equal." when I use the code "imp = Concatenator.run(imp1, imp2);". > I even tried to fix the problem by doing: > Concatenator concatenator = new Concatenator(); > concatenator .setIm5D(false); > imp = concatenator.concatenate(imp1, imp2, false); > But this didn't make it either. > It seems there is no access (unless I missed it) in the plugin to turn off the "Open as 4D image" option which I would need. > Kindest regards, > Philippe > > Le Dimanche 26 Juin 2016 18:25 CEST, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> a écrit: > >>> On Jun 24, 2016, at 6:08 AM, Philippe CARL <[hidden email]> wrote: >>> >>> Dear all, >>> >>> I would like to perform something quite easy, which is namelly : >>> >>> - Open 2 stack pictures >>> >>> - Concatenate them >>> >>> - Transform them into an hyperstack >> Use code similar to this JavaScript example (requires 1.51e13 or later): >> >> img1 = IJ.createImage("stack1","8-bit ramp",500,500,50); >> img2 = IJ.createImage("stack2","8-bit random",500,500,50); >> img3 = Concatenator.run(img1,img2); >> img3.show(); >> >> The output stack is automatically transformed into an hyperstack. Use >> >> IJ.run(img3,"Hyperstack to Stack", "”); >> >> to convert it to a normal stack. >> >> The Recorder in 1.51e13 or later generates code similar to the example above. >> >> -wayne >> >>> And I would like to perform all this in java, thus I launched the macro >>> recorder (set to java) and I obtained the following plugin: >>> >>> import ij.*; >>> >>> import ij.process.*; >>> >>> import ij.gui.*; >>> >>> import java.awt.*; >>> >>> import ij.plugin.*; >>> >>> >>> public class My_Plugin implements PlugIn { >>> >>> public void run(String arg) { >>> >>> ImagePlus imp = IJ.openImage("Z:\\p1.tif"); >>> >>> imp = IJ.openImage("Z:\\p2.tif"); >>> >>> IJ.run("Concatenate...", " >>> title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None >>> --]"); >>> >>> imp2 = HyperStackConverter.toHyperStack(imp, >>> 1, 14, 60, "default", "Grayscale"); >>> >>> imp.show(); >>> >>> } >>> >>> } >>> >>> Which once compiled wasn't working.:( >>> >>> Thus I made some corrections to fix some of the found errors to finally >>> obtain the following code: >>> >>> ImagePlus imp = IJ.openImage("Z:\\p1.tif"); >>> >>> imp.show(); >>> >>> imp = IJ.openImage("Z:\\p2.tif"); >>> >>> imp.show(); >>> >>> IJ.run("Concatenate...", " >>> title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None >>> --]"); >>> >>> imp = IJ.getImage(); >>> >>> ImagePlus imp2 = >>> HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); >>> >>> imp2.show(); >>> >>> But as this code isn't giving any more errors it is not making the >>> HyperStack conversion either. >>> >>> Thus how should I need to write the code in order to perform the HyperStack >>> conversion? >>> >>> I thank you very much in advance for your help. >>> >>> My best regards, >>> >>> Philippe >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Robert,
The issue is not the xy dimensions of the two stacks, but their z or t dimensions... My best regards, Philippe -----Message d'origine----- De : ImageJ Interest Group [mailto:[hidden email]] De la part de Robert Baer Envoyé : lundi 27 juin 2016 15:11 À : [hidden email] Objet : Re: Recorder not always working in java Check to make sure the xy dimensions of your two stacks are the same. If not, you will likely need to resize or crop one of your stacks to concatenate them. On 6/27/2016 2:24 AM, CARL Philippe (PHA) wrote: > Dear Wayne, > I thank you very much for your answer and apologize really for making you work so hard in the week-end. > I have updated ImageJ to the Daily build version, but the stacks I want to concatenete don't have a similar size, and thus I get the following error: "Cannot create 4D image because stack sizes are not equal." when I use the code "imp = Concatenator.run(imp1, imp2);". > I even tried to fix the problem by doing: > Concatenator concatenator = new Concatenator(); > concatenator .setIm5D(false); > imp = concatenator.concatenate(imp1, imp2, false); > But this didn't make it either. > It seems there is no access (unless I missed it) in the plugin to turn off the "Open as 4D image" option which I would need. > Kindest regards, > Philippe > > Le Dimanche 26 Juin 2016 18:25 CEST, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> a écrit: > >>> On Jun 24, 2016, at 6:08 AM, Philippe CARL <[hidden email]> wrote: >>> >>> Dear all, >>> >>> I would like to perform something quite easy, which is namelly : >>> >>> - Open 2 stack pictures >>> >>> - Concatenate them >>> >>> - Transform them into an hyperstack >> Use code similar to this JavaScript example (requires 1.51e13 or later): >> >> img1 = IJ.createImage("stack1","8-bit ramp",500,500,50); >> img2 = IJ.createImage("stack2","8-bit random",500,500,50); >> img3 = Concatenator.run(img1,img2); >> img3.show(); >> >> The output stack is automatically transformed into an hyperstack. Use >> >> IJ.run(img3,"Hyperstack to Stack", "”); >> >> to convert it to a normal stack. >> >> The Recorder in 1.51e13 or later generates code similar to the example above. >> >> -wayne >> >>> And I would like to perform all this in java, thus I launched the macro >>> recorder (set to java) and I obtained the following plugin: >>> >>> import ij.*; >>> >>> import ij.process.*; >>> >>> import ij.gui.*; >>> >>> import java.awt.*; >>> >>> import ij.plugin.*; >>> >>> >>> public class My_Plugin implements PlugIn { >>> >>> public void run(String arg) { >>> >>> ImagePlus imp = IJ.openImage("Z:\\p1.tif"); >>> >>> imp = IJ.openImage("Z:\\p2.tif"); >>> >>> IJ.run("Concatenate...", " >>> title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None >>> --]"); >>> >>> imp2 = HyperStackConverter.toHyperStack(imp, >>> 1, 14, 60, "default", "Grayscale"); >>> >>> imp.show(); >>> >>> } >>> >>> } >>> >>> Which once compiled wasn't working.:( >>> >>> Thus I made some corrections to fix some of the found errors to finally >>> obtain the following code: >>> >>> ImagePlus imp = IJ.openImage("Z:\\p1.tif"); >>> >>> imp.show(); >>> >>> imp = IJ.openImage("Z:\\p2.tif"); >>> >>> imp.show(); >>> >>> IJ.run("Concatenate...", " >>> title=[Concatenated Stacks] image1=[p1.tif] image2=[p2.tif] image3=[-- None >>> --]"); >>> >>> imp = IJ.getImage(); >>> >>> ImagePlus imp2 = >>> HyperStackConverter.toHyperStack(imp, 1, 14, 60, "default", "Grayscale"); >>> >>> imp2.show(); >>> >>> But as this code isn't giving any more errors it is not making the >>> HyperStack conversion either. >>> >>> Thus how should I need to write the code in order to perform the HyperStack >>> conversion? >>> >>> I thank you very much in advance for your help. >>> >>> My best regards, >>> >>> Philippe >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by CARL Philippe (LBP)
Hello,
I want to make my plugin react to take some action when the users presses specific keys. At the moment I use keys that are not connected to a shortcut, this works well by making my plugin implement KeyListener and using the function "keyPressed(KeyEvent e)”. However, I am not able to get keys that are already used as a shortcut. Can I disable certain shortcuts in my plugin and then use those “free” keys to do my own work? If necessary, I can disable ALL shortcuts, as during the evaluation I don’t need any predefined shortcuts. If possible I would like to reactivate the disabled shortcuts after finishing my plugin. Best Armin -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by CARL Philippe (LBP)
> On Jun 27, 2016, at 3:24 AM, CARL Philippe (PHA) <[hidden email]> wrote:
> > Dear Wayne, > I thank you very much for your answer and apologize really for making you work so hard in the week-end. > I have updated ImageJ to the Daily build version, but the stacks I want to concatenete don't have a similar size, and thus I get the following error: "Cannot create 4D image because stack sizes are not equal." when I use the code "imp = Concatenator.run(imp1, imp2);". > I even tried to fix the problem by doing: > Concatenator concatenator = new Concatenator(); > concatenator .setIm5D(false); > imp = concatenator.concatenate(imp1, imp2, false); > But this didn't make it either. > It seems there is no access (unless I missed it) in the plugin to turn off the "Open as 4D image" option which I would need. This bug is fixed in the latest daily build (1.51e14). Here is a JavaScript example that concatenates three unequal size stacks: img1 = IJ.createImage("stack1","8-bit ramp",500,500,40); img2 = IJ.createImage("stack2","8-bit random",500,500,50); img3 = IJ.createImage("stack3","8-bit black",500,500,60); img4 = Concatenator.run(img1,img2,img3); img4.show(); -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |