Browse Source

changed the way missing part surrogates are handled

Dimitri Korsch 5 years ago
parent
commit
919d52a1f5
1 changed files with 9 additions and 1 deletions
  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)