Quantcast

Writing ImageJ plugins using C++ or Python

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

Writing ImageJ plugins using C++ or Python

Li, Xin (GE Global Research)
Hello,
I have some image analysis code in C++ that I would like to turn into ImageJ plugins. Are there any pros and cons to write plugins using C++ or Python instead of Java? Please also let me know if you have any suggestions about writing plugins using C++ or Python. Thank you so much!

Xin

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

Re: Writing ImageJ plugins using C++ or Python

ctrueden
Hi Xin,

If you like Python, you can write ImageJ scripts in Jython [1], but you
will not be able to call native C++ APIs easily.

In my opinion, the most major con of using C++ is portability and
distribution: you have to compile your native library(ies) for every
platform you wish to support, and then place them into the
platform-specific lib/<platform> folders of the ImageJ distribution on the
update site. And you do not get the benefits of a modern dependency
management system such as Maven—it will be extremely difficult for others
to build on top of your code. Personally, I think it defeats much of the
benefit of using Java.

So, I would suggest to language translate your code to Java instead. Then
it will run on all Java-enabled platforms, including ones you might not
immediately think about such as Solaris and Raspberry Pi.

Regards,
Curtis

[1] https://imagej.net/Jython_Scripting

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, Feb 6, 2017 at 10:52 AM, Li, Xin (GE Global Research) <
[hidden email]> wrote:

> Hello,
> I have some image analysis code in C++ that I would like to turn into
> ImageJ plugins. Are there any pros and cons to write plugins using C++ or
> Python instead of Java? Please also let me know if you have any suggestions
> about writing plugins using C++ or Python. Thank you so much!
>
> Xin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: Writing ImageJ plugins using C++ or Python

Jan-2
In reply to this post by Li, Xin (GE Global Research)
Some pros and cons for the C++ case:
Pros:
* Speed! Your plugin will be faster than a plugin written in Java.
* You don't have to rewrite your code in Java :)
Cons:
* You will have to use the Java Native Interface, to make your C++
methods available in Java. This can involve quite a bit of debugging,
memory management might be another issue here, since you have to provide
ways to free memory from within Java.
* Your code will not be platform-independence (in the Java sense). What
I mean by that is, that you have  to compile and provide dll/so library
files along with your plugin, which you have to manually load from your
Java code.

In short: Getting your C++ code to ImageJ will be related with some
work. Speed will be the reward, but using JNI can be a pain.

If you plan on using Python using Jython is one option here.
However, if your Python code wraps around a C++ library, you should
avoid the Python wrapper and use the C++ library directly. Which leads
us back to the C++ case.

Cheers,
Jan


On 2/6/2017 5:52 PM, Li, Xin (GE Global Research) wrote:
> Hello,
> I have some image analysis code in C++ that I would like to turn into ImageJ plugins. Are there any pros and cons to write plugins using C++ or Python instead of Java? Please also let me know if you have any suggestions about writing plugins using C++ or Python. Thank you so much!
>
> Xin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> .
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Loading...