How to use the histomicstk.annotations_and_masks.pyrtree.rect.Rect function in histomicstk

To help you get started, we’ve selected a few histomicstk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
x = self.x
        y = self.y
        xx = self.xx
        yy = self.yy
        ox = o.x
        oy = o.y
        oxx = o.xx
        oyy = o.yy

        nx = x if x < ox else ox
        ny = y if y < oy else oy
        nx2 = xx if xx > oxx else oxx
        ny2 = yy if yy > oyy else oyy

        res = Rect(nx, ny, nx2, ny2)

        return res
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
return self.union(Rect(x, y, x, y))

    def diagonal_sq(self):
        """Placeholder."""
        if self is NullRect:
            return 0
        w = self.xx - self.x
        h = self.yy - self.y
        return w * w + h * h

    def diagonal(self):
        """Placeholder."""
        return math.sqrt(self.diagonal_sq())


NullRect = Rect(0.0, 0.0, 0.0, 0.0)
NullRect.swapped_x = False
NullRect.swapped_y = False


def union_all(kids):
    """Placeholder."""
    cur = NullRect
    for k in kids:
        cur = cur.union(k.rect)
    assert(not cur.swapped_x)
    return cur
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rtree.py View on Github external
def create_leaf(cls, rooto, leaf_obj, leaf_rect):
        """Placeholder."""
        rect = Rect(leaf_rect.x, leaf_rect.y, leaf_rect.xx, leaf_rect.yy)
        rect.swapped_x = True  # Mark as leaf by setting the xswap flag.
        res = _NodeCursor.create(rooto, rect)
        idx = res.index
        res.first_child = rooto.leaf_count
        rooto.leaf_count += 1
        res.next_sibling = 0
        rooto.leaf_pool.append(leaf_obj)
        res._save_back()
        res._become(idx)
        assert(res.is_leaf())
        return res
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
def union_point(self, o):
        """Placeholder."""
        x, y = o
        return self.union(Rect(x, y, x, y))
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
def intersect(self, o):
        """Placeholder."""
        if self is NullRect:
            return NullRect
        if o is NullRect:
            return NullRect

        nx, ny = max(self.x, o.x), max(self.y, o.y)
        nx2, ny2 = min(self.xx, o.xx), min(self.yy, o.yy)
        w, h = nx2 - nx, ny2 - ny

        if w <= 0 or h <= 0:
            return NullRect

        return Rect(nx, ny, nx2, ny2)
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rtree.py View on Github external
def _become(self, index):
        """Placeholder."""
        recti = index * 4
        nodei = index * 2
        rp = self.rpool
        x = rp[recti]
        y = rp[recti+1]
        xx = rp[recti+2]
        yy = rp[recti+3]

        if (x == 0.0 and y == 0.0 and xx == 0.0 and yy == 0.0):
            self.rect = NullRect
        else:
            self.rect = Rect(x, y, xx, yy)

        self.next_sibling = self.npool[nodei]
        self.first_child = self.npool[nodei + 1]
        self.index = index
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
def grow(self, amt):
        """Placeholder."""
        a = amt * 0.5
        return Rect(self.x-a, self.y-a, self.xx+a, self.yy+a)
github DigitalSlideArchive / HistomicsTK / histomicstk / annotations_and_masks / pyrtree / rect.py View on Github external
def union(self, o):
        """Placeholder."""
        if o is NullRect:
            return Rect(self.x, self.y, self.xx, self.yy)
        if self is NullRect:
            return Rect(o.x, o.y, o.xx, o.yy)

        x = self.x
        y = self.y
        xx = self.xx
        yy = self.yy
        ox = o.x
        oy = o.y
        oxx = o.xx
        oyy = o.yy

        nx = x if x < ox else ox
        ny = y if y < oy else oy
        nx2 = xx if xx > oxx else oxx
        ny2 = yy if yy > oyy else oyy

        res = Rect(nx, ny, nx2, ny2)