put all ijopencv test code into a separate file

As a result, lipase code is no longer using ijopencv.
ijopencv, based on javacpp provides poor compatibility with
opencv's cpython bindings, not to mention it's much less
convenient. Therefore, I'm not sure that I'll use ijopencv at all...
This commit is contained in:
Guillaume Raffy 2019-04-12 12:53:17 +02:00
parent 361fb552e7
commit 14d3535388
2 changed files with 212 additions and 167 deletions

205
ijopencv-tester.py Normal file
View File

@ -0,0 +1,205 @@
from ij import IJ # pylint: disable=import-error
from ijopencv.ij import ImagePlusMatConverter # pylint: disable=import-error
from ijopencv.opencv import MatImagePlusConverter # pylint: disable=import-error
import org.bytedeco.javacpp.opencv_core as opencv_core # pylint: disable=import-error
import org.bytedeco.javacpp.opencv_imgproc as opencv_imgproc # pylint: disable=import-error
from org.bytedeco.javacpp.opencv_imgcodecs import imread, imwrite # pylint: disable=import-error
# from org.bytedeco.javacpp.opencv_core import CvMat
def test_opencv_calc_hist1():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_imgproc.cvCalcHist(src_image) # pylint: disable=unused-variable
# TypeError: cvCalcHist(): expected 2 or 4 args; got 1
def test_opencv_calc_hist2():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
opencv_imgproc.cvCalcHist(src_image, histogram)
# TypeError: cvCalcHist(): 1st arg can't be coerced to org.bytedeco.javacpp.opencv_core$IplImage
def test_opencv_calc_hist3():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_imgproc.calcHist(src_image) # pylint: disable=unused-variable
# TypeError: calcHist(): expected 6-8 or 10 args; got 1
# ah: ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java seems to contain the list of 57 allowed calcHist sets of arguments, as the number of arguments match
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:45:41]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | wc -l
# 57
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:45:56]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | head -2
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const IntPointer channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const IntPointer histSize, @Cast("const float**") PointerPointer ranges, @Cast("bool") boolean uniform/*=true*/, @Cast("bool") boolean accumulate/*=false*/ );
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const IntPointer channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const IntPointer histSize, @Const @ByPtrPtr FloatPointer ranges );
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:38:39]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | awk '-F,' '{print NF}' | sort --unique -n
# 6
# 7
# 8
# 10
def test_opencv_calc_hist4():
src_image = opencv_core.Mat([128, 128])
src_images = opencv_core.MatVector()
# print(dir(src_images))
src_images.push_back(src_image)
print(type(src_images))
# <type 'org.bytedeco.javacpp.opencv_core$MatVector'>
print(src_images)
# [org.bytedeco.javacpp.opencv_core$Mat[width=1024,height=1024,depth=8,channels=3]]
opencv_imgproc.calcHist(src_images, [0], None, None, [256], [0.0, 256.0])
# TypeError: calcHist(): 1st arg can't be coerced to org.bytedeco.javacpp.opencv_core$UMatVector, org.bytedeco.javacpp.opencv_core$GpuMatVector, org.bytedeco.javacpp.opencv_core$MatVector
def test_opencv_calc_hist5():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], None, histogram, 1, [256], [0.0, 256.0])
# at org.bytedeco.javacpp.opencv_imgproc.calcHist(Native Method)
# at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
# at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
# at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
# at java.lang.reflect.Method.invoke(Method.java:497)
# java.lang.NullPointerException: java.lang.NullPointerException: Pointer address of argument 3 is NULL.
def test_opencv_calc_hist6():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
mask = opencv_core.Mat()
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], mask, histogram, 1, [256], [0.0, 256.0])
# java.lang.RuntimeException: java.lang.RuntimeException: OpenCV(3.4.2) /Users/travis/build/bytedeco/javacpp-presets/opencv/cppbuild/macosx-x86_64/opencv-3.4.2/modules/imgproc/src/histogram.cpp:918: error: (-210:Unsupported format or combination of formats) in function 'calcHist'
def test_opencv_calc_hist7():
# 0 : depth=8
# 1 : depth=-2147483640
# 2 : depth=16
# 3 : depth=-2147483640
# 4 : depth=-2147483640
# 8 : depth=8, channels=2
print('opencv_core.CV_8U', opencv_core.CV_8U)
print('opencv_core.CV_16U', opencv_core.CV_16U)
print('opencv_core.CV_32F', opencv_core.CV_32F)
print('opencv_core.CV_8UC3', opencv_core.CV_8UC3)
src_image = opencv_core.Mat().zeros(128, 128, opencv_core.CV_8U).asMat()
byte_pointer = src_image.data()
print('byte_pointer', byte_pointer)
# byte_pointer.putChar(128 * 3 + 7, 5)
byte_pointer.put(128 * 3 + 7, 5)
# print(dir(opencv_core))
print('src_image', src_image)
histogram = opencv_core.Mat()
print('histogram', histogram)
# create an empty mask. From https://docs.opencv.org/3.4.1/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d :
# Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i] . The non-zero mask elements mark the array elements counted in the histogram.
empty_mask = opencv_core.Mat()
print('empty_mask', empty_mask)
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], empty_mask, histogram, 1, [256], [0.0, 256.0])
print('histogram', histogram, opencv_core.CvMat(histogram))
def test_opencv_calc_hist():
'''
'''
# https://forum.image.sc/t/use-opencv-within-jython-macro/10320/4
test_opencv_calc_hist7()
# histogram = opencv_imgproc.calcHist(images=[src_image], channels=[0], mask=None, histSize=[256], ranges=[0, 256])
# histogram = opencv_imgproc.calcHist(src_image, 0, None, 3, [256], [0.0, 256.0], True, False)
# print(dir(opencv_imgproc))
# help(opencv_imgproc.cvCalcHist)
# opencv_imgproc.calcHist(src_image, None, histogram)
# histogram = opencv_imgproc.cvCalcHist(src_image, None, [256], [0.0, 256.0])
# import inspect
# lines = inspect.getsource(opencv_imgproc.calcHist)
# opencv_imgproc.calcHist(src_image, histogram)
# there are 2 calcHist functions in /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2.jar, and they take 6 or 7 arguments :
# jar -xvf /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2.jar
# [1]graffy@pr079234:~/toto/jython[15:18:17]>javap ./org/opencv/imgproc/Imgproc.class | grep calcHist
# public static void calcHist(java.util.List<org.opencv.core.Mat>, org.opencv.core.MatOfInt, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfInt, org.opencv.core.MatOfFloat, boolean);
# public static void calcHist(java.util.List<org.opencv.core.Mat>, org.opencv.core.MatOfInt, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfInt, org.opencv.core.MatOfFloat);
#
# jar -xvf /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2-macosx-x86_64.jar
# [OK]graffy@pr079234:~/toto/jython[19:02:28]>grep -A 5 "calcHist(" org/bytedeco/javacpp/macosx-x86_64/include/opencv2/imgproc.hpp
# CV_EXPORTS void calcHist( const Mat* images, int nimages,
# const int* channels, InputArray mask,
# OutputArray hist, int dims, const int* histSize,
# const float** ranges, bool uniform = true, bool accumulate = false );
# /** @overload
# --
# CV_EXPORTS void calcHist( const Mat* images, int nimages,
# const int* channels, InputArray mask,
# SparseMat& hist, int dims,
# const int* histSize, const float** ranges,
# bool uniform = true, bool accumulate = false );
# --
# CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
# const std::vector<int>& channels,
# InputArray mask, OutputArray hist,
# const std::vector<int>& histSize,
# const std::vector<float>& ranges,
# bool accumulate = false );
# git checkout tags/1.4.2
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:21:57]>git branch
# * (HEAD detached at 1.4.2)
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:18:33]>grep -A 2 "void cvCalcHist" ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java
# public static native void cvCalcHist( @Cast("IplImage**") PointerPointer image, CvHistogram hist,
# int accumulate/*=0*/,
# @Const CvArr mask/*=NULL*/ );
# --
# public static native void cvCalcHist( @ByPtrPtr IplImage image, CvHistogram hist );
# public static native void cvCalcHist( @ByPtrPtr IplImage image, CvHistogram hist,
# int accumulate/*=0*/,
# @Const CvArr mask/*=NULL*/ );
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:18:41]>grep -A 2 "void cvCalcHist" ./opencv/src/main/java/org/bytedeco/javacpp/helper/opencv_imgproc.java
# public static void cvCalcHist(IplImage[] arr, CvHistogram hist, int accumulate/*=0*/, CvArr mask/*=null*/) {
# org.bytedeco.javacpp.opencv_imgproc.cvCalcHist(new IplImageArray(arr), hist, accumulate, mask);
# }
# --
# public static void cvCalcHist(IplImageArray arr, CvHistogram hist,
# int accumulate/*=0*/, CvArr mask/*=null*/) {
# org.bytedeco.javacpp.opencv_imgproc.cvCalcArrHist(arr, hist, accumulate, mask);
def create_test_image_file(image_file_path):
image = opencv_core.Mat().zeros(128, 128, opencv_core.CV_8U).asMat()
imwrite(image_file_path, image)
def test_ijopencv_converter():
image_file_path = '/tmp/toto.png'
create_test_image_file(image_file_path)
image = IJ.openImage(image_file_path)
imp2mat = ImagePlusMatConverter()
mat = imp2mat.toMat(image.getProcessor())
# white_mat = imread(white_image_file_path)
print('mat', mat)
def test_opencv():
test_ijopencv_converter()
test_opencv_calc_hist()
# If a Jython script is run, the variable __name__ contains the string '__main__'.
# If a script is loaded as module, __name__ has a different value.
if __name__ in ['__builtin__', '__main__']:
# run_script()
# test_get_image_median_value()
test_opencv()

