Example #1
0
 def threshold(self, image, subscriber=0):
     from pyphant.quantities.ParseQuantities import parseQuantity
     w1 = parseQuantity(self.paramW1.value)[0]
     rho1 = parseQuantity(self.paramRho1.value)[0]
     rho2 = parseQuantity(self.paramRho2.value)[0]
     coveragePercent = weight2Coverage(w1, rho1, rho2)
     th = calculateThreshold(image, coveragePercent)
     import scipy
     from ImageProcessing import (FEATURE_COLOR, BACKGROUND_COLOR)
     import copy
     from pyphant.core.DataContainer import FieldContainer
     resultArray = scipy.where(image.data < th, FEATURE_COLOR,
                               BACKGROUND_COLOR)
     result = FieldContainer(resultArray,
                             dimensions=copy.deepcopy(image.dimensions),
                             longname=u"Binary Image",
                             shortname=u"B")
     result.seal()
     return result
Example #2
0
 def threshold(self, image, subscriber=0):
     from pyphant.quantities.ParseQuantities import parseQuantity
     w1 = parseQuantity(self.paramW1.value)[0]
     rho1 = parseQuantity(self.paramRho1.value)[0]
     rho2 = parseQuantity(self.paramRho2.value)[0]
     coveragePercent = weight2Coverage(w1, rho1, rho2)
     th = calculateThreshold(image, coveragePercent)
     import scipy
     from ImageProcessing import (FEATURE_COLOR, BACKGROUND_COLOR)
     import copy
     from pyphant.core.DataContainer import FieldContainer
     resultArray = scipy.where(image.data < th,
                               FEATURE_COLOR,
                               BACKGROUND_COLOR)
     result = FieldContainer(resultArray,
                             dimensions=copy.deepcopy(image.dimensions),
                             longname=u"Binary Image", shortname=u"B")
     result.seal()
     return result
Example #3
0
def getConverters(FMFversion='1.1'):
    converters = [
        int,
        float,
        parseBool,
        lambda v: parseVariable(v, FMFversion),
        lambda q: parseQuantity(q, FMFversion),
        complex,  # Complex is checked after variables and quantities,
        # because 1J is 1 Joule and not an imaginary number.
        lambda d: parseDateTime(d, FMFversion),
    ]
    return converters
Example #4
0
def getConverters(FMFversion='1.1'):
    converters = [
        int,
        float,
        parseBool,
        lambda v: parseVariable(v,FMFversion),
        lambda q: parseQuantity(q,FMFversion),
        complex,        # Complex is checked after variables and quantities,
                        # because 1J is 1 Joule and not an imaginary number.
        lambda d: parseDateTime(d,FMFversion),
        ]
    return converters