Martin Tomov commited on
Commit
5643464
1 Parent(s): 29e81be

refine insect extraction

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -149,7 +149,8 @@ def extract_and_paste_insect(original_image: np.ndarray, detection: DetectionRes
149
  x_offset, y_offset = xmin, ymin
150
  x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
151
 
152
- background[y_offset:y_end, x_offset:x_end] = insect
 
153
 
154
  def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
155
  yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8) # BGR for yellow
 
149
  x_offset, y_offset = xmin, ymin
150
  x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
151
 
152
+ insect_area = background[y_offset:y_end, x_offset:x_end]
153
+ insect_area[mask_crop == 1] = insect[mask_crop == 1]
154
 
155
  def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
156
  yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8) # BGR for yellow