Has anyone gone to the trouble of creating a JNI interface to many of the
ImageJ functions? I see a few very specific examples, but no comprehensive effort to make a general purpose JNI interface that allows access to all (or at least the most popular) functions. I have a lot of code written in C that analyzes ROI's from images and I would like to, as a simple example, display an image, draw a ROI, send the ROI from ImageJ to my C code, analyze the ROI, then send results back to ImageJ for plotting or other things. Therefore, I would prefer to use JNI than rewrite all my C code in Java. |
HI,
I´ve started playing around a bit with JNI for surporting new frame grabbers. As I understand you are mostly interested in calling foreign functions in a DLL from ImageJ and returning results, not trying to call ImageJ functions back from C, true? Or what are those "popular functions"? In that case one could think about a general dll interface as in the newer versions of Matlab, which is pretty nifty. Before that, you had to write a new MEX interface for each external function you wanted to use and convert from and to the internal data representation of Matlab variables and arrays. Now, Matlab can parse a .h file that describes the external dll for functions and will "automagically" invoke a wrapper that allocates, copies and converts the arguments and the return values to and from the dll, so no change to the dll and no extra glue code needed. Really nice. I think if you somehow wisely limited the allowed complexity of the function definitions (Matalb even does understand typedefs in the .h) for a first version such an interface to ImageJ could be doable, I already was thinking about adding such an interface to Euler (a free Matlab clone) some day. Joachim Dale Thayer <dale.thayer@TER An: [hidden email] ADYNE.COM> Kopie: (Blindkopie: Joachim Wesner/DEWET/LMSCentral/Leica) Gesendet von: Thema: JNI in ImageJ ImageJ Interest Group <[hidden email] .GOV> 24.04.2006 23:33 Bitte antworten an ImageJ Interest Group Has anyone gone to the trouble of creating a JNI interface to many of the ImageJ functions? I see a few very specific examples, but no comprehensive effort to make a general purpose JNI interface that allows access to all (or at least the most popular) functions. I have a lot of code written in C that analyzes ROI's from images and I would like to, as a simple example, display an image, draw a ROI, send the ROI from ImageJ to my C code, analyze the ROI, then send results back to ImageJ for plotting or other things. Therefore, I would prefer to use JNI than rewrite all my C code in Java. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Hello Joachim,
Yes, I meant to say that I am interested in using functions in DLL from ImageJ. For example, 1. Open a TIFF image in ImageJ 2. Draw a ROI using ImageJ. 3. Call DLL function from ImageJ that "transfers" the pixels in the ROI through a generic JNI interface. 4. Process the pixels in C code. 4. Return a few variables of results (perhaps float's, int's, or array of data) back to ImageJ via a generic JNI defined return function. 5. Display results in a dialog box from within ImageJ. As I understand it, I would write some Java plug-in that does step 3, sends ROI via JNI interface to DLL, then receives say a pointer to a structure with results, and then the plug-in would display the results, or plot the results. In other words, if a JNI "data transfer" interface could be written, then I could easily move data back and forth to my C code. One of the variables being passed to the C code could be a simple number that tells the C code which C function to execute, that way I don't have to define a JNI interface for every DLL function. Maybe there's a better way. Perhaps the ImageJ community has some ideas. Thanks for your response. I'll look into the Matlab suggestion. Dale Joachim Wesner <[hidden email]> Sent by: ImageJ Interest Group <[hidden email]> 04/24/2006 05:24 PM Please respond to ImageJ Interest Group <[hidden email]> To [hidden email] cc Subject Antwort: JNI in ImageJ HI, I´ve started playing around a bit with JNI for surporting new frame grabbers. As I understand you are mostly interested in calling foreign functions in a DLL from ImageJ and returning results, not trying to call ImageJ functions back from C, true? Or what are those "popular functions"? In that case one could think about a general dll interface as in the newer versions of Matlab, which is pretty nifty. Before that, you had to write a new MEX interface for each external function you wanted to use and convert from and to the internal data representation of Matlab variables and arrays. Now, Matlab can parse a .h file that describes the external dll for functions and will "automagically" invoke a wrapper that allocates, copies and converts the arguments and the return values to and from the dll, so no change to the dll and no extra glue code needed. Really nice. I think if you somehow wisely limited the allowed complexity of the function definitions (Matalb even does understand typedefs in the .h) for a first version such an interface to ImageJ could be doable, I already was thinking about adding such an interface to Euler (a free Matlab clone) some day. Joachim Dale Thayer <dale.thayer@TER An: [hidden email] ADYNE.COM> Kopie: (Blindkopie: Joachim Wesner/DEWET/LMSCentral/Leica) Gesendet von: Thema: JNI in ImageJ ImageJ Interest Group <[hidden email] .GOV> 24.04.2006 23:33 Bitte antworten an ImageJ Interest Group Has anyone gone to the trouble of creating a JNI interface to many of the ImageJ functions? I see a few very specific examples, but no comprehensive effort to make a general purpose JNI interface that allows access to all (or at least the most popular) functions. I have a lot of code written in C that analyzes ROI's from images and I would like to, as a simple example, display an image, draw a ROI, send the ROI from ImageJ to my C code, analyze the ROI, then send results back to ImageJ for plotting or other things. Therefore, I would prefer to use JNI than rewrite all my C code in Java. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Dale Thayer
You can try to use java.lang.Runtime to launch processes.
I use it to launch C programs from plugins, you can manage messages and errors from the program through a StreamGobbler class (found on the web)... Arnaud Quoting Dale Thayer <[hidden email]>: > Has anyone gone to the trouble of creating a JNI interface to many of the > ImageJ functions? I see a few very specific examples, but no > comprehensive effort to make a general purpose JNI interface that allows > access to all (or at least the most popular) functions. I have a lot of > code written in C that analyzes ROI's from images and I would like to, as > a simple example, display an image, draw a ROI, send the ROI from ImageJ > to my C code, analyze the ROI, then send results back to ImageJ for > plotting or other things. Therefore, I would prefer to use JNI than > rewrite all my C code in Java. > -- Arnaud Dieudonné Doctorant en Physique Médicale Laboratoire QUANT.I.F. Faculté de Médecine et Pharmacie de Rouen Tel: +33 2 35 14 86 17 |
Hi,
I have been trying to write c plugins for ImageJ, I made the .dll file using .c and .h and I have included it in the ImageJ folder. When I try to compile the java file I get this error:- java.lang.UnsatisfiedLinkError: H_.sayHello()V at H_.sayHello(Native Method) at H_.run(H_.java:18) at ij.IJ.runUserPlugIn(IJ.java:183) at ij.ImageJ.runUserPlugIn(ImageJ.java:268) at ij.plugin.PlugInExecuter.run(Compiler.java:264) at java.lang.Thread.run(Thread.java:619) Can anyone please suggest what might be the mistake? |
Free forum by Nabble | Edit this page |