Commit d33cc740 authored by Gustavo Pinzon's avatar Gustavo Pinzon
Browse files

bug on test for DirectionalErosion

parent e0d48397
Pipeline #63169 passed with stages
in 26 minutes and 42 seconds
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from __future__ import print_function
import unittest
......@@ -67,8 +67,9 @@ class testAll(unittest.TestCase):
if vect[0]<0: vect[:]=-1*vect[:]
a = random.randrange(1,10,1)
c = random.randrange(1,10,1)
print(a,c)
if numpy.abs(a-c)<2:a = a*2
maxDim = numpy.max([a,c])
maxDim = numpy.max([a+10,c+10])
imTest = spam.kalisphera.makeBlurryNoisySpheroid([maxDim,maxDim,maxDim],
[numpy.floor(maxDim/2), numpy.floor(maxDim/2), numpy.floor(maxDim/2)],
[a,c],
......@@ -79,14 +80,15 @@ class testAll(unittest.TestCase):
imEroded = morph.directionalErosion(imTest, vect, a, c)
self.assertIs(imEroded, None)
#Perform watershed to label the grains
labIm = ws.watershed(imTest) #CHANGE FOR scipy.ndimage.label
labIm = ws.watershed(imTest)
#Perform directional erosion
imEroded = morph.directionalErosion(imTest, [vect], a, c)
#Label the markers
markers, num_seeds = scipy.ndimage.label(imEroded, structure = numpy.ones((3,3,3)))
centerOfMassMarkers = scipy.ndimage.measurements.center_of_mass(markers,labels=markers,index=list(numpy.unique(markers)[1:])) #CHANGE FOR SPAM
#Check that the center of mass of the marker lies inside the labelled grain
self.assertEqual(labIm[int(centerOfMassMarkers[0][0]),int(centerOfMassMarkers[0][1]),int(centerOfMassMarkers[0][2])], numpy.unique(labIm)[1])
# Label the markers
markers = spam.label.watershed(imEroded)
# Compute COM
COM = spam.label.centresOfMass(markers)
#Check that the center of mass of the marker lies inside the labelled grain
self.assertEqual(labIm[int(COM[1][0]),int(COM[1][1]),int(COM[1][2])], numpy.unique(labIm)[1])
def test_greyDilation(self):
#Generate single sphere
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment