• Aucun résultat trouvé

Algorithms for mathematical morphology

N/A
N/A
Protected

Academic year: 2021

Partager "Algorithms for mathematical morphology"

Copied!
54
0
0

Texte intégral

(1)Algorithms for mathematical morphology M. Van Droogenbroeck October 8, 2002. Algorithms for mathematical morphology. M. Van Droogenbroeck.

(2) Outline Introduction Review of existing algorithms and discussion Description of two recent algorithms Comparison Granulometries. Algorithms for mathematical morphology. M. Van Droogenbroeck. 1.

(3) Introduction Do we really need new algorithms for openings? Are existing algorithms not fast enough?. Algorithms for mathematical morphology. M. Van Droogenbroeck. 2.

(4) Introduction Do we really need new algorithms for openings? Are existing algorithms not fast enough? Applications – Industrial applications – Label images Requirements – – – –. Hardware or software? Memory requirements? Is speed the ultimate goal? Should the implementation be reusable?. Algorithms for mathematical morphology. M. Van Droogenbroeck. 2.

(5) Definitions and interpretations The erosion. . . . and dilation . . . of a set. are defined as:. . . (1).   . .  . (2).  . For a function. Algorithms for mathematical morphology. . .  

(6) . . . .   

(7) . . (3). M. Van Droogenbroeck. 3.

(8) The opening . .  . .  . . (4). Geometric interpretation: . Algorithms for mathematical morphology.     . (5). M. Van Droogenbroeck. 4.

(9) Notations and conventions Size of a structuring element: a set as . Algorithms for mathematical morphology. . . . . of size , denoted . . . . . . . . . . , is usually defined (6). dilations. M. Van Droogenbroeck. 5.

(10) Notations and conventions Size of a structuring element: a set as . . . . . of size , denoted . . . . . . . . . . , is usually defined (6). dilations. Here we adopt a different convention! –. is a -pixels wide segment.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 5.

(11) Notations and conventions Size of a structuring element: a set as . . . . . of size , denoted . . . . . . . . . . , is usually defined (6). dilations. Here we adopt a different convention! – . is a -pixels wide segment. is a square or a rectangle. is an horizontal segment and. is a vertical segment. . . Algorithms for mathematical morphology. M. Van Droogenbroeck. 5.

(12) Review of existing algorithms Problem statement: Suppose. . . . Algorithms for mathematical morphology. , we need to compute.  . .. M. Van Droogenbroeck. 6.

(13) Review of existing algorithms Problem statement: Suppose. . . . , we need to compute.  . .. Classification of different algorithms? Elementary implementations Histogram based VAN. H ERK’s algorithm. Algorithms dedicated to binary images Distance based algorithms Algorithms based on the geometric interpretation of openings Algorithms for mathematical morphology. M. Van Droogenbroeck. 6.

(14) Elementary implementations 1. Trivial implementation (a) direct application of the definition. Algorithms for mathematical morphology. complexity proportional to . M. Van Droogenbroeck. 7.

(15) Elementary implementations 1. Trivial implementation complexity proportional to. (a) direct application of the definition 2. Alternative: linear decomposition. (a) based on the chain rule       (b) results in (c) complexity proportional to. Algorithms for mathematical morphology. . . .  .  . .  . . . . . .. .. M. Van Droogenbroeck. 7.

(16) Elementary implementations 1. Trivial implementation complexity proportional to. (a) direct application of the definition 2. Alternative: linear decomposition. (a) based on the chain rule       (b) results in (c) complexity proportional to. . . .  . . .  . . . . . . .. .. 3. Other alternative: logarithmic decomposition (a) Proposed by P ECHT (1985) and VAN DEN B OOMGAARD (1992) (b) The logarithmic decomposition suppresses the redundancy inherent to recursive dilations with a unique convex structuring element.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 7.

(17) For example, if.  . Logarithmic decomposition denotes the border of  . . . .   . .   . ,.    . 

(18)  . (7). (usual notation of size). Algorithms for mathematical morphology. M. Van Droogenbroeck. 8.

(19) For example, if.  . Logarithmic decomposition denotes the border of  . . .   . . .  . , .    . 

(20)  . (7). (usual notation of size). Theorem. . . . . . .   . (8). Algorithms for mathematical morphology. . . M. Van Droogenbroeck. 8.

(21) For example, if.  . Logarithmic decomposition denotes the border of  . .  . . . . ,.   .    . 

