Several beginner questions about LUTs

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

Several beginner questions about LUTs

CARL Philippe (LBP)
Dear all,
I never really played with LUTs before and thus may have a couple of probably silly questions about them.
So what I would like to do is to apply certain LUTs on an ImageProcessor.
Browsing on the web, I found the following code:
        IndexColorModel cm;
        try
        {
                LutLoader lutLoader = new LutLoader();
                cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
        }
        catch (Exception e)
        {
                IJ.error("error reading LUT file");
        }
with lut one of the LUT filename found within the "luts" folder.
Then I want to apply the loaded LUT to an image with:
        ip.setColorModel(cm);
ip being an ImageProcessor.
But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
Why is there this difference between the use of the classes?
Also the:
        ip.setColorModel(cm);
application seems not to be working within my code, so how could I locate my error?
At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
I thank you very much in advance for your help on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

Michael Schmid
Hi Philippe,

as far as I can see, the ij.plugin.LutLoader class currently has no
public method to access the built-in LUTs without craeting an image and
assigning a LUT to it with 'IJ.run'.
The LutLoader creates the built-in LUTS "fire", "grays", "ice",
"spectrum", "3-3-2 RGB", "red", "green", "blue", "cyan", "magenta",
"yellow", "redgreen".

I think that such a public method would be nice to have (but it would be
a bit of work to modify the LutLoader to get it).


Michael
________________________________________________________________
On 06.07.20 02:16, CARL Philippe (LBP) wrote:

> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.
> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 42 89
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

CARL Philippe (LBP)
Hi Michael,
How are you doing?
I mostly solved the issues I had described below and similarly to you I saw that there aren't really public methods to access the built-in LUTS.
So what I did is (for each of them) to declare a String[] within which I manually copied the data I could find under Image>Color>Show_LUT>List.
I agree that this can probably be considered as "bad programming" but at least it is working...
Nevertheless something I still have to work on, is to find a way to transform IndexColorModel data into a form similar to what is given by Image>Color>Show_LUT>List.
And I guess there are some plugins out there already doing this.
Kndest regards,
Philippe

----- Mail original -----
De: "Michael Schmid" <[hidden email]>
À: "imagej" <[hidden email]>
Cc: "CARL Philippe, LBP" <[hidden email]>
Envoyé: Mardi 7 Juillet 2020 13:23:09
Objet: Re: Several beginner questions about LUTs

Hi Philippe,

as far as I can see, the ij.plugin.LutLoader class currently has no
public method to access the built-in LUTs without craeting an image and
assigning a LUT to it with 'IJ.run'.
The LutLoader creates the built-in LUTS "fire", "grays", "ice",
"spectrum", "3-3-2 RGB", "red", "green", "blue", "cyan", "magenta",
"yellow", "redgreen".

I think that such a public method would be nice to have (but it would be
a bit of work to modify the LutLoader to get it).


Michael
________________________________________________________________
On 06.07.20 02:16, CARL Philippe (LBP) wrote:

> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.
> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 42 89
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

Michael Schmid
Hi Philippe,

the Glasbey LUT file is ascii, not binary; you can open it with a text
editor.

Other ascii LUTs in my LUT directory:

5_Ramps.lut
Jet.lut
Sepia.lut
UnionJack.lut

LutLoader.open opens binary LUT files only.

LutLoader.openLut(String pathOrURL) detects the file type and then uses
the appropriate method for opening. In contrast to LutLoader.open it
does not return an ImageColorModel but an ImageJ ij.process.LUT

This is not really obvious, one has to read the LutLoader code rather
carefully to find out. So it's not really beginner's questions that you
are asking.

Best,

Michael
________________________________________________________________
On 08.07.20 16:48, CARL Philippe (LBP) wrote:

