当前位置: 首页>>代码示例>>Python>>正文


Python data.astronaut方法代码示例

本文整理汇总了Python中skimage.data.astronaut方法的典型用法代码示例。如果您正苦于以下问题:Python data.astronaut方法的具体用法?Python data.astronaut怎么用?Python data.astronaut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage.data的用法示例。


在下文中一共展示了data.astronaut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _prepare_images

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def _prepare_images(path_out, im_size=IMAGE_SIZE):
    """ generate and prepare synth. images for registration

    :param str path_out: path to the folder
    :param tuple(int,int) im_size: desired image size
    :return tuple(str,str): paths to target and source image
    """
    image = resize(data.astronaut(), output_shape=im_size, mode='constant')
    img_target = random_noise(image, var=IMAGE_NOISE)
    path_img_target = os.path.join(path_out, NAME_IMAGE_TARGET)
    io.imsave(path_img_target, img_target)

    # warp synthetic image
    tform = AffineTransform(scale=(0.9, 0.9),
                            rotation=0.2,
                            translation=(200, -50))
    img_source = warp(image, tform.inverse, output_shape=im_size)
    img_source = random_noise(img_source, var=IMAGE_NOISE)
    path_img_source = os.path.join(path_out, NAME_IMAGE_SOURCE)
    io.imsave(path_img_source, img_source)
    return path_img_target, path_img_source 
开发者ID:Borda,项目名称:BIRL,代码行数:23,代码来源:bm_comp_perform.py

示例2: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
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 = iaa.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)) 
开发者ID:aleju,项目名称:imgaug,代码行数:27,代码来源:check_add_to_hue_and_saturation.py

示例3: load_images

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def load_images(n_batches=10, sleep=0.0):
    batch_size = 4
    astronaut = data.astronaut()
    astronaut = ia.imresize_single_image(astronaut, (64, 64))
    kps = ia.KeypointsOnImage([ia.Keypoint(x=15, y=25)], shape=astronaut.shape)
    counter = 0
    for i in range(n_batches):
        batch_images = []
        batch_kps = []
        for b in range(batch_size):
            astronaut_text = ia.draw_text(astronaut, x=0, y=0, text="%d" % (counter,), color=[0, 255, 0], size=16)
            batch_images.append(astronaut_text)
            batch_kps.append(kps)
            counter += 1
        batch = ia.Batch(
            images=np.array(batch_images, dtype=np.uint8),
            keypoints=batch_kps
        )
        yield batch
        if sleep > 0:
            time.sleep(sleep) 
开发者ID:aleju,项目名称:imgaug,代码行数:23,代码来源:check_background_augmentation.py

示例4: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()[..., ::-1]  # rgb2bgr
    print(image.shape)

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

    for n_segments in cycle(reversed(np.arange(1, 200, SEGMENTS_PER_STEP))):
        aug = iaa.Superpixels(p_replace=0.75, n_segments=n_segments)
        time_start = time.time()
        img_aug = aug.augment_image(image)
        print("augmented %d in %.4fs" % (n_segments, time.time() - time_start))
        img_aug = ia.draw_text(img_aug, x=5, y=5, text="%d" % (n_segments,))

        cv2.imshow("aug", img_aug)
        cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:19,代码来源:check_superpixels.py

示例5: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    img = data.astronaut()
    img = ia.imresize_single_image(img, (64, 64))
    aug = iaa.Fliplr(0.5)
    unseeded1 = aug.draw_grid(img, cols=8, rows=1)
    unseeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1000)
    seeded1 = aug.draw_grid(img, cols=8, rows=1)
    seeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1000)
    reseeded1 = aug.draw_grid(img, cols=8, rows=1)
    reseeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1001)
    reseeded3 = aug.draw_grid(img, cols=8, rows=1)
    reseeded4 = aug.draw_grid(img, cols=8, rows=1)

    all_rows = np.vstack([unseeded1, unseeded2, seeded1, seeded2, reseeded1, reseeded2, reseeded3, reseeded4])
    ia.imshow(all_rows) 
开发者ID:aleju,项目名称:imgaug,代码行数:23,代码来源:check_seed.py

