Exemple #1
0
def extract_chip2(img_path, roi, theta, new_size):
    'Crops chip from image ; Rotates and scales; Converts to grayscale'
    # Read parent image
    np_img = io.imread(img_path)
    # Build transformation
    (rx, ry, rw, rh) = roi
    (rw_, rh_) = new_size
    Aff = np.array([[2., 0., 0.], [0., 1., 0.]])
    print('built transform Aff=\n%r' % Aff)
    # Rotate and scale
    #chip = cv2.warpAffine(np_img, Aff, (rw_, rh_), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
    chip = cv2.warpAffine(np_img, Aff, (rw_, rh_))
    #print('warped')
    return chip
Exemple #2
0
def extract_chip2(img_path, roi, theta, new_size):
    'Crops chip from image ; Rotates and scales; Converts to grayscale'
    # Read parent image
    np_img = io.imread(img_path)
    # Build transformation
    (rx, ry, rw, rh) = roi
    (rw_, rh_) = new_size
    Aff = np.array([[ 2., 0.,  0.],
                    [ 0., 1.,  0.]])
    print('built transform Aff=\n%r' % Aff)
    # Rotate and scale
    #chip = cv2.warpAffine(np_img, Aff, (rw_, rh_), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
    chip = cv2.warpAffine(np_img, Aff, (rw_, rh_))
    #print('warped')
    return chip
Exemple #3
0
def mask_creator_demo():
    try:
        from hotspotter import fileio as io
        img = io.imread('/lena.png')
    except ImportError:
        img = np.random.uniform(0, 255, size=(100, 100))

    ax = plt.subplot(111)
    ax.imshow(img)

    mc = MaskCreator(ax)
    plt.show()

    mask = mc.get_mask(img.shape)
    masked_img = apply_mask(img, mask)

    plt.imshow(masked_img)
    plt.title('Region outside of mask is darkened')
    plt.show()
Exemple #4
0
def mask_creator_demo():
    try:
        from hotspotter import fileio as io
        img = io.imread('/lena.png')
    except ImportError:
        img = np.random.uniform(0, 255, size=(100, 100))

    ax = plt.subplot(111)
    ax.imshow(img)

    mc = MaskCreator(ax)
    plt.show()

    mask = mc.get_mask(img.shape)
    masked_img = apply_mask(img, mask)

    plt.imshow(masked_img)
    plt.title('Region outside of mask is darkened')
    plt.show()