Re: Pointing to a fixed directory structure
Posted by
ctrueden on
Oct 13, 2009; 7:24pm
URL: http://imagej.273.s1.nabble.com/Pointing-to-a-fixed-directory-structure-tp3690781p3690782.html
Hi Dean,
I have tried to read 3 bitmap images from the same directory and have been
> unable to set the correct path. Could you let me know from which location
> the path should be set relative to (i am running Eclipse on my PC):
>
Backslash literals in Java must be escaped with another backslash ("\\"),
because backslash is used to represent other special characters (tab is
"\t", newline is "\n", etc.).
So in your code, try:
String imagePath =
IJ.getDirectory("C:\\Code\\Java\\MyPlugin\\images\\test1.bmp");
It would probably also work with forward slashes.
-Curtis
On Tue, Oct 13, 2009 at 1:52 PM, Dean Raby <
[hidden email]> wrote:
> I am new to writing Java (2 months), but find the ImageJ a very interesting
> tool, and hope to write a few plugins to "quickly" test some imaging
> concepts. This work requires me to compare three images. The available
> examples, i have found, show the image information being taken from the
> image selected via the GUI however i need my plugin to read the contents
> from a fixed directory on the host PC. The image names will also be hard
> coded by the camera attached to the PC. If you have a pointer to a similar
> plugin or example it would be greatly appreciated.
>
> I have tried to read 3 bitmap images from the same directory and have been
> unable to set the correct path. Could you let me know from which location
> the path should be set relative to (i am running Eclipse on my PC):
>
> plugin directory path: C:\Code\Java\MyPlugin\src\test_.java
> image directory path: C:\Code\Java\MyPlugin\images\xxx.bmp
>
> I have tried using the full system path and the relative path and neither
> one seems to work.
>
> I am trying to use, to point to and open a test image:
>
> String imagePath =
> IJ.getDirectory("C:\Code\Java\MyPlugin\images\test1.bmp");
> dirPath = IJ.openAsString(imagePath);
> ImagePlus imp2 = IJ.openImage(dirPath);
>
> In the above code, the "slash" direction reflects that shown on the Eclipse
> tool, please let me know if is need to parse this and change the "slash"
> direction.
>
> thank you, Dean
>