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. 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 |
Hi Robert,
Somehow, you should set fi.reds, fi.greens and fi.blues of your FileInfo object and then create and set a ColorModel as seen at: https://github.com/imagej/imagej1/blob/master/ij/plugin/LutLoader.java#L90 If you look at further in this class, you'll find various methods to set r,g,b arrays from different sources (create from scratch, or load from binary or text file). Jerome. On 30 November 2014 at 00:04, 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. > > 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 > -- Jerome Mutterer CNRS - Institut de biologie moléculaire des plantes 12, rue du Général Zimmer 67084 Strasbourg Cedex T 0367155339 www.ibmp.cnrs.fr -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Robert Lockwood
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 |
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 name since this will run without keyboard, mouse, and monitor when in production mode. I've been studying the link Jerome provided but to no avail. On Sun, Nov 30, 2014 at 12:27 PM, Rasband, Wayne (NIH/NIMH) [E] < [hidden email]> wrote: > 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. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |