Beispiel #1
0
def halo_two_dee(frame, roll_rows=30, roll_cols=30, thresh_param=50):
    """
    do the halo thing with a 2D roll.
    deceptively, this is doing something rather different than the regular halo, which operates on
    the flattened array.
    """
    # roll the frame a little (rows)
    roll_frame = np.roll(frame, roll_rows, axis=0).astype(np.int32)
    # cols
    roll_frame = np.roll(roll_frame, roll_cols, axis=1).astype(np.int32)

    # get the difference (we'll turn this into the halo)
    difference = np.abs(frame.astype(np.int32) - roll_frame).astype(np.uint8)

    # use adaptive thresholding to find a mask describing the interesting regions in the difference
    # mask = threshold_mask(difference, block_size=thresh_param)
    mask = np.linalg.norm(difference, axis=2) > thresh_param

    # get the differences
    difference = primitives.color_mask(difference, mask)
    # return difference
    # and the original image
    frame = primitives.color_mask(frame, np.logical_not(mask))

    return frame + difference
Beispiel #2
0
def halo_two_dee(frame, roll_rows=30, roll_cols=30, thresh_param=50):
    """
    do the halo thing with a 2D roll.
    deceptively, this is doing something rather different than the regular halo, which operates on
    the flattened array.
    """
    # roll the frame a little (rows)
    roll_frame = np.roll(frame, roll_rows, axis=0).astype(np.int32)
    # cols
    roll_frame = np.roll(roll_frame, roll_cols, axis=1).astype(np.int32)

    # get the difference (we'll turn this into the halo)
    difference = np.abs(frame.astype(np.int32) - roll_frame).astype(np.uint8)

    # use adaptive thresholding to find a mask describing the interesting regions in the difference
    # mask = threshold_mask(difference, block_size=thresh_param)
    mask = np.linalg.norm(difference, axis=2) > thresh_param

    # get the differences
    difference = primitives.color_mask(difference, mask)
    # return difference
    # and the original image
    frame = primitives.color_mask(frame, np.logical_not(mask))

    return frame + difference
Beispiel #3
0
def halo(frame, roll=30, thresh_param=50):
    """
    let's try and put a crazy-ass halo around things.
    roll=30 and thresh_param=50 with the straight hard threshold looks good.
    """

    # roll the frame a little
    roll_frame = np.roll(frame, roll).astype(np.int32)

    # get the difference (we'll turn this into the halo)
    difference = np.abs(frame.astype(np.int32) - roll_frame).astype(np.uint8)

    # print(difference.min())
    # print(difference.max())
    # return difference
    # smooth and enhance the difference
    # difference = smooth_scale(difference, sigma=2, scale=150)

    # use adaptive thresholding to find a mask describing the interesting regions in the difference
    # mask = threshold_mask(difference, block_size=thresh_param)
    mask = np.linalg.norm(difference, axis=2) > thresh_param

    # get the differences
    difference = primitives.color_mask(difference, mask)
    # return difference
    # and the original image
    frame = primitives.color_mask(frame, np.logical_not(mask))

    return frame + difference
Beispiel #4
0
def halo(frame, roll=30, thresh_param=50):
    """
    let's try and put a crazy-ass halo around things.
    roll=30 and thresh_param=50 with the straight hard threshold looks good.
    """

    # roll the frame a little
    roll_frame = np.roll(frame, roll).astype(np.int32)

    # get the difference (we'll turn this into the halo)
    difference = np.abs(frame.astype(np.int32) - roll_frame).astype(np.uint8)

    # print(difference.min())
    # print(difference.max())
    # return difference
    # smooth and enhance the difference
    # difference = smooth_scale(difference, sigma=2, scale=150)

    # use adaptive thresholding to find a mask describing the interesting regions in the difference
    # mask = threshold_mask(difference, block_size=thresh_param)
    mask = np.linalg.norm(difference, axis=2) > thresh_param

    # get the differences
    difference = primitives.color_mask(difference, mask)
    # return difference
    # and the original image
    frame = primitives.color_mask(frame, np.logical_not(mask))

    return frame + difference
Beispiel #5
0
def dark_sobel(frame, proportion=0.5):
    """
    replace the dark regions of the image with triple sobel edges
    """
    sobel = primitives.sobel_triple(frame)
    mask = morphology.binary_dilation(primitives.dark_region_mask(frame, proportion=proportion))
    # keep the bright regions
    new_frame = primitives.color_mask(frame, mask)
    # replace dark with sobel edges
    # np.logical_not(mask, out=mask)
    # new_frame += primitives.color_mask(sobel*4, mask)
    new_frame += primitives.color_mask(sobel*4, np.logical_not(mask))

    return new_frame
Beispiel #6
0
def dark_sobel(frame, proportion=0.5):
    """
    replace the dark regions of the image with triple sobel edges
    """
    sobel = primitives.sobel_triple(frame)
    mask = morphology.binary_dilation(
        primitives.dark_region_mask(frame, proportion=proportion))
    # keep the bright regions
    new_frame = primitives.color_mask(frame, mask)
    # replace dark with sobel edges
    # np.logical_not(mask, out=mask)
    # new_frame += primitives.color_mask(sobel*4, mask)
    new_frame += primitives.color_mask(sobel * 4, np.logical_not(mask))

    return new_frame
Beispiel #7
0
def gray_skeleton(frame):
    """
    draw a skeletonized corner tree on the image using the grayscale
    """
    skeleton = primitives.build_skeleton(primitives.grayscale(frame))

    return primitives.color_mask(frame, np.logical_not(skeleton))
Beispiel #8
0
def gray_skeleton(frame):
    """
    draw a skeletonized corner tree on the image using the grayscale
    """
    skeleton = primitives.build_skeleton(primitives.grayscale(frame))

    return primitives.color_mask(frame, np.logical_not(skeleton))
Beispiel #9
0
def edge_tree(frame):
    """
    color tree with black edges generated using original (sharp) information
    """

    # get a mask for the edges
    edge_mask = primitives.not_edges(frame)

    # build a color tree
    frame = trees.color_tree(frame)

    # now apply the mask to the tree
    frame = primitives.color_mask(frame, edge_mask)
    return frame
Beispiel #10
0
def edge_tree(frame):
    """
    color tree with black edges generated using original (sharp) information
    """

    # get a mask for the edges
    edge_mask = primitives.not_edges(frame)

    # build a color tree
    frame = trees.color_tree(frame)

    # now apply the mask to the tree
    frame = primitives.color_mask(frame, edge_mask)
    return frame
Beispiel #11
0
def not_cell_shading(frame):
    """
    this is definitely not cell shading.
    """

    # get a mask for the edges
    edge_mask = primitives.not_edges(frame)

    # build a color tree
    frame = trees.color_tree(frame)

    # smooth the color tree
    frame = filters.gaussian(frame, sigma=3, multichannel=True)

    # now apply the mask to the tree
    frame = primitives.color_mask(frame, edge_mask)
    return frame
Beispiel #12
0
def not_cell_shading(frame):
    """
    this is definitely not cell shading.
    """

    # get a mask for the edges
    edge_mask = primitives.not_edges(frame)

    # build a color tree
    frame = trees.color_tree(frame)

    # smooth the color tree
    frame = filters.gaussian(frame, sigma=3, multichannel=True)

    # now apply the mask to the tree
    frame = primitives.color_mask(frame, edge_mask)
    return frame