提交 35affc14 编写于 作者: R root

dsadd color twist in classification

上级 9b67ef53
......@@ -94,9 +94,8 @@ def random_crop(img, size, settings, scale=None, ratio=None,
return resized
#NOTE:(2019/08/08) distort color func is not implemented
def distort_color(img):
"""distort image color
"""distort image color, include hue, saturation, contrast, brightness
Args:
img: image data
......@@ -104,6 +103,28 @@ def distort_color(img):
Returns:
distorted color image data
"""
contrast=0.5
brightness=0.5
def contrast_brightness(img):
return cv2.addWeighted(img, contrast, img, 0, brightness)
def saturation(img):
(h, s, v) = cv2.split(imghsv)
s = s*satadj
s = np.clip(s,0,255)
imghsv = cv2.merge([h,s,v])
return imghsv
def hue(img):
pass
ops = [contrast_brightness, saturation]
np.random.shuffle(ops)
img = ops[0](img)
img = ops[1](img)
img = ops[2](img)
return img
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册