Login  Register

Re: Relative location of files & LUT loading

Posted by Wayne Rasband on Jan 04, 2006; 5:15pm
URL: http://imagej.273.s1.nabble.com/Relative-location-of-files-LUT-loading-tp3704122p3704123.html

> 1. I am writing a LUT plugin applier so one can see the LUTs
> available before applying it.
> I am having trouble to direct the LUT importer because under
> linux, the path is expected to be described in full.
>
> For example, it does not find:
> IJ.run("LUT... ",  
> "path='\\ImageJ\\plugins\\Color\\LUTs\\"+LUTffile.lut+"'");
>
> but expects
> IJ.run("LUT... ",
> "path='\\home\\gabriel\\ImageJ\\plugins\\Color\\LUTs\\"+LUTffile.lut+"'
> ");
>
> This is less than ideal, because it will run only in those IJ
> users running linux and called "gabriel" :-)
>
> Is there a way to make the directory relative to the IJ directory
> (so it is independent of user or platform? Or what is the path
> of IJ at run time without having to use the Open Dialog?

Use the getDirectory() macro function, or IJ.getDirectory() method, to  
get the path to the ImageJ plugins directory:

     dir = getDirectory("plugins") + "Color/LUTs/";
     run("LUT... ", "path=["+dir+"LUTffile.lut]");

The "/" path separator works on all platforms, including windows. A "/"  
is always added to the end of paths returned by getDirectory(). The  
brackets ("[" and "]") are needed if the path contains spaces. The  
getDirectory() function can also get the path to the ImageJ  
("startup"), macros, home and temp folders, and to the folder that the  
current image was loaded from.

> 2.  In my List_LUTs plugin I had to put some delay to allow an image
> to apply an LUT before converting it to RGB.
>
> IJ.run("LUT... ", "path='"+dir+list[i]+"'");
> IJ.wait(200);
> IJ.run("RGB Color");
>
> It seems that the plugin sends the command to import the LUT, but
> the image conversion to RGB can take place before the LUT has
> been applied (and thus gives an error as the file is not 8bit grey
> anymore. Is there a solution to this other than inserting the delay as  
> above?

I do not see this problem on Mac OS X and Windows XP.

-wayne