Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow PointAnnotation sampling in RandomPointSampler #61

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions wholeslidedata/samplers/pointsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from shapely.affinity import affine_transform
from shapely.geometry import Point
from wholeslidedata.samplers.sampler import Sampler

from wholeslidedata.annotation.types import PointAnnotation

class PointSampler(Sampler):
@abc.abstractmethod
Expand Down Expand Up @@ -39,6 +39,9 @@ def __init__(self, buffer=0.0, simplify=2.0, seed=123):
self._simplify = simplify

def sample(self, annotation):
if isinstance(annotation, PointAnnotation):
return annotation.centroid

buffer = self._buffer
if isinstance(self._buffer, dict):
try:
Expand All @@ -64,4 +67,4 @@ def sample(self, annotation):
p = affine_transform(Point(1 - x, 1 - y), transform)
else:
p = affine_transform(Point(x, y), transform)
return p.x, p.y
return p.x, p.y
Loading