Пример #1
0
# Membrane, from the ovals: 312 points
membrane = reduce(
    lambda cs, pol: [cs[0] + list(pol.xpoints), cs[1] + list(pol.ypoints)],
    [roi.getPolygon() for roi in rois], [[], []])

# Membrane oblique, fuzzy: another 76 points
membrane_oblique = reduce(
    lambda cs, pol: [cs[0] + list(pol.xpoints), cs[1] + list(pol.ypoints)],
    [roi.getPolygon() for roi in [roi_oblique]], [[], []])

len_membrane = len(membrane[0]) + len(membrane_oblique[0])

# Background samples: as many as membrane samples
rectangle = Roi(10, 10, w - 20, h - 20)
pol = rectangle.getInterpolatedPolygon(1.0, False)  # 433 points
nonmem = (list(int(x) for x in pol.xpoints)[:len_membrane],
          list(int(y) for y in pol.ypoints)[:len_membrane])

####

import sys

sys.path.append("/home/albert/lab/scripts/python/imagej/IsoView-GCaMP/")
from lib.segmentation_em import createSMOClassifier, createRandomForestClassifier, classify, \
                                filterBank, filterBankRotations, filterBankBlockStatistics, \
                                createPerceptronClassifier, filterBankOrthogonalEdges, filterBankEdges
from net.imglib2.img.display.imagej import ImageJFunctions as IL
from net.imglib2.algorithm.math.ImgMath import offset
from net.imglib2.view import Views
from net.imglib2.type.numeric.real import DoubleType