Login  Register

Re: Recorder not always working in java

Posted by CARL Philippe (LBP) on Jun 27, 2016; 1:32pm
URL: http://imagej.273.s1.nabble.com/Recorder-not-always-working-in-java-tp5016723p5016736.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