> Hi Michael,
> I may have talked quite too fast yesterday!
> Indeed if you look at the following code:
> http://punias.free.fr/ImageJ/LutLoaderAndLister.java
> and try to apply it on some binary compressed LUTs that can be found within the "luts" folder (like edges or cool) and compare it to the results of doing Image>Lookup_Tables and then Image>Color>Show_LUT you will already find some slight differences.
> But these differences will be even worse when trying to apply the plugin on some text file LUTs like Jet or Glasbey.
> These issues come from the use of the LutLoader class but I can't figure out the origin of them.
> I thank you very much in advance for your help on this and feel free to make your answer on the list if you think it may be of common interest.
> Kindest regards,
> Philippe
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

Wayne Rasband-2
In reply to this post by CARL Philippe (LBP)
> On Jul 5, 2020, at 8:16 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.

The ImageJ 1.53d15 daily build adds a static LutLoader.getLut(name) method that returns an IndexColorModel for any of the LUTs listed in the Image>Lookup Tables menu.

Here is a JavaScript example:

 img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
 img.show();
 setLut(img,"Fire");
 setLut(img,"Ice");
 setLut(img,"Cyan");
 setLut(img,"Phase");
 setLut(img,"Edges");
 setLut(img,"Cyan Hot");
 setLut(img,"Cool");
 setLut(img,"Glasbey");
 setLut(img,"Viridis");

 function setLut(img, name) {
   ip = img.getProcessor();
   lut = LutLoader.getLut(name);
   if (lut!=null)
      ip.setColorModel(lut);
   else
       name = "Not found: "+name;
   img.setTitle(name);
   msg = new TextRoi(10,10,name);
   msg.setFontSize(40);
   msg.setStrokeColor(Color.yellow);
   img.setOverlay(new Overlay(msg));
   img.updateAndDraw();
   IJ.wait(2000);    
 }


> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> My best regards,
> Philippe

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

CARL Philippe (LBP)
Dear Wayne,
Thanks a lot for this update!
It is working as a charm both for the built-in LUTs as the one within the "luts" folder and this way more easily than before.
Take care,
Philippe

----- Le 9 Juil 20, à 3:16, Wayne Rasband [hidden email] a écrit :

> On Jul 5, 2020, at 8:16 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.

The ImageJ 1.53d15 daily build adds a static LutLoader.getLut(name) method that returns an IndexColorModel for any of the LUTs listed in the Image>Lookup Tables menu.

Here is a JavaScript example:

 img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
 img.show();
 setLut(img,"Fire");
 setLut(img,"Ice");
 setLut(img,"Cyan");
 setLut(img,"Phase");
 setLut(img,"Edges");
 setLut(img,"Cyan Hot");
 setLut(img,"Cool");
 setLut(img,"Glasbey");
 setLut(img,"Viridis");

 function setLut(img, name) {
   ip = img.getProcessor();
   lut = LutLoader.getLut(name);
   if (lut!=null)
      ip.setColorModel(lut);
   else
       name = "Not found: "+name;
   img.setTitle(name);
   msg = new TextRoi(10,10,name);
   msg.setFontSize(40);
   msg.setStrokeColor(Color.yellow);
   img.setOverlay(new Overlay(msg));
   img.updateAndDraw();
   IJ.wait(2000);    
 }


> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> My best regards,
> Philippe

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

CARL Philippe (LBP)
Dear Wayne,
I may have talked slightly too fast!
Your code is working as a charm for all LUTs besides the "3-3-2 RGB" and "Red/Green" ones.
Nevertheless by replacing the line 24 of the latest ij.plugin.LutLoader.java file, i.e.:
                FileInfo fi = ll.getBuiltInLut(name.toLowerCase());
by
                name = name.equals("3-3-2 RGB") ? "3-3-2 RGB" : name.replace("/", "").toLowerCase();
                FileInfo fi = ll.getBuiltInLut(name);
will already make the deal.
Again thanks a lot your update which simplifies a lot my code and have a nice day.
Kindest regards,
Philippe

----- Mail original -----
De: "CARL Philippe, LBP" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Jeudi 9 Juillet 2020 13:36:52
Objet: Re: Several beginner questions about LUTs

Dear Wayne,
Thanks a lot for this update!
It is working as a charm both for the built-in LUTs as the one within the "luts" folder and this way more easily than before.
Take care,
Philippe

