http://imagej.273.s1.nabble.com/Programatically-apply-LUT-to-16-bit-gray-image-tp5010690p5010703.html
Thanks very much Wayne. It works but I can't use a file picker to select
the LUT. I need to specify the directory and file name or the full path
production mode. I've been studying the link Jerome provided but to no
avail.
> On Nov 29, 2014, at 6:04 PM, Robert Lockwood <
[hidden email]> wrote:
> >
> > I have dropped a couple of LUT's in the LUT folder of FiJi and want to
> > apply them in my Java Application to some test images (RAW) that I've
> been
> > able to read in and display.
>
> Here is a JavaScript example that creates a 16-bit image, opens a LUT from
> the luts folder, applies the LUT to the image, displays the image, gets the
> pixel data, modifies it, updates the display, saves the image in PNG
> format, opens the PNG and displays it. It requires the latest ImageJ daily
> build (1.49n1), which adds the Opener.openLut() method.
>
> -wayne
>
> img = IJ.createImage("Untitled", "16-bit ramp", 500, 500, 1);
> ip = img.getProcessor();
> lut = Opener.openLut(IJ.getDirectory("luts")+"Cool.lut");
> if (lut!=null)
> ip.setLut(lut);
> img.show();
> pixels = ip.getPixels();
> for (i=0; i<pixels.length; i++)
> pixels[i] = -32768 + i%65536;
> img.updateAndDraw();
> path = IJ.getDirectory("temp")+"Untitled.png";
> IJ.saveAs(img, "PNG", path);
> img2 = IJ.openImage(path);
> img2.show();
>
>
> > My testing code:
> >
> > fi = new FileInfo();
> > fi.fileName = input_file;
> > fi.fileType = FileInfo.GRAY16_UNSIGNED;
> > fi.width = imgWidth;
> > fi.height = imgHeight;
> > fi.intelByteOrder = false;
> > fo = new FileOpener(fi);
> > imp = fo.open(false);
> > if (imp != null) {
> > ip = (ShortProcessor) imp.getProcessor();
> > bi = ip.get16BitBufferedImage();
> > new ImagePlus(input_file, bi).show();
> > }
> >
> >
> > How to I import the LUT into my code. It appears that if I have an LUT I
> > can set it but I don't know how to import it.
> >
> > My objective, after a suitable LUT is found, is to save the image as a
> PNG.
> >
> >
> > --
> > When I was 12 I thought I would live forever.
> > So far, so good.
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
When I was 12 I thought I would live forever.
So far, so good.