Martin Tomov commited on
Commit
02b6b84
·
verified ·
1 Parent(s): 49f371c

classification_boxes and segmentation update

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -148,8 +148,13 @@ def extract_and_paste_insect(original_image: np.ndarray, detection: DetectionRes
148
  x_offset, y_offset = xmin, ymin
149
  x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
150
 
151
- # Place the insect onto the yellow background
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)
 
148
  x_offset, y_offset = xmin, ymin
149
  x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
150
 
151
+ # Ensure the background area under the bounding box is yellow
152
+ yellow_area = np.full_like(insect_crop, (0, 255, 255), dtype=np.uint8)
153
+ background[y_offset:y_end, x_offset:x_end] = yellow_area
154
+
155
+ # Combine the insect with the yellow background
156
+ combined = cv2.add(background[y_offset:y_end, x_offset:x_end], insect)
157
+ background[y_offset:y_end, x_offset:x_end] = combined
158
 
159
  def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
160
  yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8)