----- Le 9 Juil 20, à 3:16, Wayne Rasband [hidden email] a écrit :

> On Jul 5, 2020, at 8:16 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.

The ImageJ 1.53d15 daily build adds a static LutLoader.getLut(name) method that returns an IndexColorModel for any of the LUTs listed in the Image>Lookup Tables menu.

Here is a JavaScript example:

 img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
 img.show();
 setLut(img,"Fire");
 setLut(img,"Ice");
 setLut(img,"Cyan");
 setLut(img,"Phase");
 setLut(img,"Edges");
 setLut(img,"Cyan Hot");
 setLut(img,"Cool");
 setLut(img,"Glasbey");
 setLut(img,"Viridis");

 function setLut(img, name) {
   ip = img.getProcessor();
   lut = LutLoader.getLut(name);
   if (lut!=null)
      ip.setColorModel(lut);
   else
       name = "Not found: "+name;
   img.setTitle(name);
   msg = new TextRoi(10,10,name);
   msg.setFontSize(40);
   msg.setStrokeColor(Color.yellow);
   img.setOverlay(new Overlay(msg));
   img.updateAndDraw();
   IJ.wait(2000);    
 }


> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

CARL Philippe (LBP)
Dear Wayne (I promise my last reply on this!),
Actually the two lines I proposed below for replacing the line 24 of the ij.plugin.LutLoader.java file can be replaced by the single following line:
                FileInfo fi = ll.getBuiltInLut(name.equals("3-3-2 RGB") ? "3-3-2 RGB" : name.replace("/", "").toLowerCase());
Also slightly modifying the javascript example you gave below by:
        img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
        img.show();
        lutList = IJ.getLuts();
        for(i = 0; i < lutList.length; i++)
                setLut(img,lutList[i]);

        function setLut(img, name) {
                ip = img.getProcessor();
                lut = LutLoader.getLut(name);
                if (lut!=null)
                ip.setColorModel(lut);
                else
                        name = "Not found: "+name;
                img.setTitle(name);
                msg = new TextRoi(10,10,name);
                msg.setFontSize(40);
                msg.setStrokeColor(Color.yellow);
                img.setOverlay(new Overlay(msg));
                img.updateAndDraw();
                IJ.wait(2000);    
        }
gives a cool way to visualize the different LUTs installed on a machine (in parallel to he already existing Image>Color>Display_LUTs).
Kindest regards,
Philippe

----- Le 9 Juil 20, à 14:24, CARL Philippe, LBP [hidden email] a écrit :

Dear Wayne,
I may have talked slightly too fast!
Your code is working as a charm for all LUTs besides the "3-3-2 RGB" and "Red/Green" ones.
Nevertheless by replacing the line 24 of the latest ij.plugin.LutLoader.java file, i.e.:
                FileInfo fi = ll.getBuiltInLut(name.toLowerCase());
by
                name = name.equals("3-3-2 RGB") ? "3-3-2 RGB" : name.replace("/", "").toLowerCase();
                FileInfo fi = ll.getBuiltInLut(name);
will already make the deal.
Again thanks a lot your update which simplifies a lot my code and have a nice day.
Kindest regards,
Philippe

----- Mail original -----
De: "CARL Philippe, LBP" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Jeudi 9 Juillet 2020 13:36:52
Objet: Re: Several beginner questions about LUTs

Dear Wayne,
Thanks a lot for this update!
It is working as a charm both for the built-in LUTs as the one within the "luts" folder and this way more easily than before.
Take care,
Philippe

----- Le 9 Juil 20, à 3:16, Wayne Rasband [hidden email] a écrit :

> On Jul 5, 2020, at 8:16 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear all,
> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
> So what I would like to do is to apply certain LUTs on an ImageProcessor.

The ImageJ 1.53d15 daily build adds a static LutLoader.getLut(name) method that returns an IndexColorModel for any of the LUTs listed in the Image>Lookup Tables menu.