(22)   . (7). (usual notation of size). Theorem. . . . . .   . (8) . . . Other decompositions are possible:  . Algorithms for mathematical morphology. . . .   .   .    .   . (9). M. Van Droogenbroeck. 8.

(23) Histogram based algorithms (I) Original idea of H UANG et al. [1979]: a local histogram is computed in a sliding window.. 1. 2. 1 2 3 4. 3. 3. 2. 4. 1 2 3 4. Figure 1: Illustration in the case of an erosion.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 9.

(24) 2D structuring elements.    Bq  Bp                            . Bp.    . Algorithms for mathematical morphology. To be removed To be added. M. Van Droogenbroeck. 10.

(25) Algorithms for mathematical morphology. M. Van Droogenbroeck. 11.

(26) Statistical properties of an erosion/dilation Paper by S TEVENSON (1996) Notations Let .  . . . .  . be random variables with a same distribution..  . . is the PDF and . We define: . .

(27) . . . . . .   . . . .

(28)  . et . . . . .. Then [Dilation].  .  . . .  . . . 

(29)  . .  . and.  .  . . Algorithms for mathematical morphology. .  .    . . . . . . .  . .  .      . . . .    . . .  . . . .    .   .  . .  . . . (10).  . . . . (11) (12). . (13). . .    .    . (14). M. Van Droogenbroeck. 12.

(30) [Erosion] .   . .  . . . .  . Algorithms for mathematical morphology. 

(31). . .  

(32)                . . . . . .    . . . . .    . .   . . .  .    .   .  . . .        . (15) (16) (17) (18) (19). M. Van Droogenbroeck. 13.

(33) What could we do when a min/max value is lost? Solution: built a list of local maximums and keep them in memory.. D OUGLAS (1996). Running Max/Min calculation using a pruned ordered list.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 14.

(34) Histogram based algorithms (II) In the case of a binary image:. 1. 0. 0. 0. 1. 0. only a single counter is needed. Algorithms for mathematical morphology. M. Van Droogenbroeck. 15.

(35) Histogram based algorithms (II) In the case of a binary image:. 1. 0. 0. 0. 1. 0. only a single counter is needed Properties: the computation time does not depend on the size of the structuring element the computation time depends on the image content applicable to arbitrary structuring elements. Algorithms for mathematical morphology. M. Van Droogenbroeck. 15.

(36) VAN. H ERK’s algorithm (I). H ERK (1992) proposed a 1-D algorithm based on separability and a combination of block recursive series which are evaluated forwards and backwards. VAN. Input. Output Algorithms for mathematical morphology. M. Van Droogenbroeck. 16.

(37) VAN. H ERK’s algorithm (II). Properties: 3 comparisons per pixel number of operations independent of the structuring element size but the structure is dependent of the structuring element size! applicable to binary morphology Further improvements proposed by G IL and K IMMEL (ISMM 2000) VAN. H ERK’s algorithm will be used for benchmarking. Algorithms for mathematical morphology. M. Van Droogenbroeck. 17.

(38) Directional Morphological Filtering Problem statement: how should we handle an erosion on a Bresenham line? Answer: papers by J ONES, S OILLE and TALBOT (2002). Algorithms for mathematical morphology. M. Van Droogenbroeck. 18.

(39) Algorithms dedicated to binary morphology YOUNG et al. (1981) has proposed methods suited for hardware implementations. V LIET et al. (1988), S CHMITT (1989), and V INCENT (1991) provided methods  which analyze the border of both and . VAN. Algorithms for mathematical morphology. M. Van Droogenbroeck. 19.

(40) Distance based algorithms L AY (1987) developed an algorithm based on the distance function.. 0 1 1 1 1 1 1 0 1 1 1 1 0 Distance 0 1 2 3 3 2 1 0 1 2 2 1 0   0 0 0 1 1 0 0 0 0 0 0 0 0. Algorithms for mathematical morphology. M. Van Droogenbroeck. 20.

(41) Algorithms based on the geometric interpretation of openings Propagation algorithm for binary openings with a rectangle. Algorithms for mathematical morphology. M. Van Droogenbroeck. 21.

(42) Remark:.  .  . . . . . (20). the opening provides the erosion!. Algorithms for mathematical morphology. M. Van Droogenbroeck. 22.

(43) Single pass opening algorithms. Algorithms for mathematical morphology. M. Van Droogenbroeck. 23.

(44) Computation time 8 Linear erosion Linear opening Linear close-opening. 7.5 7 6.5 6 5.5 5 4.5 4 3.5 3 2.5 2 1.5 1 0.5 0 0. Algorithms for mathematical morphology. 5. 10. 15. 20. 25. M. Van Droogenbroeck. 24.

(45) There are methods for the direct computation of linear openings (also applicable to functions). .  .  . . (21). But direct linear opening algorithms can still help reducing the computation times as.  .  . . . Algorithms for mathematical morphology.   .  . . . . . .  .  . . . .  .  . (22) (23) (24). M. Van Droogenbroeck. 25.

(46) First family of algorithms: 2D scan-based algorithms 2 phases: 1. Scan the input image and build two matrices. 2. Fill the output image with thresholded values. Our algorithms are similar to algorithms that use thresholded distance maps.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 26.

(47) Description of the first phase . . . . The first matrix, denoted or , is filled with the distance of each pixel contained in an object to the right border of that object. 1 1 0 1 0 0 1 1. Original image 1 1 1 1 0 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1. Algorithms for mathematical morphology. 0 0 0 0 0 1 1 1. 5 6 0 9 0 0 3 4. 4 5 7 8 8 1 2 3. 3 4 6 7 7 0 1 2. HOR 2 1 3 2 5 4 6 5 6 5 0 6 0 6 1 0. 0 1 3 4 4 5 5 5. 0 0 2 3 3 4 4 4. 0 1 1 2 2 3 3 3. 1 0 0 1 1 2 2 2. 0 0 0 0 0 1 1 1. M. Van Droogenbroeck. 27.

(48) Building the second matrix: program fragment . . . is the length of the vertical segment of or equal to . . for all   do if      

(49)  . .  . . . . . that has all its value larger.  then. /* Scan to the top */ . .    

(50)    "#$

(51) do while      ! %&  '(  )      . end while /* Scan to the bottom */ . . ). . while . .      !

(52)    "#$

(53) do %&  '(  )     ) . end while *. +. else *. +. .  ,$

(54) .  ,$

(55).   .  . end if Algorithms for mathematical morphology. M. Van Droogenbroeck. 28.

(56) First phase: final result 1 1 0 1 0 0 1 1. Original image 1 1 1 1 0 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1. 0 0 0 0 0 1 1 1. 5 6 0 9 0 0 3 4. 4 5 7 8 8 1 2 3. 3 4 6 7 7 0 1 2. HOR 2 1 3 2 5 4 6 5 6 5 0 6 0 6 1 0. 0 1 3 4 4 5 5 5. 0 0 2 3 3 4 4 4. 0 1 1 2 2 3 3 3. 1 0 0 1 1 2 2 2. 0 0 0 0 0 1 1 1. 2 1 0 1 0 0 2 1. 5 4 3 2 2 8 2 1. Figure 2: A binary object and its corresponding two matrices All rectangles included in. are mentioned in. . and. 5 4 3 2 2 0 2 1. VER 5 7 4 6 3 5 2 4 2 4 0 2 0 2 1 0 . 0 7 6 5 5 3 3 3. and. 0 0 6 5 5 3 3 3 . 0 7 7 5 5 3 3 3. 1 0 0 5 5 3 3 3. .. . but there is some redundancy. Algorithms for mathematical morphology. M. Van Droogenbroeck. 29. 0 0 0 0 0 3 3 3.

(57) The second phase (shown for. Algorithms for mathematical morphology.  . . .  ). M. Van Droogenbroeck. 30.