174
lipase.py
View File

@ -6,14 +6,8 @@
# the 'name' parameter from the user, and then display
# the 'greeting' output parameter, based on its type.
from ij import IJ # pylint: disable=import-error
from ijopencv.ij import ImagePlusMatConverter # pylint: disable=import-error
from ijopencv.opencv import MatImagePlusConverter # pylint: disable=import-error
from ij import ImagePlus # pylint: disable=import-error
import org.bytedeco.javacpp.opencv_core as opencv_core # pylint: disable=import-error
import org.bytedeco.javacpp.opencv_imgproc as opencv_imgproc # pylint: disable=import-error
from org.bytedeco.javacpp.opencv_imgcodecs import imread # pylint: disable=import-error
# greeting = "Hello, " + name + "!"
@ -181,166 +175,13 @@ class ImageCatalog(object):
# self.sequences[ micro_manager_metadata_file_path ] = Sequence(self, micro_manager_metadata_file_path)
def test_opencv_calc_hist1():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_imgproc.cvCalcHist(src_image) # pylint: disable=unused-variable
# TypeError: cvCalcHist(): expected 2 or 4 args; got 1
def test_opencv_calc_hist2():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
opencv_imgproc.cvCalcHist(src_image, histogram)
# TypeError: cvCalcHist(): 1st arg can't be coerced to org.bytedeco.javacpp.opencv_core$IplImage
def test_opencv_calc_hist3():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_imgproc.calcHist(src_image) # pylint: disable=unused-variable
# TypeError: calcHist(): expected 6-8 or 10 args; got 1
# ah: ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java seems to contain the list of 57 allowed calcHist sets of arguments, as the number of arguments match
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:45:41]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | wc -l
# 57
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:45:56]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | head -2
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const IntPointer channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const IntPointer histSize, @Cast("const float**") PointerPointer ranges, @Cast("bool") boolean uniform/*=true*/, @Cast("bool") boolean accumulate/*=false*/ );
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const IntPointer channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const IntPointer histSize, @Const @ByPtrPtr FloatPointer ranges );
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:38:39]>grep -A 5 calcHist ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java | sed -E 's/^[ ]*//g' | tr '\n' '`' | sed 's/,`/, /g' | tr '`' '\n' | grep '^@Namespace' | awk '-F,' '{print NF}' | sort --unique -n
# 6
# 7
# 8
# 10
def test_opencv_calc_hist4():
src_image = opencv_core.Mat([128, 128])
src_images = opencv_core.MatVector()
# print(dir(src_images))
src_images.push_back(src_image)
print(type(src_images))
# <type 'org.bytedeco.javacpp.opencv_core$MatVector'>
print(src_images)
# [org.bytedeco.javacpp.opencv_core$Mat[width=1024,height=1024,depth=8,channels=3]]
opencv_imgproc.calcHist(src_images, [0], None, None, [256], [0.0, 256.0])
# TypeError: calcHist(): 1st arg can't be coerced to org.bytedeco.javacpp.opencv_core$UMatVector, org.bytedeco.javacpp.opencv_core$GpuMatVector, org.bytedeco.javacpp.opencv_core$MatVector
def test_opencv_calc_hist5():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], None, histogram, 1, [256], [0.0, 256.0])
# at org.bytedeco.javacpp.opencv_imgproc.calcHist(Native Method)
# at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
# at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
# at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
# at java.lang.reflect.Method.invoke(Method.java:497)
# java.lang.NullPointerException: java.lang.NullPointerException: Pointer address of argument 3 is NULL.
def test_opencv_calc_hist6():
src_image = opencv_core.Mat([128, 128])
histogram = opencv_core.Mat()
mask = opencv_core.Mat()
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], mask, histogram, 1, [256], [0.0, 256.0])
# java.lang.RuntimeException: java.lang.RuntimeException: OpenCV(3.4.2) /Users/travis/build/bytedeco/javacpp-presets/opencv/cppbuild/macosx-x86_64/opencv-3.4.2/modules/imgproc/src/histogram.cpp:918: error: (-210:Unsupported format or combination of formats) in function 'calcHist'
def test_opencv_calc_hist7():
pixel_type=0
# 0 : depth=8
# 1 : depth=-2147483640
# 2 : depth=16
# 3 : depth=-2147483640
# 4 : depth=-2147483640
# 8 : depth=8, channels=2
src_image = opencv_core.Mat().zeros(128, 128, pixel_type).asMat()
print('src_image', src_image)
histogram = opencv_core.Mat()
print('histogram', histogram)
mask = opencv_core.Mat()
print('mask', mask)
# @Namespace("cv") public static native void calcHist( @Const Mat images, int nimages, @Const int[] channels, @ByVal Mat mask, @ByVal Mat hist, int dims, @Const int[] histSize, @Const @ByPtrPtr float[] ranges );
opencv_imgproc.calcHist(src_image, 1, [0], mask, histogram, 1, [256], [0.0, 256.0])
def test_opencv():
'''
'''
# https://forum.image.sc/t/use-opencv-within-jython-macro/10320/4
test_opencv_calc_hist7()
# histogram = opencv_imgproc.calcHist(images=[src_image], channels=[0], mask=None, histSize=[256], ranges=[0, 256])
# histogram = opencv_imgproc.calcHist(src_image, 0, None, 3, [256], [0.0, 256.0], True, False)
# print(dir(opencv_imgproc))
# help(opencv_imgproc.cvCalcHist)
# opencv_imgproc.calcHist(src_image, None, histogram)
# histogram = opencv_imgproc.cvCalcHist(src_image, None, [256], [0.0, 256.0])
# import inspect
# lines = inspect.getsource(opencv_imgproc.calcHist)
# opencv_imgproc.calcHist(src_image, histogram)
# there are 2 calcHist functions in /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2.jar, and they take 6 or 7 arguments :
# jar -xvf /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2.jar
# [1]graffy@pr079234:~/toto/jython[15:18:17]>javap ./org/opencv/imgproc/Imgproc.class | grep calcHist
# public static void calcHist(java.util.List<org.opencv.core.Mat>, org.opencv.core.MatOfInt, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfInt, org.opencv.core.MatOfFloat, boolean);
# public static void calcHist(java.util.List<org.opencv.core.Mat>, org.opencv.core.MatOfInt, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfInt, org.opencv.core.MatOfFloat);
#
# jar -xvf /Applications/Fiji.app/jars/opencv-3.4.2-1.4.2-macosx-x86_64.jar
# [OK]graffy@pr079234:~/toto/jython[19:02:28]>grep -A 5 "calcHist(" org/bytedeco/javacpp/macosx-x86_64/include/opencv2/imgproc.hpp
# CV_EXPORTS void calcHist( const Mat* images, int nimages,
# const int* channels, InputArray mask,
# OutputArray hist, int dims, const int* histSize,
# const float** ranges, bool uniform = true, bool accumulate = false );
# /** @overload
# --
# CV_EXPORTS void calcHist( const Mat* images, int nimages,
# const int* channels, InputArray mask,
# SparseMat& hist, int dims,
# const int* histSize, const float** ranges,
# bool uniform = true, bool accumulate = false );
# --
# CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
# const std::vector<int>& channels,
# InputArray mask, OutputArray hist,
# const std::vector<int>& histSize,
# const std::vector<float>& ranges,
# bool accumulate = false );
# git checkout tags/1.4.2
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:21:57]>git branch
# * (HEAD detached at 1.4.2)
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:18:33]>grep -A 2 "void cvCalcHist" ./opencv/src/main/java/org/bytedeco/javacpp/opencv_imgproc.java
# public static native void cvCalcHist( @Cast("IplImage**") PointerPointer image, CvHistogram hist,
# int accumulate/*=0*/,
# @Const CvArr mask/*=NULL*/ );
# --
# public static native void cvCalcHist( @ByPtrPtr IplImage image, CvHistogram hist );
# public static native void cvCalcHist( @ByPtrPtr IplImage image, CvHistogram hist,
# int accumulate/*=0*/,
# @Const CvArr mask/*=NULL*/ );
# [OK]graffy@pr079234:~/toto/javacpp-presets[19:18:41]>grep -A 2 "void cvCalcHist" ./opencv/src/main/java/org/bytedeco/javacpp/helper/opencv_imgproc.java
# public static void cvCalcHist(IplImage[] arr, CvHistogram hist, int accumulate/*=0*/, CvArr mask/*=null*/) {
# org.bytedeco.javacpp.opencv_imgproc.cvCalcHist(new IplImageArray(arr), hist, accumulate, mask);
# }
# --
# public static void cvCalcHist(IplImageArray arr, CvHistogram hist,
# int accumulate/*=0*/, CvArr mask/*=null*/) {
# org.bytedeco.javacpp.opencv_imgproc.cvCalcArrHist(arr, hist, accumulate, mask);
def get_image_median_value(src_image):
return 0
def test_get_image_median_value():
image_file_path = '/Users/graffy/ownCloud/ipr/lipase/raw-images/res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0/img_000000000_DM300_327-353_fluo_000.tif'
image = imread(image_file_path)
image = IJ.openImage(image_file_path)
median_value = get_image_median_value(image)
print('median value : %d' % median_value)
@ -372,17 +213,17 @@ def test_get_image_median_value():
def find_depth_index(src_image, white_sequence):
''' finds in the image sequence white_sequence the image that correlates the best to src_image
:param cv_core.Mat src_image:
:param IJ.ImagePlus src_image:
:param Sequence white_sequence:
'''
for z_index in range(white_sequence.num_slices):
white_image_file_path = white_sequence.get_image_file_path(channel_index=0, frame_index=0, z_index=z_index)
# white_image = IJ.openImage(white_image_file_path)
white_image = IJ.openImage(white_image_file_path)
# imp2mat = ImagePlusMatConverter()
# white_mat = imp2mat.toMat(white_image.getProcessor())
white_mat = imread(white_image_file_path)
# white_mat = imread(white_image_file_path)
print(white_image)
print white_mat
break
@ -392,7 +233,7 @@ def process_sequence(sequence):
'''
white_seq = sequence.get_white()
src_image_file_path = sequence.get_image_file_path(channel_index=0, frame_index=0, z_index=0)
src_image = imread(src_image_file_path)
src_image = IJ.openImage(src_image_file_path)
# src_image = IJ.openImage(src_image_file_path)
find_depth_index(src_image, white_seq)
@ -421,5 +262,4 @@ def run_script():
# If a script is loaded as module, __name__ has a different value.
if __name__ in ['__builtin__', '__main__']:
# run_script()
# test_get_image_median_value()
test_opencv()
test_get_image_median_value()