# Synopse

Dilate one structuring element by another

• Bo = iasedil(B1, B2)
• Bo: Structuring Element
• B1: Structuring Element
• B2: Structuring Element
```01. from numpy import *
02.
03. def iasedil(B1, B2):
04.     from ia870 import ialimits, iagray, iabinary, iaisbinary, iamat2set, iaadd4dil, iasetrans, iaseunion
05.
06.     assert (iaisbinary(B1) or (B1.dtype == int32) or (B1.dtype == int64) or (B1.dtype == float64)) and \
07.            (iaisbinary(B2) or (B2.dtype == int32) or (B2.dtype == int64) or (B2.dtype == float64)), \
08.            'iasedil: s.e. must be binary, int32, int64 or float64'
09.     if len(B1.shape) == 1: B1 = B1[newaxis,:]
10.     if len(B2.shape) == 1: B2 = B2[newaxis,:]
11.     if B1.dtype=='bool' and B2.dtype == 'bool':
12.        Bo = iabinary([0])
13.     else:
14.        Bo = array(ialimits(B1)[0]).reshape(1)
15.        if iaisbinary(B1):
16.           Bo = array(ialimits(B2)[0]).reshape(1)
17.           B1 = iagray(B1,B2.dtype,0)
18.        if iaisbinary(B2):
19.           Bo = array(ialimits(B1)[0]).reshape(1)
20.           B2 = iagray(B2,B1.dtype,0)
21.     x,v = iamat2set(B2)
22.     if len(x):
23.         for i in range(x.shape[0]):
24.             s = iaadd4dil(B1,v[i])
25.             st= iasetrans(s,x[i])
26.             Bo = iaseunion(Bo,st)
27.     return Bo```

# Description

iasedil dilates an structuring element by another. The main difference between this dilation and iadil is that the dilation between structuring elements are not bounded, returning another structuring element usually larger than anyone of them. This gives the composition of the two structuring elements by Minkowski addition.

# Examples

## Example 1

```01. from ia870 import iasecross, iasedil, iaseline, iaseshow, iasedisk
02.
03. B1 = iasecross(1)
04. B2 = iasedil(B1,B1)
05. print 'B2',B2 *1
06.
07. b1 = iaseline(5)
08. print 'iaseshow(b1)',iaseshow(b1) *1
09. b2 = iasedisk(2)
10. print 'iaseshow(b2)',iaseshow(b2) *1
11. b3 = iasedil(b1,b2)
12. print 'iaseshow(b3)',iaseshow(b3) *1```
```B2 [[0 0 1 0 0]
[0 1 1 1 0]
[1 1 1 1 1]
[0 1 1 1 0]
[0 0 1 0 0]]
iaseshow(b1) [[0 0 0 0 1 1 1 1 1]]
iaseshow(b2) [[0 1 1 1 0]
[1 1 1 1 1]
[1 1 1 1 1]
[1 1 1 1 1]
[0 1 1 1 0]]
iaseshow(b3) [[0 0 0 0 0 1 1 1 1 1 1 1 0]
[0 0 0 0 1 1 1 1 1 1 1 1 1]
[0 0 0 0 1 1 1 1 1 1 1 1 1]
[0 0 0 0 1 1 1 1 1 1 1 1 1]
[0 0 0 0 0 1 1 1 1 1 1 1 0]]
```

## Example 2: grayscale, float

```01. f1 = array([[-1.,0.,-2.]])
02. f2 = array([[-1.],[0.],[-2.]])
03. fo = iasedil(f1,f2)
04. print 'fo', fo
05.
06. f1 = array([[1.,2.,3.]])
07. f2 = iaseline(3,90)
08. fo = iasedil(f1,f2)
09. print 'fo', fo
10. fo = iasedil(f2,f1)
11. print 'fo', fo```
```fo [[-2. -1. -3.]
[-1.  0. -2.]
[-3. -2. -4.]]
fo [[-inf -inf -inf]
[-inf -inf -inf]
[  1.   2.   3.]
[  1.   2.   3.]
[  1.   2.   3.]]
fo [[-inf -inf -inf]
[-inf -inf -inf]
[  1.   2.   3.]
[  1.   2.   3.]
[  1.   2.   3.]]
```

## Example 3: grayscale, int

```01. f1 = array([[-1,0,-2]])
02. f2 = array([[-1],[0],[-2]])
03. fo = iasedil(f1,f2)
04. print 'fo', fo
05.
06. f1 = array([[1,2,3]])
07. f2 = iaseline(3,90)
08. fo = iasedil(f1,f2)
09. print 'fo', fo
10.
11. fo = iasedil(f2,f1)
12. print 'fo', fo```
```fo [[-2 -1 -3]
[-1  0 -2]
[-3 -2 -4]]
fo [[-9223372036854775808 -9223372036854775808 -9223372036854775808]
[-9223372036854775808 -9223372036854775808 -9223372036854775808]
[                   1                    2                    3]
[                   1                    2                    3]
[                   1                    2                    3]]
fo [[-9223372036854775808 -9223372036854775808 -9223372036854775808]
[-9223372036854775808 -9223372036854775808 -9223372036854775808]
[                   1                    2                    3]
[                   1                    2                    3]
[                   1                    2                    3]]
```

## Example 3: grayscale, int32

```1. f1 = array([[-1,0,-2]],'int32')
2. f2 = array([[0],[1]],'int32')
3. fo = iasedil(f1,f2)
4. print 'fo', fo```
```fo [[-2147483647 -2147483647 -2147483647]
[         -1           0          -2]
[          0           1          -1]]
```