# Figure 3.23 - Logical structural opening

## Description

Logical openings pass or do not pass components based only on whether combinations of structuring elements fit. Using reconstructive opening top-hats, this can be extended to requiring nonfitting elements.For connected structuring elements B1, B2, ... Bn and a set U = {u1, u2, ...um} of binary logical vectors, uj = (uj1, uj2, .. ujn), a logical structural filter (LSF) is defined by

Application of this LSF to a text image is shown in Fig. 3.23: (a) text image; (b) reconstructive opening by a short horizontal line; (c) reconstructive opening by a -deg diagonal line; (d) reconstructive opening by a -deg diagonal line; (e) reconstructive opening tophat by a vertical line; (f) intersection of parts (c), (d), and (e), which extracts any character with both diagonals but no vertical line; (g) intersection of parts (b) and (d), which extracts any character with horizontal and -deg diagonal; and (h) the final output of the LSF, which is the union of parts (f) and (g).

## Demo Script

``` 1 import ia870 as MT
2 import numpy as np
3
5
6 B11 = MT.iasedil(MT.iasebox(),MT.iaserot(MT.iaseline(25),90)) # vertical
7
8 C = MT.iaopenrec(A,B11,MT.iasebox())
9 Cneg = MT.iaopenrecth(A,B11,MT.iasebox())
10
11 B12 = MT.iasedil(MT.iasebox(),MT.iaseline(18))              # horizontal
12 D = MT.iaopenrec(A,B12,MT.iasebox())
13 E = MT.iaintersec(C,D)
14
15 B21 = MT.iasedil(MT.iabinary(np.ones(2)),MT.iaserot(MT.iaseline(18),45))
16
17 F = MT.iaopenrec(A,B21,MT.iasebox())
18
19 B22 = MT.iasedil(MT.iabinary(np.ones(2)),MT.iaserot(MT.iaseline(18),-45))
20
21 G = MT.iaopenrec(A,B22,MT.iasebox())
22 H = MT.iaintersec(F,G,Cneg)  # diagonal but vertical
23 I = MT.iaintersec(G,D)       # horizontal and diagonal
24 J = MT.iaunion(H,I)
25
26 fig_a = A
27 fig_b = D
28 fig_c = F
29 fig_d = G
30 fig_e = Cneg
31 fig_f = H
32 fig_g = I
33 fig_h = J
34