MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / ImageList

Class ImageList

benchmark/utils/cropping.py:41–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39# ---- ImageList utility class ----
40
41class ImageList:
42 def __init__(self, images):
43 if not isinstance(images, (tuple, list, set)):
44 images = [images]
45 self.images = []
46 for image in images:
47 if not isinstance(image, PIL.Image.Image):
48 image = PIL.Image.fromarray(image)
49 self.images.append(image)
50
51 def __len__(self):
52 return len(self.images)
53
54 def to_pil(self):
55 return tuple(self.images) if len(self.images) > 1 else self.images[0]
56
57 @property
58 def size(self):
59 sizes = [im.size for im in self.images]
60 assert all(sizes[0] == s for s in sizes)
61 return sizes[0]
62
63 def resize(self, *args, **kwargs):
64 return ImageList(self._dispatch('resize', *args, **kwargs))
65
66 def crop(self, *args, **kwargs):
67 return ImageList(self._dispatch('crop', *args, **kwargs))
68
69 def _dispatch(self, func, *args, **kwargs):
70 return [getattr(im, func)(*args, **kwargs) for im in self.images]
71
72
73# ---- Crop/resize functions ----

Callers 4

resizeMethod · 0.70
cropMethod · 0.70
rescale_image_depthmapFunction · 0.70
crop_image_depthmapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected