Exemplo n.º 1
0
def checkCycle(image):
    # check if number of cycles in the donut image after thinning is 1
    skel = Skeleton(image)
    skel.setThinningOutput(mode="constant")
    thinned_blob = skel.skeletonStack
    label_img, countObjects = ndimage.measurements.label(thinned_blob, structure=np.ones((3, 3, 3), dtype=bool))
    assert countObjects == 1, "number of cycles in single donut is {}".format(countObjects)
Exemplo n.º 2
0
def checkAlgorithmSameObjects(image):
    # check if same objects after and before pruning
    skel = Skeleton(image)
    skel.setPrunedSkeletonOutput()
    label_img, countObjectsn = ndimage.measurements.label(skel.outputStack, structure=np.ones((3, 3, 3), dtype=np.uint8))
    label_img, countObjects = ndimage.measurements.label(image, structure=np.ones((3, 3, 3), dtype=np.uint8))
    assert (countObjectsn == countObjects) or np.sum(label_img == 2) == 1
Exemplo n.º 3
0
def checkSameObjects(image):
    # check if number of objects are same in input and output of thinning
    label_img, countObjects = ndimage.measurements.label(image, structure=ndimage.generate_binary_structure(image.ndim, 2))
    skel = Skeleton(image)
    skel.setThinningOutput(mode="constant")
    thinned_blob = skel.skeletonStack
    label_img, countObjectsn = ndimage.measurements.label(thinned_blob, structure=ndimage.generate_binary_structure(image.ndim, 2))
    assert (countObjectsn == countObjects), ("number of objects in input "
                                             "{} is different from output {}".format(countObjects, countObjectsn))
    return thinned_blob
Exemplo n.º 4
0
def get_thinnedRandomBlob():
    # get random convex blob
    xs = np.random.uniform(-1, 1, size=50)
    ys = np.random.uniform(-1, 1, size=50)
    zs = np.random.uniform(-1, 1, size=50)

    xyzs = list(zip(xs, ys, zs))

    hullz = ConvexHull(xyzs)

    xf, yf, zf = np.mgrid[-1:1:100j, -1:1:10j, -1:1:10j]
    blob = np.ones(xf.shape, dtype=bool)
    for x, y, z, c in hullz.equations:
        mask = (xf * x) + (yf * y) + (zf * z) - c < 0
        blob[mask] = 0
    blob = blob.astype(bool)
    skel = Skeleton(blob)
    skel.setThinningOutput()
    thinned_blob = skel.skeletonStack
    return thinned_blob
Exemplo n.º 5
0
def get_single_voxel_lineNobranches():
    # graph of no branches single line
    sampleLine = get_single_voxel_line()
    skel = Skeleton(sampleLine)
    skel.setNetworkGraph(False)
    return skel.graph
Exemplo n.º 6
0
def get_disjoint_trees_no_cycle_3d():
    # graph of two disjoint trees
    crosPair = get_disjoint_crosses()
    skel = Skeleton(crosPair)
    skel.setNetworkGraph(False)
    return skel.graph
Exemplo n.º 7
0
def get_cycles_with_branches_protrude():
    # graph of a cycle with branches
    sampleImage = get_tiny_loop_with_branches()
    skel = Skeleton(sampleImage)
    skel.setNetworkGraph(False)
    return skel.graph
Exemplo n.º 8
0
def get_cycle_no_tree():
    # graph of a cycle
    donut = get_donut()
    skel = Skeleton(donut)
    skel.setNetworkGraph(True)
    return skel.graph
Exemplo n.º 9
0
import pickle

from skeleton.skeletonClass import Skeleton

"""
Program to run and save statistics after pruning
"""

path = input("enter root directory of the binary pngs")
skeleton = Skeleton(path)
skeleton.segmentStatsAfterPruning()
pickle.dump(skeleton.statsAfter, open("skeletonStas.p", "wb"))
Exemplo n.º 10
0
def checkAlgorithmPreservesImage(image):
    skel = Skeleton(image)
    skel.setThinningOutput(mode="constant")
    thinned_blob = skel.skeletonStack
    assert np.array_equal(image, thinned_blob)
Exemplo n.º 11
0
import pickle

from skeleton.skeletonClass import Skeleton
"""
Program to run and save statistics after pruning
"""

path = input("enter root directory of the binary pngs")
skeleton = Skeleton(path)
skeleton.segmentStatsAfterPruning()
pickle.dump(skeleton.statsAfter, open("skeletonStas.p", "wb"))