예제 #1
0
def _all_orientations_helper(arr, expected_result=None):
    # different 90 degree rotations of a 3D volume and test if number of objects are as
    # expected after thinning
    for reoriented in reorders(arr):
        thinned_volume = thin_volume.get_thinned(reoriented, mode='constant')
        result = _get_count_objects(thinned_volume)
        nose.tools.assert_equal(result, expected_result)
def _getCountObjects(image):
    # count number of 26 or 8 connected objects in the skeletonized image
    if image.ndim == 2:
        skel = getskeletonize2d(image)
        label_skel, countObjects = ndimage.measurements.label(skel, structure=np.ones((3, 3), dtype=bool))
    else:
        skel = get_thinned(image)
        label_skel, countObjects = ndimage.measurements.label(skel, structure=np.ones((3, 3, 3), dtype=bool))
    return countObjects
예제 #3
0
def test_wide_lines():
    test_images = get_thick_lines()
    for image, thickness, center in test_images:
        result = thin_volume.get_thinned(image, mode='reflect')
        nose.tools.assert_equal(result.sum(), image.sum() // thickness)
        nzc = image_tools.list_of_tuples_of_val(result, 1)
        prev_slope = np.subtract(nzc[0], nzc[1])
        for p1, p2 in zip(nzc[:-1], nzc[1:]):
            slope = np.subtract(p1, p2)
            # all points lie on same straight line
            np.testing.assert_array_equal(slope, prev_slope)
            # all points are in the center of the thick line
            nose.tools.assert_in(center, p1)
            nose.tools.assert_in(center, p2)
예제 #4
0
 def setThinningOutput(self, mode="reflect"):
     # Thinning output
     self.skeletonStack = get_thinned(self.inputStack, mode)
예제 #5
0
def test_rectangles():
    test_images = get_stationary_3d_rectangles(width=0)
    for image in test_images:
        np.testing.assert_array_equal(
            image, thin_volume.get_thinned(image, mode='constant'))
예제 #6
0
def test_random_images():
    for image in get_rand_images():
        thin_volume.get_thinned(image, mode='constant')