def pad(image, by):
     """Pad image with a 1px white and (BY-1)px black border"""
     image_border1 = ia.pad(image, top=1, right=1, bottom=1, left=1,
                        mode="constant", cval=255)
     image_border2 = ia.pad(image_border1, top=by-1, right=by-1,
                        bottom=by-1, left=by-1,
                        mode="constant", cval=0)
     return image_border2
예제 #2
0
 def pad(image, by):
     image_border1 = ia.pad(image,
                            top=1,
                            right=1,
                            bottom=1,
                            left=1,
                            mode="constant",
                            cval=255)
     image_border2 = ia.pad(image_border1,
                            top=by - 1,
                            right=by - 1,
                            bottom=by - 1,
                            left=by - 1,
                            mode="constant",
                            cval=0)
     return image_border2
예제 #3
0
def main():
    image = data.astronaut()

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image)
    cv2.waitKey(TIME_PER_STEP)

    # for value in cycle(np.arange(-255, 255, VAL_PER_STEP)):
    for value in np.arange(-255, 255, VAL_PER_STEP):
        aug = iaa.AddToHueAndSaturation(value=value)
        img_aug = aug.augment_image(image)
        img_aug = ia.pad(img_aug, bottom=40)
        img_aug = ia.draw_text(img_aug,
                               x=0,
                               y=img_aug.shape[0] - 38,
                               text="value=%d" % (value, ),
                               size=30)

        cv2.imshow("aug", img_aug)
        cv2.waitKey(TIME_PER_STEP)

    images_aug = iaa.AddToHueAndSaturation(
        value=(-255, 255), per_channel=True).augment_images([image] * 64)
    ia.imshow(ia.draw_grid(images_aug))

    image = ia.quokka_square((128, 128))
    images_aug = []
    images_aug.extend(iaa.AddToHue().augment_images([image] * 10))
    images_aug.extend(iaa.AddToSaturation().augment_images([image] * 10))
    ia.imshow(ia.draw_grid(images_aug, rows=2))
예제 #4
0
def pad(
        image, by
):  #label permanece na imagem quando houver alguma alteração rotacional
    image_border1 = ia.pad(image,
                           top=1,
                           right=1,
                           bottom=1,
                           left=1,
                           mode="constant",
                           cval=255)
    image_border2 = ia.pad(image_border1,
                           top=by - 1,
                           right=by - 1,
                           bottom=by - 1,
                           left=by - 1,
                           mode="constant",
                           cval=0)
    return image_border2
def main():
    image = data.astronaut()

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image)
    cv2.waitKey(TIME_PER_STEP)

    # for value in cycle(np.arange(-255, 255, VAL_PER_STEP)):
    for value in np.arange(-255, 255, VAL_PER_STEP):
        aug = iaa.AddToHueAndSaturation(value=value)
        img_aug = aug.augment_image(image)
        img_aug = ia.pad(img_aug, bottom=40)
        img_aug = ia.draw_text(img_aug, x=0, y=img_aug.shape[0]-38, text="value=%d" % (value,), size=30)

        cv2.imshow("aug", img_aug)
        cv2.waitKey(TIME_PER_STEP)

    images_aug = iaa.AddToHueAndSaturation(value=(-255, 255), per_channel=True).augment_images([image] * 64)
    ia.imshow(ia.draw_grid(images_aug))