def __call__(self, image: numpy.ndarray, test):
from scipy import stats
def dilate_diff(image, range, iterations=1):
dil = cv2.dilate(image, numpy.ones((range, range), numpy.float32), iterations=iterations)
image = cv2.absdiff(image, dil)
return image
dtype = image.dtype
rgb = (image.transpose(1, 2, 0) + 1) / 2
lab = rgb2lab(rgb) / 100
image = lab[:, :, 0]
image = dilate_diff(image, 3).astype(numpy.float32)
rand = 0.2 + (numpy.random.randn(1) / 20 if not test else 0)
rand = 0.000001 if rand <= 0 else rand
image = cv2.GaussianBlur(image, (5, 5), rand)
rand = 0.4 + (numpy.random.randn(1) / 20 if not test else 0)
rand = 0.000001 if rand <= 0 else rand
image = cv2.GaussianBlur(image, (5, 5), rand)
rand = numpy.random.randn(1) / 40 if not test else 0
image = numpy.power(image, 0.8 + rand)
image = image.astype(dtype)[numpy.newaxis]
return image
评论列表
文章目录