Processing Images without displaying them on the screen

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Processing Images without displaying them on the screen

Andreas Jahnen
Dear ImageJ Users,

In my current project, I use ImageJ more as a library then directly as a
tool. We have some constraints, which makes it better this way. For this
reason I do not work with visible ImageJ windows on my desktop. This works
fine, here is a example

// get the a image from somewhere:
ImagePlus image_red = m_array.getRedImage();

// do some processing:
WindowManager.setTempCurrentImage(image_red);
IJ.run("Enhance Contrast", "saturated=0.5 normalize equalize");
IJ.run("Red");

image_red.updateImage();

Especially this is fine, as I can test my problems in ImageJ and then
integrate this directly into my programme.

With this I have one problem: I can not use plugins and functions that are
using more than the "TempCurrentImage", for example the following
commands:

- Merge RGB...
- Image Calculator...

Does anybody know a solution, that I can do the following without
displaying images on the screen?

// some not working code, that should demonstrate what I want to do:
// get the a images from somewhere:
ImagePlus image_red = m_array.getRedImage();
ImagePlus image_green = m_array.getGreenImage();

// do some processing:
WindowManager.setTempCurrentImage("red", image_red);
WindowManager.setTempCurrentImage("green", image_green);

IJ.run("RGB Merge...", "red=[red] green=[green]");

Thank you very much,

Andreas

-----------------------------------------------------------------
Andreas Jahnen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  -  http://www.santec.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Processing Images without displaying them on the screen

Wayne Rasband
The ij.plugin.RGBStackMerge plugin, which implements the
Image>Color>RGB Merge command, has a public mergeStacks() method you
can call. Here is an example:

     ImagePlus red = IJ.createImage("Red", "8-bit Ramp", 512, 512, 10);
     ImagePlus green = IJ. createImage("Green", "8-bit Ramp", 512, 512,
10);
     WindowManager.setTempCurrentImage(green);
     IJ.run("Flip Horizontally", "stack");
     int w = red.getWidth();
     int h = red.getHeight();
     int d = red.getStackSize();
     RGBStackMerge rsm = new RGBStackMerge();
     ImageStack rgb = rsm.mergeStacks(w, h, d, red.getStack(),
green.getStack(), null, false);
     new ImagePlus("rgb", rgb).show();

The ij.plugin.ImageCalculator plugin has a similar calculate() method:

     ImagePlus red = IJ.createImage("Red", "8-bit Ramp", 512, 512, 10);
     ImagePlus green = IJ. createImage("Green", "8-bit Ramp", 512, 512,
10);
     WindowManager.setTempCurrentImage(green);
     IJ.run("Flip Horizontally", "stack");
     ImageCalculator ic = new ImageCalculator();
     ic.calculate("difference stack create", red, green);

The string argument of the calculate method is the same as the first
argument of the imageCalculator() macro function.

-wayne

On Aug 30, 2006, at 5:38 AM, Andreas Jahnen wrote:

> Dear ImageJ Users,
>
> In my current project, I use ImageJ more as a library then directly as
> a
> tool. We have some constraints, which makes it better this way. For
> this
> reason I do not work with visible ImageJ windows on my desktop. This
> works
> fine, here is a example
>
> // get the a image from somewhere:
> ImagePlus image_red = m_array.getRedImage();
>
> // do some processing:
> WindowManager.setTempCurrentImage(image_red);
> IJ.run("Enhance Contrast", "saturated=0.5 normalize equalize");
> IJ.run("Red");
>
> image_red.updateImage();
>
> Especially this is fine, as I can test my problems in ImageJ and then
> integrate this directly into my programme.
>
> With this I have one problem: I can not use plugins and functions that
> are
> using more than the "TempCurrentImage", for example the following
> commands:
>
> - Merge RGB...
> - Image Calculator...
>
> Does anybody know a solution, that I can do the following without
> displaying images on the screen?
>
> // some not working code, that should demonstrate what I want to do:
> // get the a images from somewhere:
> ImagePlus image_red = m_array.getRedImage();
> ImagePlus image_green = m_array.getGreenImage();
>
> // do some processing:
> WindowManager.setTempCurrentImage("red", image_red);
> WindowManager.setTempCurrentImage("green", image_green);
>
> IJ.run("RGB Merge...", "red=[red] green=[green]");
>
> Thank you very much,
>
> Andreas
>
> -----------------------------------------------------------------
> Andreas Jahnen  -  Ingenieur de Recherche
> [hidden email]
> -----------------------------------------------------------------
> CRP Henri Tudor  -  http://www.santec.lu
> 29, Avenue John F. Kennedy
> L-1855 Luxembourg
> -----------------------------------------------------------------
>