Morphological Operation on Printed Circuit Board (PCB) Reverse Engineering using MATLAB Ruzinoor Che Mata Shahrul Azmib, Ruslizam Daudc Abdul Nasir Zulkiflid and Farzana Kabir Ahmade Fakulti of Technology Management Universiti Utara Malaysia 06010 Sintok, Kedah Darulaman. Malaysia. a
[email protected],
[email protected], c
[email protected], d
[email protected], e
[email protected]
ABSTRACT
are dilation and erosion will be employed in segmenting PCB’s image. The image which is used already processed in preprocessing stage and described in previous paper, Reverse Engineering for Obsolete Single Layer Printed Circuit Board (PCB) before applying morphological technique.
Image segmentation has been an important and challenging issue in the field of computer vision over decades. It plays a critical role for most image analysis tasks, such as object detection and recognition. The aim of this paper is to obtain segmented image of Printed Circuit Board (PCB)’s track using mathematical morphological operation. Morphological image analysis is based on the idea that images represent a collection of spatial patterns that can be analyzed based on some predefined patterns called structuring elements. Most basic morphological operation, dilation and erosion have been employed in this research. Detail elaboration on this method will be discussed and experimental results are presented.
In the following section, a brief introduction on mathematical morphology operation will be discussed. In section 3 the methodology that has been employed will be describes. It will include the phases involved in segmenting the PCB’s track. Finally, conclusions and possible extension of the algorithm are discussed in section 4.
2.0 MATHEMATICAL MORPHOLOGY OPERATION
Keywords Printed Circuit Board, Morphological Operation, Dilation, Erosion
Morphological operations used in the process of segmenting images. Image segmentation refers to the process of finding regions in an image that represent objects or meaningful parts of objects. Common applications of morphological operators include filling small holes in objects, separating adjacent or slightly overlapping objects, and joining broken boundaries into continuous segments.
Reverse Engineering Image segmentation,
1.0 INTRODUCTION Image segmentation is an important yet difficult computer vision task, as it requires to some extent a semantic understanding of the image. Generally, it is the process of partitioning the image into disjoint regions, each one being homogeneous and connected with respect to some property, such as gray-value, color, texture, motion. It can be divided into three different but complementary stages, for example 1) preprocessing; 2) region/feature extraction; and 3) segmentation algorithm application, each one being significant for the final segmentation result.
Dilation and erosion are two fundamental morphological operations. Dilation adds pixel to the boundaries in an image, while erosion removes pixels on object boundaries. The rule used to determine whether the pixels should be operated using dilation or erosion (Xu, Gu & Peters, 2005) I. Dilation – The value of the output is the maximum value of all the pixels in the input pixel’s neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel is set to 1 as illustrated in Fig. 1.
This paper aims to obtain segmented PCB image using morphology operation. Morphology relates to the structure or form of objects. Morphological filtering simplifies a segmented image to facilitate the search for objects of interest. This is done by smoothing out object outlines, filling small holes and eliminating small projections. The two principal morphological operations
529
Table 1: Types of flat structuring element in Matlab
1 1 1 1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1 1 0 0 0
Flat structuring element Arbitrary Pair Diamond Periodicline Disk Rectangle Line Square Octagon
1
I. Arbitrary Input Image
Output Image
Fig 1: Morphological Dilation of a Binary Image
II. Erosion – The value of the output pixel is the minimum value of all the pixels in the input pixel’s neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set 0. 2.1
SE = strel ('arbitrary',NHOOD)
(2)
SE = strel (NHOOD)
(3)
Syntax above creates a flat structuring element where NHOOD specifies the neighborhood. NHOOD is a matrix containing 1's and 0's; the location of the 1's defines the neighborhood for the morphological operation. The center (or origin) of NHOOD is its center element, given by floor ((size(NHOOD)+1)/2).
Structuring Element in Morphology Operation
An essential part of the dilation and erosion operations is the structuring element which is used to probe the input image. The number of pixels added or removed from the object in an image depends on the size and shape of the structuring element. A structuring element is a matrix consisting of only 0’s and 1’s that can have any arbitrary shape and size. The pixels with values of 1 define the neighborhood (Boomgaard & Balen, 1992). Fig.2: Arbitrary structuring element
Two-dimensional or flat structuring elements are typically much smaller than the image being processed. The center pixel of the structuring element, called the origin, identifies the pixel of interest or the pixel being processed (Rolf, 1993). The pixels in the structuring element containing 1’s define the neighborhood of the structuring element. These pixels are also considered in dilation or erosion processing. There is another kind of structuring element, called three-dimensional or nonflat. It uses 0’s and 1’s to classify the extent of the structuring element in the x- and y- planes and add height values to the third dimension. This research adopts the two-dimensional structuring elements.
II. Diamond SE = strel('diamond',R)
(4)
Syntax (4) creates a flat, diamond-shaped structuring element, where R specifies the distance from the structuring element origin to the points of the diamond as shown in Fig. 3. R must be a nonnegative integer scalar.
MatLab which is software meant for high performance language in technical computing is used as a tool for segmentation. Strel is a function in MatLab that create morphology structuring element. Following is the syntax for structuring element, SE: SE = strel (shape,parameters)
(1)
Fig.3: Diamond structuring element
Where shape is a string specifying the desired shape and parameters is a list of factors that identify information about the shape, such as its size. This table lists all the supported shapes. Depending on shape, strel can take additional parameters. Next are the descriptions of creating each type of structuring element (Jones & Soille, 1996; The MathWorks , 2004).
III. Disk SE = strel('disk',R,N)
530
(5)
Syntax (5) creates a flat, disk-shaped structuring element, where R specifies the radius. R must be a nonnegative integer. N must be 0, 4, 6, or 8.
Fig.6: Octagon structuring element
III.
I.
Pair
Fig.4: Disk structuring element
SE = strel('pair',OFFSET)
Linear
Syntax (8) creates a flat structuring element containing two members. One member is located at the origin. The second member's location is specified by the vector OFFSET. OFFSET must be a two-element vector of integers.
SE = strel('line',LEN,DEG)
(6)
Syntax (6) creates a flat, linear structuring element, where LEN specifies the length, and DEG specifies the angle (in degrees) of the line, as measured in a counterclockwise direction from the horizontal axis. LEN is approximately the distance between the centers of the structuring element members at opposite ends of the line.
(8)
Fig.7: Pair structuring element
IV.
Periodicline
SE = strel('periodicline',P,V)
Syntax (9) creates a flat structuring element containing 2*P+1 members. V is a two-element vector containing integer-valued row and column offsets. One structuring element member is located at the origin. The other members are located at 1*V, -1*V, 2*V, -2*V, .., P*V, P*V.
Fig.5: Line structuring element
II.
(9)
Octagon
SE = strel('octagon',R)
(7)
Syntax (7) creates a flat, octagonal structuring element, where R specifies the distance from the structuring element origin to the sides of the octagon, as measured along the horizontal and vertical axes. R must be a nonnegative multiple of 3. Fig.8: Octagon structuring element
V.
Rectangle
SE = strel('rectangle',MN)
531
(10)
Syntax (10) creates a flat, rectangle-shaped structuring element, where MN specifies the size. MN must be a two-element vector of nonnegative integers. The first element of MN is the number of rows in the structuring element neighborhood; the second element is the number of columns.
3.2 Edge Detection The object to be segmented differs greatly in contrast from the background image. Changes in contrast can be detected by operators that calculate the gradient of an image. The gradient image can be calculated and a threshold can be applied to create a binary mask containing the segmented tracks. First, edge detection is used to calculate the threshold value, then tune the threshold value and use edge again to obtain a binary mask that contains the segmented tracks as shown in Fig. 12.
Fig.9: Octagon structuring element
VI.
Square
SE = strel('square',W)
(11)
Syntax (11) creates a square structuring element whose width is W pixels. W must be a nonnegative integer scalar.
Fig. 12 Binary mask of PCB’s tracks
3.3 Dilation The binary gradient mask shows lines of high contrast in the image. These lines do not quite delineate the outline of the tracks. Compared to the original image, there are gaps in the lines surrounding the object in the gradient mask. These linear gaps disappeared if the Sobel image is dilated using linear structuring elements, which created using the strel function. Fig. 13 shows dilated gradient mask using linear structuring element.
Fig.10: Octagon structuring element
3.0 MORPHOLOGY OPERATION ON PCB USING MATLAB PCB’s tracks can be detected using morphological technique in MatLab. There are several steps involved such as: 3.1 Read an Image Image of raw PCB is read and converted from truecolor or RGB to grayscale and then to binary image as shown in Fig. 11. The image is necessary to be in binary form to enable processing of morphology operation.
Fig. 13: Dilated gradient mask
Fig. 11: PCB Binary Image
532
3.4 Fill Holes The dilated gradient mask shows the reasonably outline, but there are still holes in the interior of the tracks. To fill these holes the imfill function is used. Fig. 14 shows image that operated with imfill function.
Fig. 16: Segmented PCB image
4.0 CONCLUSION Morphology is a broad set of image processing operation that process images based on shapes. Morphological operation applies a structuring element to an input image, creating an output image of the same size. This research used linear structuring element as it has the same size and shape of PCB’s tracks. The aim is this research is to segmenting the PCB’s tracks for re fabrication stages in further process. Using dilation and erosion function in morphological operation, a fine segmented PCB’s tracks image was achieved.
Fig. 14: PCB binary image with imfill function
3.5 Remove Connected Object in Borders The tracks have been successfully segmented, but it has some defects. Objects that are connected to the border of the image need to be removed using the imclearborder function.
REFERENCES Boomgaard, V.D. & Balen, R.V. (1992), Methods for Fast Morphological Image Transforms Using Bitmapped Images. Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, 54(3), 252-254. Jones, R. & Soille, P. (1996). Periodic lines: Definition, cascades, and application to granulometrie. Pattern Recognition Letters, 17(10), 1057-1063. Rolf, A. (1993). Radial Decomposition of Discs and Spheres. Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, 55( 5), 325-332. The MathWorks, (2004). Image Processing Toolbox For Use With MATLAB, Version 5. The MathWorks, Inc Xu, J., Gu, L., & Peters, T.M. (2005). A Novel Multistage 3D Medical Image Segmentation: Methodology and Validation. In proceeding of 2005 International Conference on Computational Intelligence and Security, Xi’an China.
Fig. 15: Cleared border PCB image
3.6 Erosion Finally, in order to make the segmented object look natural, the tracks are smoothen by erode function with a diamond structuring element.
533