示例6: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()

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

    height, width = image.shape[0], image.shape[1]
    center_x = width // 2
    center_y = height // 2
    r = int(min(image.shape[0], image.shape[1]) / 3)

    for deg in cycle(np.arange(0, 360, DEG_PER_STEP)):
        rad = np.deg2rad(deg-90)
        point_x = int(center_x + r * np.cos(rad))
        point_y = int(center_y + r * np.sin(rad))

        direction = deg / 360
        aug = iaa.DirectedEdgeDetect(alpha=1.0, direction=direction)
        img_aug = aug.augment_image(image)
        img_aug[point_y-POINT_SIZE:point_y+POINT_SIZE+1, point_x-POINT_SIZE:point_x+POINT_SIZE+1, :] =\
            np.array([0, 255, 0])

        cv2.imshow("aug", img_aug)
        cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:27,代码来源:check_directed_edge_detect.py

示例7: load_images

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def load_images():
    batch_size = 4
    astronaut = data.astronaut()
    astronaut = eu.imresize_single_image(astronaut, (64, 64))
    kps = KeyPointsOnImage([KeyPoint(x=15, y=25)], shape=astronaut.shape)
    counter = 0
    for i in range(10):
        batch_images = []
        batch_kps = []
        for b in range(batch_size):
            batch_images.append(astronaut)
            batch_kps.append(kps)
            counter += 1
        batch = Batch(
            images=np.array(batch_images, dtype=np.uint8),
            keypoints=batch_kps
        )
        yield batch 
开发者ID:liuguiyangnwpu,项目名称:DL.EyeSight,代码行数:20,代码来源:check_background.py

示例8: main_WithColorspace

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main_WithColorspace():
    image = data.astronaut()
    print("image shape:", image.shape)

    aug = WithColorspace(
        from_colorspace="RGB",
        to_colorspace="HSV",
        children=WithChannels(0, Add(50))
    )

    aug_no_colorspace = WithChannels(0, Add(50))

    img_show = np.hstack([
        image,
        aug.augment_image(image),
        aug_no_colorspace.augment_image(image)
    ])

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", img_show[..., ::-1])
    cv2.waitKey(TIME_PER_STEP) 
开发者ID:liuguiyangnwpu,项目名称:DL.EyeSight,代码行数:23,代码来源:check_color.py

示例9: load_images

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def load_images():
    batch_size = 4
    astronaut = data.astronaut()
    astronaut = ia.imresize_single_image(astronaut, (64, 64))
    kps = ia.KeypointsOnImage([ia.Keypoint(x=15, y=25)], shape=astronaut.shape)
    counter = 0
    for i in range(10):
        batch_images = []
        batch_kps = []
        for b in range(batch_size):
            astronaut_text = ia.draw_text(astronaut, x=0, y=0, text="%d" % (counter,), color=[0, 255, 0], size=16)
            batch_images.append(astronaut_text)
            batch_kps.append(kps)
            counter += 1
        batch = ia.Batch(
            images=np.array(batch_images, dtype=np.uint8),
            keypoints=batch_kps
        )
        yield batch 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:21,代码来源:check_background_augmentation.py

示例10: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()[...,::-1] # rgb2bgr
    print(image.shape)

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

    for n_segments in cycle(reversed(np.arange(1, 200, SEGMENTS_PER_STEP))):
        aug = iaa.Superpixels(p_replace=0.75, n_segments=n_segments)
        time_start = time.time()
        img_aug = aug.augment_image(image)
        print("augmented %d in %.4fs" % (n_segments, time.time() - time_start))
        img_aug = ia.draw_text(img_aug, x=5, y=5, text="%d" % (n_segments,))

        cv2.imshow("aug", img_aug)
        cv2.waitKey(TIME_PER_STEP) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:19,代码来源:check_superpixels.py

示例11: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    img = data.astronaut()
    img = misc.imresize(img, (64, 64))
    aug = iaa.Fliplr(0.5)
    unseeded1 = aug.draw_grid(img, cols=8, rows=1)
    unseeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1000)
    seeded1 = aug.draw_grid(img, cols=8, rows=1)
    seeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1000)
    reseeded1 = aug.draw_grid(img, cols=8, rows=1)
    reseeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1001)
    reseeded3 = aug.draw_grid(img, cols=8, rows=1)
    reseeded4 = aug.draw_grid(img, cols=8, rows=1)

    all_rows = np.vstack([unseeded1, unseeded2, seeded1, seeded2, reseeded1, reseeded2, reseeded3, reseeded4])
    misc.imshow(all_rows) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:23,代码来源:check_seed.py

