Example #1
0
def _oppositeAngle(p1, p2, p3):
    """_oppositeAngle(p1, p2, p3)
    Given the triangle (p1, p2, p3), returns angle at p3 (in radians)"""
    a = p1 - p3
    b = p2 - p3
    c = dot(a, b) / \
        math.sqrt(squaredNorm(a)*squaredNorm(b))
    if abs(c) < 1:
        return math.acos(c)
    elif abs(c) > 0:
        return 0
    return math.pi
Example #2
0
def _oppositeAngle(p1, p2, p3):
    """_oppositeAngle(p1, p2, p3)
    Given the triangle (p1, p2, p3), returns angle at p3 (in radians)"""
    a = p1 - p3
    b = p2 - p3
    c = dot(a, b) / \
        math.sqrt(squaredNorm(a)*squaredNorm(b))
    if abs(c) < 1:
        return math.acos(c)
    elif abs(c) > 0:
        return 0
    return math.pi
Example #3
0
def pruneByMorphologicalSignificance(skel, ratio = 0.1):
    for edge in skel.edgeIter():
        edge.setFlag(IS_BARB, False)

        if edge.startNode().hasDegree(1):
            edge.setFlag(IS_BARB, True)

            endSide = edge.endSide[0]-edge.endSide[1]
            minDist = ratio * numpy.linalg.norm(endSide)

            endNormal = Vector2(endSide[1], -endSide[0])
            endNormal /= numpy.linalg.norm(endNormal)

            for p in edge:
                if abs(dot(p - edge[-1], endNormal)) > minDist:
                    edge.setFlag(IS_BARB, False)
                    break

            if edge.flag(IS_BARB):
                continue # no need to test other side

        if edge.endNode().hasDegree(1):
            edge.setFlag(IS_BARB, True)

            startSide = edge.startSide[0]-edge.startSide[1]
            minDist = ratio * max(1.0, numpy.linalg.norm(startSide))

            startNormal = Vector2(startSide[1], -startSide[0])
            startNormal /= numpy.linalg.norm(startNormal)

            for p in edge:
                if abs(dot(p - edge[0], startNormal)) > minDist:
                    edge.setFlag(IS_BARB, False)
                    break

    return _pruneBarbsInternal(skel)
Example #4
0
def pruneByMorphologicalSignificance(skel, ratio = 0.1):
    for edge in skel.edgeIter():
        edge.setFlag(IS_BARB, False)

        if edge.startNode().hasDegree(1):
            edge.setFlag(IS_BARB, True)

            endSide = edge.endSide[0]-edge.endSide[1]
            minDist = ratio * numpy.linalg.norm(endSide)

            endNormal = Vector2(endSide[1], -endSide[0])
            endNormal /= numpy.linalg.norm(endNormal)

            for p in edge:
                if abs(dot(p - edge[-1], endNormal)) > minDist:
                    edge.setFlag(IS_BARB, False)
                    break

            if edge.flag(IS_BARB):
                continue # no need to test other side

        if edge.endNode().hasDegree(1):
            edge.setFlag(IS_BARB, True)

            startSide = edge.startSide[0]-edge.startSide[1]
            minDist = ratio * max(1.0, numpy.linalg.norm(startSide))

            startNormal = Vector2(startSide[1], -startSide[0])
            startNormal /= numpy.linalg.norm(startNormal)

            for p in edge:
                if abs(dot(p - edge[0], startNormal)) > minDist:
                    edge.setFlag(IS_BARB, False)
                    break

    return _pruneBarbsInternal(skel)