Function iaseshow

Synopse

Display a structuring element as an image.

  • y = iaseshow(B, option="NORMAL")
    • y: Image
    • B: Structuring Element
    • option: String 'NORMAL', ' EXPAND' or ' NON-FLAT'
01. from numpy import *
02. from string import upper
03. 
04. def iaseshow(B, option="NORMAL"):
05.     from ia870 import iaisbinary, iaintersec, iagray, iabinary
06.     from ia870 import iasedil, iaero, iabshow
07. 
08.     option = upper(option)
09.     if option=='NON-FLAT':
10.         y = array([0],int32)
11.         if iaisbinary(B):
12.             B = iaintersec( iagray(B,'int32'),0)
13.     elif option=='NORMAL':
14.         if iaisbinary(B):    y=iabinary([1])
15.         else:
16.            y=array([0],int32)
17.     elif option=='EXPAND':
18.         assert iaisbinary(B), 'This option is only available with flat SE'
19.         y = iasedil( iabinary([1]),B)
20.         b1= iabinary(y>=0)
21.         b0= b1<0
22.         b0[shape(b0)[0]/2, shape(b0)[1]/2] = 1
23.         y = iabshow(b1,y,b0)
24.         return y
25.     else:
26.         print 'iaseshow: not a valid flag: NORMAL, EXPAND or NON-FLAT'
27. 
28.     y = iasedil(y,B)
29.     return y

Description

iaseshow used with the option EXPAND generates an image y that is a suitable graphical representation of the structuring element B. This function is useful to convert a structuring element to an image. The origin of the structuring element is at the center of the image. If B is flat, y is binary, otherwise, y is signed int32 image. When using the option NON-FLAT, the output y is always a signed int32 image.

Examples

Example 1

1. from ia870 import iaseshow, iasecross
2. 
3. b=iasecross(3)
4. print iaseshow(b)
5. print iaseshow(b,'NON-FLAT')
6. a = iaseshow(b,'EXPAND')
7. adshow(a)
[[False False False  True False False False]
 [False False  True  True  True False False]
 [False  True  True  True  True  True False]
 [ True  True  True  True  True  True  True]
 [False  True  True  True  True  True False]
 [False False  True  True  True False False]
 [False False False  True False False False]]
[[-2147483647 -2147483647 -2147483647           0 -2147483647 -2147483647
  -2147483647]
 [-2147483647 -2147483647           0           0           0 -2147483647
  -2147483647]
 [-2147483647           0           0           0           0           0
  -2147483647]
 [          0           0           0           0           0           0
            0]
 [-2147483647           0           0           0           0           0
  -2147483647]
 [-2147483647 -2147483647           0           0           0 -2147483647
  -2147483647]
 [-2147483647 -2147483647 -2147483647           0 -2147483647 -2147483647
  -2147483647]]

Example 2

1. from ia870 import iasedisk, iaseline
2. 
3. b1=iasedisk(2,'2D','EUCLIDEAN')
4. adshow(iaseshow(b1,'EXPAND'))
5. 
6. b2 = iaseline()
7. adshow(iaseshow(b2,'EXPAND'))

See Also

  • iabshow - illustrate the display of binary images
  • iagray - convert binary to grayscale image
  • iaintersec - intersection of images
  • iasedil - Minkowski addition, for operation between structuring elements