Skip to content

Commit

Permalink
update centroid_aug.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dummyindex committed May 29, 2024
1 parent a03937d commit 8cf5919
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions notebooks/scripts/mmdetection_classify/centroid_aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,12 @@ def __call__(self, results, exact_match_rg_channel=False):
properties.sort(key=lambda x: x.area, reverse=True)
props = properties[0]
centroid = props.centroid
# centroid_box = np.array(
# [
# centroid[0] - centroid_box_width / 2,
# centroid[1] - centroid_box_width / 2,
# centroid[0] + centroid_box_width / 2,
# centroid[1] + centroid_box_width / 2,
# ]
# )

centroid_box = np.array(
[
centroid[1] - centroid_box_width / 2,
centroid[0] - centroid_box_width / 2,
centroid[1] + centroid_box_width / 2,
centroid[1] - centroid_box_width / 2,
centroid[0] + centroid_box_width / 2,
centroid[1] + centroid_box_width / 2,
]
)

Expand All @@ -88,7 +79,7 @@ def __call__(self, results, exact_match_rg_channel=False):

# Draw centroid box via corrected_mask mass weight
new_mask = np.zeros(corrected_mask.shape)
new_mask[int(centroid_box[1]) : int(centroid_box[3]), int(centroid_box[0]) : int(centroid_box[2])] = 1
new_mask[int(centroid_box[0]) : int(centroid_box[2]), int(centroid_box[1]) : int(centroid_box[3])] = 1
new_mask = new_mask.astype(int)

new_img[:, :, 0] = new_mask
Expand Down

0 comments on commit 8cf5919

Please sign in to comment.