示例12: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)

    aug = iaa.WithColorspace(
        from_colorspace="RGB",
        to_colorspace="HSV",
        children=iaa.WithChannels(0, iaa.Add(50))
    )

    aug_no_colorspace = iaa.WithChannels(0, iaa.Add(50))

    img_show = np.hstack([
        image,
        aug.augment_image(image),
        aug_no_colorspace.augment_image(image)
    ])
    misc.imshow(img_show) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:20,代码来源:check_withcolorspace.py

示例13: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()
    image = ia.imresize_single_image(image, (HEIGHT, WIDTH))

    kps = []
    for y in range(NB_ROWS):
        ycoord = BB_Y1 + int(y * (BB_Y2 - BB_Y1) / (NB_COLS - 1))
        for x in range(NB_COLS):
            xcoord = BB_X1 + int(x * (BB_X2 - BB_X1) / (NB_ROWS - 1))
            kp = (xcoord, ycoord)
            kps.append(kp)
    kps = set(kps)
    kps = [ia.Keypoint(x=xcoord, y=ycoord) for (xcoord, ycoord) in kps]
    kps = ia.KeypointsOnImage(kps, shape=image.shape)

    bb = ia.BoundingBox(x1=BB_X1, x2=BB_X2, y1=BB_Y1, y2=BB_Y2)
    bbs = ia.BoundingBoxesOnImage([bb], shape=image.shape)

    seq = iaa.Affine(rotate=45)
    seq_det = seq.to_deterministic()
    image_aug = seq_det.augment_image(image)
    kps_aug = seq_det.augment_keypoints([kps])[0]
    bbs_aug = seq_det.augment_bounding_boxes([bbs])[0]

    image_before = np.copy(image)
    image_before = kps.draw_on_image(image_before)
    image_before = bbs.draw_on_image(image_before)

    image_after = np.copy(image_aug)
    image_after = kps_aug.draw_on_image(image_after)
    image_after = bbs_aug.draw_on_image(image_after)

    ia.imshow(np.hstack([image_before, image_after]))
    imageio.imwrite("bb_aug.jpg", np.hstack([image_before, image_after])) 
开发者ID:aleju,项目名称:imgaug,代码行数:36,代码来源:check_bb_augmentation.py

示例14: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)
    print("Press ENTER or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))

    children_all = [
        ("hflip", iaa.Fliplr(1)),
        ("add", iaa.Add(50)),
        ("dropout", iaa.Dropout(0.2)),
        ("affine", iaa.Affine(rotate=35))
    ]

    channels_all = [
        None,
        0,
        [],
        [0],
        [0, 1],
        [1, 2],
        [0, 1, 2]
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image[..., ::-1])
    cv2.waitKey(TIME_PER_STEP)

    for children_title, children in children_all:
        for channels in channels_all:
            aug = iaa.WithChannels(channels=channels, children=children)
            img_aug = aug.augment_image(image)
            print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))

            title = "children=%s | channels=%s" % (children_title, channels)
            img_aug = ia.draw_text(img_aug, x=5, y=5, text=title)

            cv2.imshow("aug", img_aug[..., ::-1])  # here with rgb2bgr
            cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:39,代码来源:check_withchannels.py

示例15: main

# 需要导入模块: from skimage import data [as 别名]
# 或者: from skimage.data import astronaut [as 别名]
def main():
    image = data.astronaut()
    image = ia.imresize_single_image(image, (64, 64))
    print("image shape:", image.shape)
    print("Press any key or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))

    k = [
        1,
        2,
        4,
        8,
        16,
        (8, 8),
        (1, 8),
        ((1, 1), (8, 8)),
        ((1, 16), (1, 16)),
        ((1, 16), 1)
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.resizeWindow("aug", 64*NB_AUGS_PER_IMAGE, 64)

    for ki in k:
        aug = iaa.AverageBlur(k=ki)
        img_aug = [aug.augment_image(image) for _ in range(NB_AUGS_PER_IMAGE)]
        img_aug = np.hstack(img_aug)
        print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))

        title = "k=%s" % (str(ki),)
        img_aug = ia.draw_text(img_aug, x=5, y=5, text=title)

        cv2.imshow("aug", img_aug[..., ::-1])  # here with rgb2bgr
        cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:35,代码来源:check_average_blur.py


注:本文中的skimage.data.astronaut方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。