MCPcopy
hub / github.com/cvg/Hierarchical-Localization / resize_image

Function resize_image

hloc/extract_features.py:146–161  ·  view source on GitHub ↗
(image, size, interp)

Source from the content-addressed store, hash-verified

144
145
146def resize_image(image, size, interp):
147 if interp.startswith('cv2_'):
148 interp = getattr(cv2, 'INTER_'+interp[len('cv2_'):].upper())
149 h, w = image.shape[:2]
150 if interp == cv2.INTER_AREA and (w < size[0] or h < size[1]):
151 interp = cv2.INTER_LINEAR
152 resized = cv2.resize(image, size, interpolation=interp)
153 elif interp.startswith('pil_'):
154 interp = getattr(PIL.Image, interp[len('pil_'):].upper())
155 resized = PIL.Image.fromarray(image.astype(np.uint8))
156 resized = resized.resize(size, resample=interp)
157 resized = np.asarray(resized, dtype=image.dtype)
158 else:
159 raise ValueError(
160 f'Unknown interpolation {interp}.')
161 return resized
162
163
164class ImageDataset(torch.utils.data.Dataset):

Callers 2

preprocessMethod · 0.85
__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected