|
@@ -1,7 +1,9 @@
|
|
|
import numpy as np
|
|
|
|
|
|
+from abc import ABC
|
|
|
+from abc import abstractproperty
|
|
|
from matplotlib import pyplot as plt
|
|
|
-from abc import ABC, abstractproperty
|
|
|
+from skimage.transform import resize
|
|
|
|
|
|
from cvdatasets import utils
|
|
|
|
|
@@ -108,6 +110,12 @@ class BasePart(ABC):
|
|
|
|
|
|
def crop(self, im, w, h, padding_mode="edge", is_location=True):
|
|
|
if not self.is_visible:
|
|
|
+ _part_surrogate = resize(utils.asarray(im), (h, w),
|
|
|
+ mode="constant",
|
|
|
+ anti_aliasing=True,
|
|
|
+ preserve_range=True)
|
|
|
+ return _part_surrogate.astype(np.uint8)
|
|
|
+ # old code using black images as surrogates
|
|
|
_, _, c = utils.dimensions(im)
|
|
|
return np.zeros((h, w, c), dtype=np.uint8)
|
|
|
|