[mmdlith] [Up] [mmdpieces] Demonstrations

mmdpcb
Decompose a printed circuit board in its main parts.

Description

The input image is a binary image of a printed circuit board. The decomposition is created mainly using openings by structural elements that depends on the geometry of the circuit board.

Demo Script

Reading

The binary image of a printed circuit board is read.

>>> a = mmreadgray('pcb1bin.tif');

                  
>>> mmshow(a);

                
a

Detecting holes

A new image is created by filling the holes. The input image is subtracted from this new image with holes. The resulting residues are the holes.

>>> b = mmclohole(a);

                  
>>> holes = mmsubm(b,a);

                  
>>> mmshow(b);

                  
>>> mmshow(a, holes);

                
b a, holes

Detecting square islands

The square islands are detected using an opening by a square of size 17x17.

>>> c = mmopen(b,mmsebox(8));

                  
>>> square = mmcdil(c, a);

                  
>>> mmshow(b, c);

                  
>>> mmshow(holes, square);

                
b, c holes, square

Detecting circle islands

The circle islands are detected using an opening by an Euclidean disk on a residues image.

>>> f = mmsubm(b, c);

                  
>>> g = mmopen(f, mmsedisk(8));

                  
>>> circle = mmcdil(g,a);

                  
>>> mmshow(f, g);

                  
>>> mmshow(holes, square, circle);

                
f, g holes, square, circle

Detecting rectangular islands

The rectangular islands are detected using an opening by a rectangle of size 25 x 8 on a residues image. The rectangle structuring element is built from the composition of vertical and horizontal lines.

>>> i = mmsubm(f, g);

                  
>>> m = mmopen(i,mmsedil(mmseline(8,90), mmseline(25)));

                  
>>> rect = mmcdil(m,a);

                  
>>> mmshow(i, m);

                  
>>> mmshow(holes, square, circle, rect);

                
i, m holes, square, circle, rect

Detecting thick connections

The thick connections are detected using an opening by a square on a residues image.

>>> o = mmsubm(i,m);

                  
>>> p = mmopen(o, mmsebox(2));

                  
>>> thin = mmcdil(p,a);

                  
>>> mmshow(o, p);

                  
>>> mmshow(holes, square, circle, rect, thin);

                
o, p holes, square, circle, rect, thin

Detecting thin connections

The thin connections are detected using an opening by a square on a residues image.

>>> r = mmsubm(o,p);

                  
>>> s = mmopen(r, mmsebox());

                  
>>> thick = mmcdil(s,a);

                  
>>> mmshow(r, s);

                  
>>> mmshow(holes, square, circle, rect, thin, thick);

                
r, s holes, square, circle, rect, thin, thick

Displaying all together

The main components of the circuit are overlayed and presented in a single image.

>>> mmshow(holes, square, circle, rect, thin, thick);

                
holes, square, circle, rect, thin, thick

[mmdlith] [Up] [mmdpieces] Python