Skip to content, Skip to search

Changes

Jython Scripting

213 bytes added, 01:47, 28 August 2018
Using openCV in Jython
==== Using openCV in Jython ====
It is even possible to use most of opencv functionalities within Jython/Fiji. There are several options (see the [https: For that //imagej.net/OpenCV wiki page about opencv]), yet the most simple straight forward is probably IJ-OpenCV which is to enable available via the IJopenCV update site that sites. It will automatically download the necessary packagesand dependencies in your Fiji installation.
A manual installation is also possible by putting the jar packages in the jar folder of imageJ. They are avalaible on the [https://github.com/joheras/IJ-OpenCV IJopenCV github], which even provides a maven option. '''NB  The 1st things to know about openCV is that most functions works with openCV matrix object. Hopefully, the IJopenCV provides some converters : the version on Github and the update sites are not identical and not compatible'''
The 1st things to know about openCV is that most functions works with openCV matrix object. Hopefully, the IJopenCV provides a converter :
<source lang="python">
#@ ImagePlus ImP
from ijopencv .ij import ImageConverterImagePlusMatConverterfrom ijopencv.opencv import MatImagePlusConverter
Converter # Convert ImagePlus (actually the contained ImageProcessor) to Matrix objectimp2mat = ImageConverterImagePlusMatConverter() # create an instance of the converterImMat = imp2mat.toMat(imp.getProcessor())print ImMat
# Convert Matrix object to a matriceImageProcessorImCv mat2imp = Converter.convertToMatImagePlusConverter(ImP# Do some processing in openCV#...# Convert back to an ImagePlusImP2 NewIP = Convertermat2imp.convertFromtoImageProcessor(ImCvImMat)print NewIP
</source>
* <code>org.bytedeco.javacpp.opencv_core.transform</code>
That's the one to use ! It takes only <code>org.bytedeco.javacpp.opencv_core.Mat</code> as input, which is the most approriate in Fiji/Jython  
== Self written Jython modules for ImageJ ==
Emailconfirmed
88
edits