示例#1
0
def test_nodule():
    logging.info('running: test_nodule...')
    # Load the image.
    img = plt.imread(PATH_IMG_NODULE)[..., 0] / 255.
    
    # g(I)
    gI = gborders(img, alpha=1000, sigma=5.48)
    
    # Morphological GAC. Initialization of the level-set.
    levelset = circle_levelset(img.shape, (100, 126), 20)
    mgac = MorphGAC(levelset, gI, smoothing=1, threshold=0.31, balloon=1)
    
    # Visual evolution.
    fig = plt.figure()
    evolve_visual(mgac, fig, num_iters=45, background=img)
    assert os.path.exists(PATH_OUTPUT)
    fig.savefig(os.path.join(PATH_OUTPUT, 'cmorphsnakes_nodule.png'))
    plt.close(fig)
示例#2
0
def test_starfish():
    logging.info('running: test_starfish...')
    # Load the image.
    imgcolor = plt.imread(PATH_IMG_STARFISH) / 255.
    img = rgb2gray(imgcolor)
    
    # g(I)
    gI = gborders(img, alpha=1000, sigma=2)
    
    # Morphological GAC. Initialization of the level-set.
    levelset = circle_levelset(img.shape, (163, 137), 135)
    mgac = MorphGAC(levelset, gI, smoothing=2, threshold=0.3, balloon=-1)
    
    # Visual evolution.
    fig = plt.figure()
    evolve_visual(mgac, fig, num_iters=100, background=imgcolor)
    assert os.path.exists(PATH_OUTPUT)
    fig.savefig(os.path.join(PATH_OUTPUT, 'cmorphsnakes_starfish.png'))
    plt.close(fig)
示例#3
0
def snake(img_,init):
    # img = np.load("./morphsnakes/testimages/confocal.npy")
    # fig = plt.figure(frameon=False)
    if img_.ndim>3:
        img = img_[:,:,:,0]
    else:
        img = img_

    print(img.shape)
    if True:
        macwe = smorph.MorphACWE(img, smoothing=1, lambda1=1, lambda2=2)
        macwe.levelset = circle_levelset(img.shape, init, 10)
        macwe.levelset = boundingbox_levelset()
        smorph.evolve_visual3d(macwe, num_iters=100)
    else:
        # g(I)
        gI = smorph.gborders(img, alpha=1000, sigma=2)
        # Morphological GAC. Initialization of the level-set.
        mgac = smorph.MorphGAC(gI, smoothing=2, threshold=0.3, balloon=-1)
        mgac.levelset = circle_levelset(img.shape, init, 10)
        smorph.evolve_visual3d(mgac, num_iters=100)