[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.

Illustrated Source Code

Reading

The binary image of a printed circuit board is read.

Image a = mmBinary(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.

Image b = mmClohole(a);
Image 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.

Image c = mmOpen(b,mmSebox(8));
Image 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.

Image f = mmSubm(b, c);
Image g = mmOpen(f, mmSedisk(8));
Image 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.

Image i = mmSubm(f, g);
Image m = mmOpen(i,mmSedil(mmSeline(8,90), mmSeline(25)));
Image 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.

Image o = mmSubm(i,m);
Image p = mmOpen(o, mmSebox(2));
Image 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.

Image r = mmSubm(o,p);
Image s = mmOpen(r, mmSebox());
Image 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]