Python scipy.ndimage.grey_dilation() Examples
The following are 26
code examples of scipy.ndimage.grey_dilation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.ndimage
, or try the search function
.
Example #1
Source File: MaskDamager.py From PReMVOS with MIT License | 6 votes |
def damage_mask(mask, scale_factor, shift_absolute, shift_factor): assert not (shift_absolute != 0.0 and shift_factor != 0.0) mask = mask.astype("float32") if shift_absolute != 0.0: mask = shift_mask_speed_absolute(mask, max_speed=shift_absolute) elif shift_factor != 0.0: mask = shift_mask_speed_factor(mask, factor=shift_factor) if scale_factor != 0.0: scale = numpy.random.uniform(1 - scale_factor, 1 + scale_factor) mask = scale_mask(mask, scale) # dilation_size = 5 # mask = grey_dilation(mask, size=(dilation_size, dilation_size, 1)) return mask
Example #2
Source File: FCN_CrackAnalysis.py From FCN_for_crack_recognition with MIT License | 5 votes |
def get_skeleton(self): return ndi.grey_dilation(self.img_skl, size=2)
Example #3
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_dilation_scalar_size(self): result = ndimage.grey_dilation(self.array, size=3) assert_array_almost_equal(result, self.dilated3x3)
Example #4
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_morphological_laplace02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 + tmp2 - 2 * array output = ndimage.morphological_laplace(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #5
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_morphological_laplace01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 + tmp2 - 2 * array output = numpy.zeros(array.shape, array.dtype) ndimage.morphological_laplace(array, footprint=footprint, structure=structure, output=output) assert_array_almost_equal(expected, output)
Example #6
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_morphological_gradient02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 - tmp2 output = ndimage.morphological_gradient(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #7
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_morphological_gradient01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 - tmp2 output = numpy.zeros(array.shape, array.dtype) ndimage.morphological_gradient(array, footprint=footprint, structure=structure, output=output) assert_array_almost_equal(expected, output)
Example #8
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_closing02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp = ndimage.grey_dilation(array, footprint=footprint, structure=structure) expected = ndimage.grey_erosion(tmp, footprint=footprint, structure=structure) output = ndimage.grey_closing(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #9
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_opening02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = ndimage.grey_dilation(tmp, footprint=footprint, structure=structure) output = ndimage.grey_opening(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #10
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_opening01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] tmp = ndimage.grey_erosion(array, footprint=footprint) expected = ndimage.grey_dilation(tmp, footprint=footprint) output = ndimage.grey_opening(array, footprint=footprint) assert_array_almost_equal(expected, output)
Example #11
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_dilation03(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] structure = [[1, 1, 1], [1, 1, 1]] output = ndimage.grey_dilation(array, footprint=footprint, structure=structure) assert_array_almost_equal([[8, 8, 10, 10, 6], [8, 10, 9, 10, 8], [9, 9, 9, 8, 8]], output)
Example #12
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_dilation02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] structure = [[0, 0, 0], [0, 0, 0]] output = ndimage.grey_dilation(array, footprint=footprint, structure=structure) assert_array_almost_equal([[7, 7, 9, 9, 5], [7, 9, 8, 9, 7], [8, 8, 8, 7, 7]], output)
Example #13
Source File: test_ndimage.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_grey_dilation01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] output = ndimage.grey_dilation(array, footprint=footprint) assert_array_almost_equal([[7, 7, 9, 9, 5], [7, 9, 8, 9, 7], [8, 8, 8, 7, 7]], output)
Example #14
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_dilation_scalar_size(self): result = ndimage.grey_dilation(self.array, size=3) assert_array_almost_equal(result, self.dilated3x3)
Example #15
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_morphological_laplace02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 + tmp2 - 2 * array output = ndimage.morphological_laplace(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #16
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_morphological_laplace01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 + tmp2 - 2 * array output = numpy.zeros(array.shape, array.dtype) ndimage.morphological_laplace(array, footprint=footprint, structure=structure, output=output) assert_array_almost_equal(expected, output)
Example #17
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_morphological_gradient02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 - tmp2 output = ndimage.morphological_gradient(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #18
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_morphological_gradient01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp1 = ndimage.grey_dilation(array, footprint=footprint, structure=structure) tmp2 = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = tmp1 - tmp2 output = numpy.zeros(array.shape, array.dtype) ndimage.morphological_gradient(array, footprint=footprint, structure=structure, output=output) assert_array_almost_equal(expected, output)
Example #19
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_closing02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp = ndimage.grey_dilation(array, footprint=footprint, structure=structure) expected = ndimage.grey_erosion(tmp, footprint=footprint, structure=structure) output = ndimage.grey_closing(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #20
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_opening02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] structure = [[0, 0, 0], [0, 0, 0]] tmp = ndimage.grey_erosion(array, footprint=footprint, structure=structure) expected = ndimage.grey_dilation(tmp, footprint=footprint, structure=structure) output = ndimage.grey_opening(array, footprint=footprint, structure=structure) assert_array_almost_equal(expected, output)
Example #21
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_opening01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[1, 0, 1], [1, 1, 0]] tmp = ndimage.grey_erosion(array, footprint=footprint) expected = ndimage.grey_dilation(tmp, footprint=footprint) output = ndimage.grey_opening(array, footprint=footprint) assert_array_almost_equal(expected, output)
Example #22
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_dilation03(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] structure = [[1, 1, 1], [1, 1, 1]] output = ndimage.grey_dilation(array, footprint=footprint, structure=structure) assert_array_almost_equal([[8, 8, 10, 10, 6], [8, 10, 9, 10, 8], [9, 9, 9, 8, 8]], output)
Example #23
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_dilation02(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] structure = [[0, 0, 0], [0, 0, 0]] output = ndimage.grey_dilation(array, footprint=footprint, structure=structure) assert_array_almost_equal([[7, 7, 9, 9, 5], [7, 9, 8, 9, 7], [8, 8, 8, 7, 7]], output)
Example #24
Source File: test_ndimage.py From Computable with MIT License | 5 votes |
def test_grey_dilation01(self): array = numpy.array([[3, 2, 5, 1, 4], [7, 6, 9, 3, 5], [5, 8, 3, 7, 1]]) footprint = [[0, 1, 1], [1, 0, 1]] output = ndimage.grey_dilation(array, footprint=footprint) assert_array_almost_equal([[7, 7, 9, 9, 5], [7, 9, 8, 9, 7], [8, 8, 8, 7, 7]], output)
Example #25
Source File: utils.py From AdaptiveWingLoss with Apache License 2.0 | 5 votes |
def generate_weight_map(weight_map,heatmap): k_size = 3 dilate = ndimage.grey_dilation(heatmap ,size=(k_size,k_size)) weight_map[np.where(dilate>0.2)] = 1 return weight_map
Example #26
Source File: dev_Image.py From NodeEditor with MIT License | 4 votes |
def run_FreeCAD_ImageT(self): from scipy import ndimage fn=self.getData('image') import matplotlib.image as mpimg img=mpimg.imread(fn) (sa,sb,sc)=img.shape red=0.005*(self.getData("red")+100) green=0.005*(self.getData("green")+100) blue=0.005*(self.getData("blue")+100) #blue=0 say("rgb",red,green,blue) # andere filtre #img = ndimage.sobel(img) #img = ndimage.laplace(img) im2=img[:,:,0]*red+img[:,:,1]*green+img[:,:,2]*blue im2=np.round(im2) if self.getData('invert'): im2 = 1- im2 #im2 = ndimage.sobel(im2) ss=int((self.getData('maskSize')+100)/20) say("ss",ss) if ss != 0: mode=self.getData('mode') say("mode",mode) if mode=='closing': im2=ndimage.grey_closing(im2, size=(ss,ss)) elif mode=='opening': im2=ndimage.grey_opening(im2, size=(ss,ss)) elif mode=='erosion': im2=ndimage.grey_erosion(im2, size=(ss,ss)) elif mode=='dilitation': im2=ndimage.grey_dilation(im2, footprint=np.ones((ss,ss))) else: say("NO MODE") nonzes=np.where(im2 == 0) pts = [FreeCAD.Vector(sb+-x,sa-y) for y,x in np.array(nonzes).swapaxes(0,1)] h=10 pts = [FreeCAD.Vector(sb+-x,sa-y,(red*img[y,x,0]+green*img[y,x,1]+blue*img[y,x,2])*h) for y,x in np.array(nonzes).swapaxes(0,1)] colors=[img[y,x] for y,x in np.array(nonzes).swapaxes(0,1)] say("len pts",len(pts)) self.setData("Points_out",pts)