documents:101105ij_r_jython
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
documents:101105ij_r_jython [2010/11/04 13:46] – created kota | documents:101105ij_r_jython [2014/04/15 15:23] – [2. Using ImageJ from R] kota | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Python <- (ImageJ, R) ====== | ||
- | |||
- | Analysis using several tools is a powerful way to deal with complex Image data. We often do this, and here is one small example of taking advantages of ImageJ and R at the same time. | ||
- | |||
- | ImageJ classes could be accessed by Jython, a python based java interface. R has rJava (JRI, Java - R Interface). For this reason, one way of using ImageJ functions and R functions in an integrated environment is to use these resources from Jython. | ||
- | |||
- | Do everything from Java is one way, but python-scripting environment is light enough to test many things. After these testings are done, then a serious Java code could be written. | ||
- | |||
- | Here is a trial in win32. All commands will be done from command line. It should basically be similar in other environment. | ||
- | |||
- | ===== Setting Up Environment. ===== | ||
- | |||
- | You should have done: | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | **1. set CLASSPATH** | ||
- | |||
- | Following three jars should be in your classpath. | ||
- | * JRI.jar | ||
- | * REngine.jar | ||
- | * JRIEngine.jar | ||
- | * ij.jar | ||
- | ... so in command line | ||
- | < | ||
- | set CLASSPATH=%CLASSPATH%; | ||
- | </ | ||
- | **2. set PATH** | ||
- | |||
- | R native libraries should be linked. Then the path should be added with bin, jri, R.dll and JVM.dll: | ||
- | < | ||
- | set PATH=%PATH%; | ||
- | </ | ||
- | ===== Example Scripting ===== | ||
- | <sxh python> | ||
- | C:\>java org.python.util.jython | ||
- | Jython 2.5.1 (Release_2_5_1: | ||
- | [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_22 | ||
- | Type " | ||
- | |||
- | #importing image using ImageJ | ||
- | |||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | |||
- | # going into R, first instantiate | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | >>> | ||
- | |||
- | >>> | ||
- | #.. will plot the graph but one cannot close it... | ||
- | |||
- | >>> | ||
- | #will close all the plots. | ||
- | |||
- | </ | ||
- | |||
- | |||
documents/101105ij_r_jython.txt · Last modified: 2020/11/26 09:11 by 127.0.0.1