MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / imread_uint

Function imread_uint

ldm/modules/image_degradation/utils_image.py:185–197  ·  view source on GitHub ↗
(path, n_channels=3)

Source from the content-addressed store, hash-verified

183# get uint8 image of size HxWxn_channles (RGB)
184# --------------------------------------------
185def imread_uint(path, n_channels=3):
186 # input: path
187 # output: HxWx3(RGB or GGG), or HxWx1 (G)
188 if n_channels == 1:
189 img = cv2.imread(path, 0) # cv2.IMREAD_GRAYSCALE
190 img = np.expand_dims(img, axis=2) # HxWx1
191 elif n_channels == 3:
192 img = cv2.imread(path, cv2.IMREAD_UNCHANGED) # BGR or G
193 if img.ndim == 2:
194 img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB) # GGG
195 else:
196 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # RGB
197 return img
198
199
200# --------------------------------------------

Callers 1

split_imagesetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected