Jelajahi Sumber

changed the way missing part surrogates are handled

Dimitri Korsch 5 tahun lalu
induk
melakukan
919d52a1f5
1 mengubah file dengan 9 tambahan dan 1 penghapusan
  1. 9 1
      cvdatasets/dataset/part/base.py

+ 9 - 1
cvdatasets/dataset/part/base.py

@@ -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)