(58) 1. Selection of positions where 1 1 0 1 0 0 1 1. Original 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0. image 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1. 0 0 0 0 0 1 1 1. 5 6 0 9 0 0 3 4. 4 5 7 8 8 1 2 3. 3 4 6 7 7 0 1 2. . HOR 2 1 3 2 5 4 6 5 6 5 0 6 0 6 1 0. .  . . 0 1 3 4 4 5 5 5. 0 0 2 3 3 4 4 4. 0 1 1 2 2 3 3 3. . and 1 0 0 1 1 2 2 2. 0 0 0 0 0 1 1 1. 2 1 0 1 0 0 2 1. 5 4 3 2 2 8 2 1. . . . . 5 4 3 2 2 0 2 1. VER 5 7 4 6 3 5 2 4 2 4 0 2 0 2 1 0. 0 7 6 5 5 3 3 3. 0 0 6 5 5 3 3 3. 0 7 7 5 5 3 3 3. 1 0 0 5 5 3 3 3. 0 0 0 0 0 3 3 3. 1 1 1 1 1 0 0 0. OUT 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 0 1. 0 0 1 1 1 1 1 1. 0 0 1 1 1 1 1 1. 0 0 0 1 1 1 1 1. 0 0 0 0 0 0 0 0. 2. Fill the first column with run-length values 3. Fill the output image 1 1 0 1 0 0 1 1. Original 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0. image 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1. 0 0 0 0 0 1 1 1. Algorithms for mathematical morphology. INTERMEDIATE 0 4 0 0 0 0 0 5 0 0 0 0 0 5 0 0 4 0 0 5 0 0 5 4 0 5 0 0 5 4 0 0 0 0 5 4 0 0 0 0 5 4 0 0 0 0 0 4. RESULT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0. 0 0 0 0 0 0 0 0. 1 1 1 1 1 0 0 0. M. Van Droogenbroeck. 31.

(59) Implementation issues: optimizations Better use of hardware and software characteristics. – Because of to the linear structure of memory blocks, accesses along a row in a 2-D array are faster than accesses along a column.. Fast access Slow access. –. . is transposed before being stored.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 32.

(60) Implementation issues: optimizations Better use of hardware and software characteristics. – Because of to the linear structure of memory blocks, accesses along a row in a 2-D array are faster than accesses along a column. Fast access Slow access. –. . is transposed before being stored.. Avoid some computation redundancy. – If. . . .  .  . .  . . then. .  . . .  .   .   . .. All these optimizations were included in the implementations. Algorithms for mathematical morphology. M. Van Droogenbroeck. 32.

(61) Generalization of the 2D scan-based algorithm to label images   (   ) 1 1 1 4 4 4 4 4. 3 4 4 1 3 5 5 4. 1 1 1 1 4 4 4 4. LABEL IMAGE 1 2 2 2 2 2 2 1 1 2 2 2 2 2 1 1 2 2 2 2 3 1 1 2 2 2 3 3 4 1 1 2 2 2 2 4 4 4 2 2 2 3 4 4 4 2 2 2 3 4 4 2 2 2 2 3. 2 3 3 3 2 4 4 3. HOR 7 6 5 5 4 3 4 3 2 3 2 1 1 4 3 1 3 2 1 3 2 4 3 2. 1 2 2 2 1 3 3 2. 8 1 1 1 2 2 2 1. Algorithms for mathematical morphology. 4 2 1 5 2 1 1 1. 3 1 4 4 1 4 4 4. 2 3 3 3 3 3 3 3. 2 3 3 3 3 3 3 3. 2 3 3 3 3 3 3 3. 1 2 2 2 2 2 2 2. 3 3 3 3 3 3 3 3. 1 1 1 1 1 1 1 1. 3 2 2 5 4 2 2 3. 1 1 1 0 4 4 4 4. 4 3 3 3 4 2 2 3. 1 1 1 1 4 4 4 4. 4 3 3 3 4 2 2 3. 1 1 1 1 4 4 4 4. 1 4 4 4 1 2 2 3. VER 1 1 1 2 2 2 3 3 3 4 8 8 1 1 1 2 4 4 2 4 4 1 4 4. 1 2 3 1 1 4 4 4. 1 2 2 2 1 3 3 3. 1 7 7 7 7 7 7 7. 1 7 7 7 7 7 7 7. 8 8 8 8 8 8 8 8. 0 1 1 1 0 0 0 0. OUT 2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 0 2 2 0 2 2 0 2 2. 2 2 2 0 2 2 2 2. 0 0 0 0 0 3 3 3. 0 3 3 3 3 3 3 3. 0 3 3 3 3 3 3 3. 0 3 3 3 3 3 3 3. M. Van Droogenbroeck. 33.

(62) Second family of algorithms: list-based algorithms Principle: build a list of rectangles  . .  . .   .  . such that. . all rectangles of . are maximum in size. the list does not contain any redundant rectangle 1000 lines of C code!. Algorithms for mathematical morphology. M. Van Droogenbroeck. 34.

