(path)
| 218 | # get single image of size HxWxn_channles (BGR) |
| 219 | # -------------------------------------------- |
| 220 | def read_img(path): |
| 221 | # read image by cv2 |
| 222 | # return: Numpy float32, HWC, BGR, [0,1] |
| 223 | img = cv2.imread(path, cv2.IMREAD_UNCHANGED) # cv2.IMREAD_GRAYSCALE |
| 224 | img = img.astype(np.float32) / 255. |
| 225 | if img.ndim == 2: |
| 226 | img = np.expand_dims(img, axis=2) |
| 227 | # some images have 4 channels |
| 228 | if img.shape[2] > 3: |
| 229 | img = img[:, :, :3] |
| 230 | return img |
| 231 | |
| 232 | |
| 233 | ''' |
nothing calls this directly
no outgoing calls
no test coverage detected