Here is a JavaScript example:

 img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
 img.show();
 setLut(img,"Fire");
 setLut(img,"Ice");
 setLut(img,"Cyan");
 setLut(img,"Phase");
 setLut(img,"Edges");
 setLut(img,"Cyan Hot");
 setLut(img,"Cool");
 setLut(img,"Glasbey");
 setLut(img,"Viridis");

 function setLut(img, name) {
   ip = img.getProcessor();
   lut = LutLoader.getLut(name);
   if (lut!=null)
      ip.setColorModel(lut);
   else
       name = "Not found: "+name;
   img.setTitle(name);
   msg = new TextRoi(10,10,name);
   msg.setFontSize(40);
   msg.setStrokeColor(Color.yellow);
   img.setOverlay(new Overlay(msg));
   img.updateAndDraw();
   IJ.wait(2000);    
 }


> Browsing on the web, I found the following code:
> IndexColorModel cm;
> try
> {
> LutLoader lutLoader = new LutLoader();
> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
> }
> catch (Exception e)
> {
> IJ.error("error reading LUT file");
> }
> with lut one of the LUT filename found within the "luts" folder.
> Then I want to apply the loaded LUT to an image with:
> ip.setColorModel(cm);
> ip being an ImageProcessor.
> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
> Why is there this difference between the use of the classes?
> Also the:
> ip.setColorModel(cm);
> application seems not to be working within my code, so how could I locate my error?
> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
> I thank you very much in advance for your help on this.
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Several beginner questions about LUTs

Wayne Rasband-2
Hi Philippe,

I  had forgotten about the IJ.getLuts() method! I changed the name of the JavaScript example to “Show_all_LUTs.js”, fixed the problems with "3-3-2 RGB" and "Red/Green”, and added it (in 1.53d17) to the Help>Examples>JavaScript menu.

-wayne