(63) Description. 1 1 0 1 0 0 1 1. Original 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0. image 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1. 0 0 0 0 0 1 1 1. 5 6 0 9 0 0 3 4. 4 5 7 8 8 1 2 3. 3 4 6 7 7 0 1 2. HOR 2 1 3 2 5 4 6 5 6 5 0 6 0 6 1 0. 0 1 3 4 4 5 5 5. 0 0 2 3 3 4 4 4. 0 1 1 2 2 3 3 3. 1 0 0 1 1 2 2 2. 0 0 0 0 0 1 1 1. 2 1 0 1 0 0 2 1. 5 4 3 2 2 8 2 1. 5 4 3 2 2 0 2 1. VER 5 7 4 6 3 5 2 4 2 4 0 2 0 2 1 0. 0 7 6 5 5 3 3 3. 0 0 6 5 5 3 3 3. (i,j)=(0,0) Width=5 Height=2 (i,j)=(0,0) Width=4 Height=5 (i,j)=(0,0) Width=1 Height=7 Basically,. . is replaced by a list.. 21 non-redundant rectangles. Algorithms for mathematical morphology. M. Van Droogenbroeck. 35. 0 7 7 5 5 3 3 3.

(64) Problem of multiple intersections. R1. R2 R3 Two solutions: 1. Avoid rewriting pixels in . 2. Stores all the intersections between elements of . . A thorough examination of all the intersections leads to a variant (called area specific) for which no output pixel is written twice. Algorithms for mathematical morphology. M. Van Droogenbroeck. 36.

(65) Computation times of 2D scan and list-based algorithms 1. Generic 2D scan-based 2. Size-specific 2D scan-based 3. List of rectangles 4. List of rectangles (area specific). 0.9 0.8. Computation time [s]. 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 5. Algorithms for mathematical morphology. 10. 15. 20 Size n. 25. 30. 35. 40. M. Van Droogenbroeck. 37.

(66) The respective contributions of the first and second phase to the total amount of time are about 85%-15%.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 38.

(67) Comparison with other algorithms All algorithms have been reimplemented and optimized for the case of binary images. For the particular case of VAN H ERK’s algorithm (often used as a benchmark), we        transposed the intermediate matrix twice, after and , to achieve a fair comparison with our algorithms.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 39.

(68) Computation times of several algorithms for binary openings. Algorithms for mathematical morphology. M. Van Droogenbroeck. 40.

(69) 1 Linear decomposition Propagation Binary histogram Generic 2D scan-based Size specific 2D scan-based List of rectangles van Herk. Computation time [s]. 0.8. 0.6. 0.4. 0.2. 0 5. 10. Algorithms for mathematical morphology. 15. 20 Size n. 25. 30. 35 M. Van Droogenbroeck. 40 41.

(70) Comparison of algorithms that do not depend on the size of the structuring element. Program complexity Relative computation speed Allow multiple computations Dependent on the content. Algorithms for mathematical morphology. Histogram Very low Fast No Slightly. van Herk Low Fast No No. Scan-based Medium Very fast Yes Yes. List-based High Slow Yes Yes. M. Van Droogenbroeck. 42.

(71) Granulometries V INCENT (2000). Granulometries and Opening Trees.. Algorithms for mathematical morphology. M. Van Droogenbroeck. 43.

(72)

Figure

Figure 1: Illustration in the case of an erosion.
Figure 2: A binary object and its corresponding two matrices  and  . All rectangles included in are mentioned in  and

Références

Documents relatifs

Experimental comparison We have measured the time and memory space used by the computation of a (sequential) 3D Delaunay triangulation of 1 million random points using CGAL,

SCHI Katholiken Wurden Tdl der demokratischen Zivgesenscha nicht Obwohl’ 39 <<Dcr Mcinungsmarkt War damit auch fiir die Kirche zu jener Instanz geworden, vor der. sondern weil

Node-based and edge-based knowledge extraction: The result of the clustering of the hypergraph of the Parkinson Disease map ought to enable knowledge extraction hidden

[41] A.Dahbi, «Étude des performances et commande d’une machine synchrone à aimants permanents utilisée dans les éoliennes», Mémoire de Magister en

These results show that randomized comparison-based algorithms are not so bad, in spite of their limitations in terms of convergence rate: (i) they are optimal in the robust

Les étoiles massives beaucoup plus grosses que le Soleil ont une gravité de surface plus faible. Elles sont par ailleurs beaucoup plus brillantes, ce qui signifie que la

In particular, it emphasizes the fact that ribbon torus-knot with a given filling are in one-to-one correspondence with welded knots before quotient under classical Reidemeister

Temperature in the electrode (left) and mass source term due to copper ablation (equation ( 7 )) at t=5ms.