def scanline_error(tensor, shape):
"""
"""
height, width, channels = shape
value_shape = [height, width, 1]
error_line = tf.maximum(basic([int(height * .75), 1], value_shape, distrib=ValueDistribution.exp) - .5, 0)
error_swerve = tf.maximum(basic([int(height * .01), 1], value_shape, distrib=ValueDistribution.exp) - .5, 0)
error_line *= error_swerve
error_swerve *= 2
white_noise = basic([int(height * .75), 1], value_shape)
white_noise = effects.blend(0, white_noise, error_swerve)
error = error_line + white_noise
y_index = effects.column_index(shape)
x_index = (effects.row_index(shape) - tf.cast(effects.value_map(error, value_shape) * width * .025, tf.int32)) % width
return tf.minimum(tf.gather_nd(tensor, tf.stack([y_index, x_index], 2)) + error_line * white_noise * 4, 1)
评论列表
文章目录