> On Jul 9, 2020, at 10:49 AM, CARL Philippe (LBP) <[hidden email]> wrote:
>
> Dear Wayne (I promise my last reply on this!),
> Actually the two lines I proposed below for replacing the line 24 of the ij.plugin.LutLoader.java file can be replaced by the single following line:
> FileInfo fi = ll.getBuiltInLut(name.equals("3-3-2 RGB") ? "3-3-2 RGB" : name.replace("/", "").toLowerCase());
> Also slightly modifying the javascript example you gave below by:
> img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
> img.show();
> lutList = IJ.getLuts();
> for(i = 0; i < lutList.length; i++)
> setLut(img,lutList[i]);
>
> function setLut(img, name) {
> ip = img.getProcessor();
> lut = LutLoader.getLut(name);
> if (lut!=null)
> ip.setColorModel(lut);
> else
> name = "Not found: "+name;
> img.setTitle(name);
> msg = new TextRoi(10,10,name);
> msg.setFontSize(40);
> msg.setStrokeColor(Color.yellow);
> img.setOverlay(new Overlay(msg));
> img.updateAndDraw();
> IJ.wait(2000);    
> }
> gives a cool way to visualize the different LUTs installed on a machine (in parallel to he already existing Image>Color>Display_LUTs).
> Kindest regards,
> Philippe
>
> ----- Le 9 Juil 20, à 14:24, CARL Philippe, LBP [hidden email] a écrit :
>
> Dear Wayne,
> I may have talked slightly too fast!
> Your code is working as a charm for all LUTs besides the "3-3-2 RGB" and "Red/Green" ones.
> Nevertheless by replacing the line 24 of the latest ij.plugin.LutLoader.java file, i.e.:
> FileInfo fi = ll.getBuiltInLut(name.toLowerCase());
> by
> name = name.equals("3-3-2 RGB") ? "3-3-2 RGB" : name.replace("/", "").toLowerCase();
> FileInfo fi = ll.getBuiltInLut(name);
> will already make the deal.
> Again thanks a lot your update which simplifies a lot my code and have a nice day.
> Kindest regards,
> Philippe
>
> ----- Mail original -----
> De: "CARL Philippe, LBP" <[hidden email]>
> À: "imagej" <[hidden email]>
> Envoyé: Jeudi 9 Juillet 2020 13:36:52
> Objet: Re: Several beginner questions about LUTs
>
> Dear Wayne,
> Thanks a lot for this update!
> It is working as a charm both for the built-in LUTs as the one within the "luts" folder and this way more easily than before.
> Take care,
> Philippe
>
> ----- Le 9 Juil 20, à 3:16, Wayne Rasband [hidden email] a écrit :
>
>> On Jul 5, 2020, at 8:16 PM, CARL Philippe (LBP) <[hidden email]> wrote:
>>
>> Dear all,
>> I never really played with LUTs before and thus may have a couple of probably silly questions about them.
>> So what I would like to do is to apply certain LUTs on an ImageProcessor.
>
> The ImageJ 1.53d15 daily build adds a static LutLoader.getLut(name) method that returns an IndexColorModel for any of the LUTs listed in the Image>Lookup Tables menu.
>
> Here is a JavaScript example:
>
> img = IJ.createImage("Untitled", "8-bit ramp", 500, 300, 1);
> img.show();
> setLut(img,"Fire");
> setLut(img,"Ice");
> setLut(img,"Cyan");
> setLut(img,"Phase");
> setLut(img,"Edges");
> setLut(img,"Cyan Hot");
> setLut(img,"Cool");
> setLut(img,"Glasbey");
> setLut(img,"Viridis");
>
> function setLut(img, name) {
>   ip = img.getProcessor();
>   lut = LutLoader.getLut(name);
>   if (lut!=null)
>      ip.setColorModel(lut);
>   else
>       name = "Not found: "+name;
>   img.setTitle(name);
>   msg = new TextRoi(10,10,name);
>   msg.setFontSize(40);
>   msg.setStrokeColor(Color.yellow);
>   img.setOverlay(new Overlay(msg));
>   img.updateAndDraw();
>   IJ.wait(2000);    
> }
>
>
>> Browsing on the web, I found the following code:
>> IndexColorModel cm;
>> try
>> {
>> LutLoader lutLoader = new LutLoader();
>> cm = lutLoader.open(IJ.getDirectory("luts") + lut + ".lut");
>> }
>> catch (Exception e)
>> {
>> IJ.error("error reading LUT file");
>> }
>> with lut one of the LUT filename found within the "luts" folder.
>> Then I want to apply the loaded LUT to an image with:
>> ip.setColorModel(cm);
>> ip being an ImageProcessor.
>> But ImageProcessor.setColorModel(java.awt.image.ColorModel cm)
>> And LutLoader.open(java.lang.String path) returns an java.awt.image.IndexColorModel.
>> So what is the difference between an IndexColorModel and ColorModel (besides the fact that IndexColorModel extends ColorModel)?
>> Why is there this difference between the use of the classes?
>> Also the:
>> ip.setColorModel(cm);
>> application seems not to be working within my code, so how could I locate my error?
>> At last, the LutLoader.open(java.lang.String path) can be used to get the IndexColorModel of LUTs saved in the "luts" folder.
>> But some LUTS (like "fire", "ice",...) are directly defined within the ij.plugin.LutLoader class.
>> Thus how is it possible to get a handle to the IndexColorModel of these LUTs?
>> I thank you very much in advance for your help on this.
>> 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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

'Show Folder' does not show folder

Gabriel Landini
Hi,
I wonder if this is only a linux bug (I confess that I had never used the
"File>Show Folder" command before!)

Launching that command opens the File Manager which gives an error saying:

The file or folder /home/gabriel/ImageJ/'/home/gabriel/ImageJ' does not exist.
It looks like if  IJ tries to find that path inside the folder where IJ is
already running from?

At the same time, the console also shows these messages:

Trying to convert empty KLocalizedString to QString.
kdeinit5: Shutting down running client.
klauncher: Exiting on signal 15
Connecting to deprecated signal
QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)

Any ideas?
Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 'Show Folder' does not show folder

Wayne Rasband-2
The very useful File>Show Folder> commands, contributed by Norbert Vischer, work fine on the ancient Ubuntu 14.04 LTS system I use for testing, running inside VirtualBox on my Mac laptop.

-wayne


