MCPcopy Create free account
hub / github.com/CaraJ7/MMSearch / remove_blocks

Function remove_blocks

utils/image_utils.py:91–106  ·  view source on GitHub ↗
(blank_blocks_y, blank_blocks_x, image)

Source from the content-addressed store, hash-verified

89
90
91def remove_blocks(blank_blocks_y, blank_blocks_x, image):
92 mask = np.ones(image.shape[:2], dtype=bool)
93 for start, end in blank_blocks_y:
94 mask[:, start:end] = False
95 for start, end in blank_blocks_x:
96 mask[start:end, :] = False
97
98 # Extract non-black regions
99 if len(image.shape) == 2: # Grayscale
100 rows = np.any(mask, axis=1)
101 cols = np.any(mask, axis=0)
102 return image[rows][:, cols]
103 else: # Color
104 rows = np.any(mask, axis=1)
105 cols = np.any(mask, axis=0)
106 return image[rows][:, cols]
107
108
109# crop & split fullpage screenshot to multiple small images

Callers 1

adaptive_pixel_slimmingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected