A high-performance image processing library designed to optimize and extend the Albumentations library with specialized functions for advanced image transformations. Perfect for developers working in computer vision who require efficient and scalable image augmentation.
def_add_elementwise_to_uint8(image, values):
# This special uint8 block is around 60-100% faster than the# corresponding non-uint8 function further below (more speedup# for smaller images).## Also tested to instead compute min/max of image and value# and then only convert image/value dtype if actually# necessary, but that was like 20-30% slower, even for 224x224# images.#ifvalues.dtype.kind=="f":
values=np.round(values)
image=image.astype(np.int16)
values=np.clip(values, -255, 255).astype(np.int16)
image_aug=image+valuesreturnnp.clip(image_aug, 0, 255).astype(np.uint8)