> On Jul 9, 2020, at 3:35 PM, Gabriel Landini <[hidden email]> wrote:
>
> Hi,
> I wonder if this is only a linux bug (I confess that I had never used the
> "File>Show Folder" command before!)
>
> Launching that command opens the File Manager which gives an error saying:
>
> The file or folder /home/gabriel/ImageJ/'/home/gabriel/ImageJ' does not exist.
> It looks like if  IJ tries to find that path inside the folder where IJ is
> already running from?
>
> At the same time, the console also shows these messages:
>
> Trying to convert empty KLocalizedString to QString.
> kdeinit5: Shutting down running client.
> klauncher: Exiting on signal 15
> Connecting to deprecated signal
> QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
>
> Any ideas?
> Cheers
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 'Show Folder' does not show folder

Gabriel Landini
On Thursday, 9 July 2020 20:59:31 BST [hidden email] wrote:
> The very useful File>Show Folder> commands, contributed by Norbert Vischer,
> work fine on the ancient Ubuntu 14.04 LTS system I use for testing, running
> inside VirtualBox on my Mac laptop.

Hi Wayne,
Thanks for looking into it. Unfortunately it does not work on opensuse Leap
15.1, or in Kubuntu 18.04 (different machines) (both up to date).

For Kubuntu IJ gives a different error:

Failed to Show Folder: java.io.IOException: Failed to show URL: file:/home/
gabriel/ImageJ/
(the folder is where IJ is installed, so it exists. There is no File Manager
launched.

I tried again in Leap 15.1 with Java 1.6.0 and I get a different error, this
time from IJ itself.

ImageJ 1.53d17; Java 1.6.0_24 [64-bit]; Linux 4.12.14-lp151.28.52-default;
27MB of 8000MB (<1%)
 
java.lang.UnsupportedOperationException: Desktop API is not supported on the
current platform
        at java.awt.Desktop.getDesktop(Desktop.java:126)
        at ij.plugin.SimpleCommands.showDirectory(SimpleCommands.java:244)
        at ij.plugin.SimpleCommands.run(SimpleCommands.java:56)
        at ij.IJ.runPlugIn(IJ.java:204)
        at ij.Executer.runCommand(Executer.java:150)
        at ij.Executer.run(Executer.java:68)
        at java.lang.Thread.run(Thread.java:662)

Regards

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: 'Show Folder' does not show folder

Aryeh Weiss
On 09/07/2020 23:33, Gabriel Landini wrote:

> On Thursday, 9 July 2020 20:59:31 BST [hidden email] wrote:
>> The very useful File>Show Folder> commands, contributed by Norbert Vischer,
>> work fine on the ancient Ubuntu 14.04 LTS system I use for testing, running
>> inside VirtualBox on my Mac laptop.
> Hi Wayne,
> Thanks for looking into it. Unfortunately it does not work on opensuse Leap
> 15.1, or in Kubuntu 18.04 (different machines) (both up to date).
>
> For Kubuntu IJ gives a different error:
>
> Failed to Show Folder: java.io.IOException: Failed to show URL: file:/home/
> gabriel/ImageJ/
> (the folder is where IJ is installed, so it exists. There is no File Manager
> launched.
>
> I tried again in Leap 15.1 with Java 1.6.0 and I get a different error, this
> time from IJ itself.
>
> ImageJ 1.53d17; Java 1.6.0_24 [64-bit]; Linux 4.12.14-lp151.28.52-default;
> 27MB of 8000MB (<1%)
>  
> java.lang.UnsupportedOperationException: Desktop API is not supported on the
> current platform
> at java.awt.Desktop.getDesktop(Desktop.java:126)
> at ij.plugin.SimpleCommands.showDirectory(SimpleCommands.java:244)
> at ij.plugin.SimpleCommands.run(SimpleCommands.java:56)
> at ij.IJ.runPlugIn(IJ.java:204)
> at ij.Executer.runCommand(Executer.java:150)
> at ij.Executer.run(Executer.java:68)
> at java.lang.Thread.run(Thread.java:662)
>
> Regards
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Works on POP OS (Ubuntu 20.04). If you want additional environment into,
let me know.

--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html