示例#1
0
文件: Blob.py 项目: rick446/SimpleCV
    def circleDistance(self):
        """
        **SUMMARY**

        Compare the hull mask to an ideal circle and count the number of pixels
        that deviate as a fraction of total area of the ideal circle.

        **RETURNS**

        The difference, as a percentage, between the hull of our blob and an idealized
        circle of our blob. 

        """
        w = self.mHullMask.width
        h = self.mHullMask.height

        idealcircle = Image((w, h))
        radius = min(w, h) / 2
        idealcircle.dl().circle((w / 2, h / 2), radius, filled=True, color=Color.WHITE)
        idealcircle = idealcircle.applyLayers()
        print self.mHullMask
        print idealcircle
        print self.mHullMask.width
        print self.mHullMask.height
        print idealcircle.width
        print idealcircle.height
        netdiff = (idealcircle - self.mHullMask) + (self.mHullMask - idealcircle)
        numblack, numwhite = netdiff.histogram(2)
        return float(numwhite) / (radius * radius * np.pi)
示例#2
0
    def circleDistance(self):
        """
        **SUMMARY**

        Compare the hull mask to an ideal circle and count the number of pixels
        that deviate as a fraction of total area of the ideal circle.

        **RETURNS**

        The difference, as a percentage, between the hull of our blob and an idealized
        circle of our blob. 

        """
        w = self.mHullMask.width
        h = self.mHullMask.height
        
        idealcircle = Image((w,h))
        radius = min(w,h) / 2
        idealcircle.dl().circle((w/2, h/2), radius, filled= True, color=Color.WHITE)
        idealcircle = idealcircle.applyLayers()
        print self.mHullMask
        print idealcircle
        print self.mHullMask.width
        print self.mHullMask.height
        print idealcircle.width
        print idealcircle.height
        netdiff = (idealcircle - self.mHullMask) + (self.mHullMask - idealcircle)
        numblack, numwhite = netdiff.histogram(2)
        return float(numwhite) / (radius * radius * np.pi)
示例#3
0
文件: Blob.py 项目: ChrisCTX/SimpleCV
 def circleDistance(self):
     """
     Compare the hull mask to an ideal circle and count the number of pixels
     that deviate as a fraction of total area of the ideal circle
     """
     idealcircle = Image((self.width(), self.height()))
     radius = min(self.width(), self.height()) / 2
     idealcircle.dl().circle((self.width()/2, self.height()/2), radius, filled= True, color=Color.WHITE)
     idealcircle = idealcircle.applyLayers()
     
     netdiff = (idealcircle - self.mHullMask) + (self.mHullMask - idealcircle)
     numblack, numwhite = netdiff.histogram(2)
     return float(numwhite) / (radius * radius * np.pi)
示例#4
0
    def circleDistance(self):
        """
        Compare the hull mask to an ideal circle and count the number of pixels
        that deviate as a fraction of total area of the ideal circle
        """
        idealcircle = Image((self.width(), self.height()))
        radius = min(self.width(), self.height()) / 2
        idealcircle.dl().circle((self.width() / 2, self.height() / 2),
                                radius,
                                filled=True,
                                color=Color.WHITE)
        idealcircle = idealcircle.applyLayers()

        hullmask = Image(self.mHullMask)

        netdiff = (idealcircle - hullmask) + (hullmask - idealcircle)
        numblack, numwhite = netdiff.histogram(2)
        return float(numwhite) / (radius * radius * np.pi)