As API: write GIF with lookup table

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

As API: write GIF with lookup table

Leonard Sitongia
I'm using ImageJ as an API in my own Java software.  It's a GUI-less program for use in batch jobs.  I can read a FITS image in, resize, annotate with text and write it as a PNG.  What I can't do is:

Write as a GIF:

The GIFWriter operates in GUI mode on an open image.  Can I use this from my GUI-less program?  Or another GIF Writer from someone?

Use a Lookup Table:

I can't figure out how to read one of the LUTs distributed with ImageJ and apply it to an image.  

Is a LUT turned into a LookupTable and applied to an ImagePlus?  I see a method to get a LUT from an ImagePlus, but not to set a LUT.

Is a LUT applied when writing a specific file format?  Read the Lookup Table, convert it to a format specific to a particular image file and set it in a Writer?

Thanks for your help.

==Leonard E. Sitongia
 High Altitude Observatory
 National Center for Atmospheric Research
 P.O. Box 3000 Boulder CO 80307  USA
 [hidden email]  voice: (303)497-2454  fax: (303)497-1589
Reply | Threaded
Open this post in threaded view
|

Re: As API: write GIF with lookup table

Rasband, Wayne (NIH/NIMH) [E]
On Oct 6, 2010, at 3:51 PM, Leonard Sitongia wrote:

> I'm using ImageJ as an API in my own Java software.  It's a GUI-less program for use in batch jobs.  I can read a FITS image in, resize, annotate with text and write it as a PNG.  What I can't do is:
>
> Write as a GIF:
>
> The GIFWriter operates in GUI mode on an open image.  Can I use this from my GUI-less program?  Or another GIF Writer from someone?
>
> Use a Lookup Table:
>
> I can't figure out how to read one of the LUTs distributed with ImageJ and apply it to an image.  
>
> Is a LUT turned into a LookupTable and applied to an ImagePlus?  I see a method to get a LUT from an ImagePlus, but not to set a LUT.
>
> Is a LUT applied when writing a specific file format?  Read the Lookup Table, convert it to a format specific to a particular image file and set it in a Writer?

Use the command recorder (Plugins>Macro>Record) to generate the needed code. As an example, this is the code generated with the recorder in "Plugin" mode when I opened a grayscale PNG, applied a LUT to it (using File>Import>LUT), and saved it in GIF format.

  public class My_Plugin implements PlugIn {
     public void run(String arg) {
        ImagePlus imp = IJ.openImage("/Users/wayne/test.png");
        IJ.run(imp, "LUT... ", "open=/Users/wayne/ImageJ/luts/cool.lut");
        IJ.saveAs(imp, "Gif", "/Users/wayne/test.gif");
     }
  }

-wayne