a simple question: using imagej source code and macros

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

a simple question: using imagej source code and macros

Chris Clarin
Good day,

I need to access imagej source codes via my own java program. i was able to
do it using the API until i discovered that i could just put everything in a
macro and just run the macro from my java program. this is what i'm trying
to do now but can't. I'm thinking that what I'm doing may be too simple, is
this correct:

public static void main (String args[]) {
        File blobs = new File ("blobs.txt");
        MacroRunner macro2 = new MacroRunner (blobs);
        macro2.run();
    }

this is the exception that I am getting: NullPointerException and this is
what gets printed out in the console:

File is not in TIFF, JPEG, GIF, BMP, DICOM, FITS, PGM,
ZIP, LUT, ROI or text format, a reader plugin for this
format is not installed, or it was not found.

Why is this so? I am sure that blobs.txt exist though and am hoping that
whatever is in blobs.txt gets run.

I tried to use the string constructor as well, doing this:

MacroRunner macro = new MacroRunner (" run(\"Blobs (25K)\");  \n
setAutoThreshold();");

and it runs perfectly. I'm just a little puzzled with why the one where i am
using a file is not working.

Thank you, hoping to have your help on this one

-- christine
-------------------------------------------------------------------
Christine T. Clarin
UP Department of Computer Science
Work/Fax: (02) 434-3877
Mobile: (+63917) 482-3606
Email: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: a simple question: using imagej source code and macros

Albert Cardona
Chris,


The MacroRunner is expecting the full path to your blobs.txt macro file.

Albert


> public static void main (String args[]) {
>         File blobs = new File ("blobs.txt");
>         MacroRunner macro2 = new MacroRunner (blobs);
>         macro2.run();
>     }
>  

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: a simple question: using imagej source code and macros

Harry Parker
In reply to this post by Chris Clarin
Hello Christine,

I think the problem you are seeing is that the paths that ImageJ uses to look for macros in the run command is different than the ones it uses for the File command. The most reliable thing to do is always specify the full path of a file you want.
 
--  
Harry Parker  
Senior Systems Engineer  
Digital Imaging Systems, Inc.

----- Original Message ----
From: Chris Clarin <[hidden email]>
To: [hidden email]
Sent: Tuesday, February 12, 2008 6:37:00 AM
Subject: a simple question: using imagej source code and macros

Good
day,

I
need
to
access
imagej
source
codes
via
my
own
java
program.
i
was
able
to
do
it
using
the
API
until
i
discovered
that
i
could
just
put
everything
in
a
macro
and
just
run
the
macro
from
my
java
program.
this
is
what
i'm
trying
to
do
now
but
can't.
I'm
thinking
that
what
I'm
doing
may
be
too
simple,
is
this
correct:

public
static
void
main
(String
args[])
{
 
 
 
 
File
blobs
=
new
File
("blobs.txt");
 
 
 
 
MacroRunner
macro2
=
new
MacroRunner
(blobs);
 
 
 
 
macro2.run();
 
 
}

this
is
the
exception
that
I
am
getting:
NullPointerException
and
this
is
what
gets
printed
out
in
the
console:

File
is
not
in
TIFF,
JPEG,
GIF,
BMP,
DICOM,
FITS,
PGM,
ZIP,
LUT,
ROI
or
text
format,
a
reader
plugin
for
this
format
is
not
installed,
or
it
was
not
found.

Why
is
this
so?
I
am
sure
that
blobs.txt
exist
though
and
am
hoping
that
whatever
is
in
blobs.txt
gets
run.

I
tried
to
use
the
string
constructor
as
well,
doing
this:

MacroRunner
macro
=
new
MacroRunner
("
run(\"Blobs
(25K)\");  
\n
setAutoThreshold();");

and
it
runs
perfectly.
I'm
just
a
little
puzzled
with
why
the
one
where
i
am
using
a
file
is
not
working.

Thank
you,
hoping
to
have
your
help
on
this
one

--
christine
-------------------------------------------------------------------
Christine
T.
Clarin
UP
Department
of
Computer
Science
Work/Fax:
(02)
434-3877
Mobile:
(+63917)
482-3606
Email:
[hidden email]





      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs