MCPcopy Create free account
hub / github.com/DragonisCV/RAM / crop_border

Function crop_border

ram/utils/img_util.py:156–172  ·  view source on GitHub ↗

Crop borders of images. Args: imgs (list[ndarray] | ndarray): Images with shape (h, w, c). crop_border (int): Crop border for each end of height and weight. Returns: list[ndarray]: Cropped images.

(imgs, crop_border)

Source from the content-addressed store, hash-verified

154
155
156def crop_border(imgs, crop_border):
157 """Crop borders of images.
158
159 Args:
160 imgs (list[ndarray] | ndarray): Images with shape (h, w, c).
161 crop_border (int): Crop border for each end of height and weight.
162
163 Returns:
164 list[ndarray]: Cropped images.
165 """
166 if crop_border == 0:
167 return imgs
168 else:
169 if isinstance(imgs, list):
170 return [v[crop_border:-crop_border, crop_border:-crop_border, ...] for v in imgs]
171 else:
172 return imgs[crop_border:-crop_border, crop_border:-crop_border, ...]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected