Import Text Image

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

Import Text Image

Ariadne MV
Hi,
I need to open an image from a text file.  
In the program is the command:  File>Import>Text Image…  
But I need call it since my program, but I don’t know how.

I have found the next functions but they aren’t enough.
createImagePlus();  
openImage(path);
openTiff(arg0, arg1)

Also to others "import" there is a specific class, like to File>Import>URL, there is URLOpener, but I can’t find to import a text file like an image.

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

Re: Import Text Image

Michael Schmid
Hi Ariadne,

for writing a plugin, the easiest is using the Macro Recorder (Plugins>Macros>Record); set it to 'Plugin' mode in the top of the Macro Recorder panel. The code created will do essentially the same as if you do it manually, i.e., create an ImagePlus and display it.

Alternatively, use [ctrl]-l (lowercase L) to find the command, select "Show Full Information" and you will see the path to its source code, in this case ij.plugin.TextReader.

There you can have a look whether it provides public methods that you can directly call from java. In this case, you can try the open(String path) method, which gives you an ImageProcessor (and does not display it).

Don't forget to import ij.plugin.TextReader in your plugin and to have a new TextReader() for the open method (because open is not static).

Michael
________________________________________________________________
On Nov 22, 2012, at 13:55, Ariadne MV wrote:

> Hi,
> I need to open an image from a text file.  
> In the program is the command:  File>Import>Text Image…  
> But I need call it since my program, but I don’t know how.
>
> I have found the next functions but they aren’t enough.
> createImagePlus();  
> openImage(path);
> openTiff(arg0, arg1)
>
> Also to others "import" there is a specific class, like to File>Import>URL, there is URLOpener, but I can’t find to import a text file like an image.
>
> Thanks!

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

Re: Import Text Image

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Ariadne MV
On Nov 22, 2012, at 7:55 AM, Ariadne MV wrote:

> Hi,
> I need to open an image from a text file.  
> In the program is the command:  File>Import>Text Image…  
> But I need call it since my program, but I don’t know how.
>
> I have found the next functions but they aren’t enough.
> createImagePlus();  
> openImage(path);
> openTiff(arg0, arg1)
>
> Also to others "import" there is a specific class, like to File>Import>URL, there is URLOpener, but I can’t find to import a text file like an image.

You can open a text file as an image using:

    IJ.run("Text Image... ", "open="+path);

I found this method by using the File>Import>Text Image command with the recorder (Plugins>Macros>Record) running.

Or you can open a text window without displaying it using:

   ImageProcessor ip = new TextReader().open(path);
   // new ImagePlus(path,ip).show();

I found this method by looking at the source code of the class in ImageJ (TextReader) that opens text images. I found the source code by typing "l" (Plugins>Utilities>Find Commands), entering "text image", clicking on "Show full information", selecting

   Text Image... (in File>Import [ij.plugin.TextReader]

from the list and clicking on the "Source" button. The "Source" button was added to the command finder in ImageJ 1.47c.

-wayne

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

Re: Import Text Image

Ariadne MV
Thanks!

I didn't know how find a command, your answers had been very helpful.

Regards,
Ariadne




> Date: Thu, 22 Nov 2012 11:06:20 -0500
> From: [hidden email]
> Subject: Re: Import Text Image
> To: [hidden email]
>
> On Nov 22, 2012, at 7:55 AM, Ariadne MV wrote:
>
> > Hi,
> > I need to open an image from a text file.  
> > In the program is the command:  File>Import>Text Image…  
> > But I need call it since my program, but I don’t know how.
> >
> > I have found the next functions but they aren’t enough.
> > createImagePlus();  
> > openImage(path);
> > openTiff(arg0, arg1)
> >
> > Also to others "import" there is a specific class, like to File>Import>URL, there is URLOpener, but I can’t find to import a text file like an image.
>
> You can open a text file as an image using:
>
>     IJ.run("Text Image... ", "open="+path);
>
> I found this method by using the File>Import>Text Image command with the recorder (Plugins>Macros>Record) running.
>
> Or you can open a text window without displaying it using:
>
>    ImageProcessor ip = new TextReader().open(path);
>    // new ImagePlus(path,ip).show();
>
> I found this method by looking at the source code of the class in ImageJ (TextReader) that opens text images. I found the source code by typing "l" (Plugins>Utilities>Find Commands), entering "text image", clicking on "Show full information", selecting
>
>    Text Image... (in File>Import [ij.plugin.TextReader]
>
> from the list and clicking on the "Source" button. The "Source" button was added to the command finder in ImageJ 1.47c.
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
     
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html