Skip to content

Commit

Permalink
for sub mean added fail safe in case image has more or less than 3 ch…
Browse files Browse the repository at this point in the history
…annels
  • Loading branch information
Marius-Juston committed Jan 20, 2021
1 parent fffc021 commit f45a368
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions keras_segmentation/data_utils/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ def get_image_array(image_input,
elif imgNorm == "sub_mean":
img = cv2.resize(img, (width, height))
img = img.astype(np.float32)
img[:, :, 0] -= 103.939
img[:, :, 1] -= 116.779
img[:, :, 2] -= 123.68
img = np.atleast_3d(img)

means = [103.939, 116.779, 123.68]

for i in range(min(img.shape[2], len(means))):
img[:, :, i] -= means[i]

img = img[:, :, ::-1]
elif imgNorm == "divide":
img = cv2.resize(img, (width, height))
Expand Down

1 comment on commit f45a368

@djpalumb
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not able to find the commit that originally put in the image means. But was wondering where/how these values were derived?

Please sign in to comment.