Multi-type Noise Removal in Lead Frame Image Using Enhanced Hybrid Median Filter

— Image filtering technique plays a very important role in digital image processing. It is one of the major steps in image enhancement and restoration. This filtering technique can remove noise and preserve the details of the image for feature extraction processes. However, filtering process can still be considered as a huge challenge for image filtering technique. Common noises in the image such as Salt & Pepper, Gaussian, Speckle, and Poisson Noise are still posing problems in filtering process where the quality and the originality of the images can be degraded and disturbed. Meanwhile, a single filtering technique is usually fit to deal with only certain specific noise. This paper presents an enhanced Hybrid Median Filter (H 6 F) technique to improve image filtering process. The technique involves 3x3 sub-mask and determination of new pixel value from the median value of the three steps which are the median calculation of ‘+’-neighbours, median calculation of all sub-masks and selection of centre pixel value. The H6F technique has been computed on lead frame inspection system. The results have shown that the technique has been able to remove multi-type of noises efficiently and produce exceptionally low Mean-Square Error (MSE) while consuming the acceptable amount of execution time when compared to other filtering techniques.


I. INTRODUCTION
Images in digital image processing are normally corrupted, and its quality is usually degraded by the undesired signal called noise. Noise can be described as a random signal, and the main source of this signal comes from light levels and sensor temperature [1]. Besides that, the presence of noise also come from environmental conditions that affect the imaging sensor, dust particles that exist in the scanner and the interference in transmission channel [2]. Noise exists in various types and characteristics. Common types of noise that have been studied in digital image processing are Salt and Pepper noise, Gaussian noise, Speckle noise and Poisson noise [3].
According to [4], noise can destroy most of the part of image information which can lead to image distortion and reduce the visual quality of the image [5]. Due to noise, the digital image also could lose essential information for human or machine to analyse. Failing to analyse image correctly might give a negative impact on us especially in a critical area such as medicine that deal with human life and in industrial production in which can endanger the end user of the product. To address these noise related problems in digital image processing, image filtering technique has generally been applied to restore the originality of the image. This technique is important to improve the accuracy of image processing algorithm. There are many image filtering techniques that have been developed such as a median filter to remove Salt and Pepper noise [6], Gaussian filter to remove Gaussian noise [7] and others [8], [9].
Image processing techniques have been used and applied in industrial production for quite some time specifically in machine's Vision System (VS) to check the quality or condition of specific products. Among the products that require quality inspection is a lead frame (Fig. 1). The lead frame is a thin layer of metal frame inside a chip package that carries signal from the die to outside in which semiconductors are attached during the package assembly process. The quality of the lead frame is very important because if there is any tiny defect, it can seriously endanger the performance and reliability of the Integrated Circuit (IC) device. The small size of the design and the reflective surface of the lead frame are the big challenges that need to be overcome to obtain good and high-quality images. Normally, the image of lead frame taken during the inspection using VS contains various types of noise and image filtering techniques have been commonly applied to deal with these noises. However, even though these techniques have been able to remove the specific or single type of noise, they still face difficulties when dealing with the images that contain multi-types of noise. Therefore, this research focuses on developing image filtering technique to remove multi-types of noise using an enhanced Hybrid Median Filter known as H 6 F on lead frame image since there is a lack of study on lead frame images. This H 6 F has been developed based on the widely-used Hybrid Median Filter (HMF) technique. The technique has been tested on lead frame inspection system and its performance was compared to other six image filtering techniques by using MSE method and execution time was taken. This research also focuses on the low-density type of noises since the vision system that use to inspect lead frame image is in a controlled condition that normally noises that present in the image is quite low. Basically, MSE method was used to investigate whether the filter used can remove noise or not. The execution time was taken to ensure the filter has a good quality of algorithm and determine whether it has acceptable time for the vision system to execute the program as mention in [1].
According to [2], the primary mechanism for image enhancement and restoration during the early development of image processing were the linear filters. This was due to their mathematical simplicity, simple design and easy implementation. However, the image that was processed using this linear filter tends to blur on the edges of the image and the filter did not remove Gaussian noise adequately. Many researches were conducted previously to improve image filtering methods. Non-linear filters were found to be the better filters in removing noise [3]. Among them are the common Median Filter (Med Filter), Minimum Filter (Min Filter) and Maximum Filter (Max Filter).

A. Median Filter
Firstly, as described in [4] and [5], Median Filter is a nonlinear filtering method that is known for its ability to remove impulsive type noise, while preserving sharp edges and fine details in digital images. In this filtering process, the value of the pixel at a certain point 'p' will be computed and replaced by the median value of its 8-neighbourhood pixel. It can be defined as the following equation: where g_med(p) is the output of the Median Filter at image point p, median{.} is the median operator, f(p) is the input image of point p and N 8 is the 8-neighbourhood pixel of point p.

B. Minimum Filter
The second non-linear filter which is Min Filter will enhance the dark values of the pixel in the image by increasing its area. This method is similar to the dilate function that processes the darkest area in the surrounding pixel and extends the region. Min Filter will select the minimum value of the 8-neighbourhood pixels of pixel 'p' (darkest point) and replace it at the pixel 'p'. The output g_min(p) of Min Filter at image point p can be defined as: where g_min(p) is the output of the Min Filter at image point p, min{.} is the minimum operator, f(p) is the input image of point p and N 8 is the 8-neighbourhood pixel of point p.

C. Maximum Filter
The third non-linear filter which is Max Filter acts as the opposite of Min Filter. Max Filter will select the maximum value of the 8-neighbourhood pixels of pixel 'p' (brightest point) and replace it at pixel 'p'. The definition of Max Filter can be written as: where g_max(p) is the output of the Max Filter at image point p, max{.} is the maximum operator, f(p) is the input image of point p and N 8 is the 8-neighbourhood pixel of point p.
In general, Max Filter is good for removal of Pepper noise type while Min Filter performs better in removing Salt noise type [6].

D. Hybrid Median Filter (HMF)
HMF [7] is a nonlinear filter that commonly used in image processing to remove impulsive noise. It can preserve the edges of an image better than the basic median filter. After this three-steps ranking operation technique is developed, it is widely used and improved ever since by others [8], [9] with the aim to remove noise better. HMF has a vital role in image processing and can be written as:  (4) where hmf(p) is the output of the HMF filter at image point p, median{.} is the median operator, f(p) is the input image of point p, + 5 is the '+' neighbours of point p and x 5 is the 'x' neighbours of point p. If point 'p' has (x, y) coordinate, then '+'-neighbours of point 'p' are at coordinate (x-1, y), (x+1, y), (x, y-1) and (x, y+1) while 'x'-neighbours of point 'p' are at coordinate (x+1, y+1), (x+1, y-1), (x-1, y+1) and (x-1, y-1). of point p.
In 2013, this hybrid technique was used to remove impulse noise and was tested on rice image as studied in [10]. As mentioned in this study, HMF can remove impulse noise smooth and efficiently. Besides that, it also preserves the edges and brightness difference better when compared to Median Filter.

E. Hybrid Cross Median Filter (H 1 F)
Hybridization of image filtering techniques has been introduced since more than two decades ago to improve image filtering processes. The Hybrid Cross Median Filter or H 1 F has been considered as a non-linear filtering technique for image enhancement and was first introduced in 2011 to remove Gaussian noise from brain tumor image [7]. The results show that H 1 F works better than HMF and Median filter in removing Gaussian noise with the performance is measured by Root Mean Square Error (RMSE) method and Peak Signal Noise Ratio (PSNR) method. H 1 F can be expressed as the following: where H 1 F(p) is the output of the H 1 F filter at image point p, median{.} is the median operator, f(p) is the input image of point p, L 3 is the LT neighbours of point p and R 3 is the RT neighbours of point p.
As defined in equation [4], H 1 F works by determining the median 'm' of the median value of the pixel of LT neighbours of point 'p', the median value of the pixel of RT neighbours of point 'p' and the pixel value of point 'p'. This median 'm' is then replaced the pixel value of point 'p'. If point 'p' has (x, y) coordinate, then LT neighbours are at point (x-1, y-1) and (x+1, y+1) while RT neighbours are at point (x+1, y-1) and (x-1, y+1).

F. Hybrid Min Filter (H 2 F)
Hybrid Min Filter or H 2 F is another hybrid image filtering technique, and it has played an important role in image processing and vision system. H 2 F is different from Min Filter and has been used to remove Salt noise. This filter was proposed in the same paper that proposed H 1 F and tested with medical image to remove Gaussian noise [7]. The H 2 F will take the minimum of the median value of the pixel of LT neighbours of point 'p', the median value of the pixel of RT neighbours of point 'p' and the pixel value of point 'p' and then use it to replace the pixel value of point 'p'. H 2 F can be defined as: where H 2 F(p) is the output of the H 2 F filter at image point p, min{.} is the minimum operator, median{.} is the median operator, f(p) is the input image of point p, L 3 is the LT neighbours of point p and R 3 is the RT neighbours of point p.

G. Hybrid Max Filter (H 3 F)
The fourth hybrid technique is known as Hybrid Max Filter or H 3 F. It is different from usual Max Filter and suitable for Pepper noise. According to [7], H 3 F can remove Gaussian noise from brain tumor image significantly better than H 1 F and H 2 F. H 3 F performs by taking the maximum of median value of the pixel of LT neighbours of point 'p', the median value of the pixel of RT neighbours of point 'p' and the median value of the pixel of point 'p' and then replace the pixel value of point 'p'. This hybrid technique can be written as: where H 3 F(p) is the output of the H 3 F filter at image point p, max{.} is the maximum operator, median{.} is the median operator, f(p) is the input image of point p, L 3 is the LT neighbours of point p and R 3 is the RT neighbours of point p.

H. Hybrid Sigma Filter (H 4 F)
Besides that, in 2013, the authors in [2] have proposed another hybrid technique called Hybrid Sigma Filter or H 4 F. H 4 F will take the median of the median value of the pixel of sigma neighbours of point 'p', the median value of the pixel of all neighbours of point 'p' and value of the pixel of point 'p' and then use it to replace the pixel value of point 'p'. This H 4 F technique has been considered to work well for medical images. This H 4 F can be written as:  (8) where H 4 F(p) is the output of the H 4 F filter at image point p, median{.} is the median operator, f(p) is the input image of point p, N 8 is the 8-neighbourhood pixel of point p and ε 5 is the sigma neighbours of point p. If point 'p' has (x, y) coordinate, then sigma neighbours are at the point (x-1, y), (x+1, y), (x, y-1) and (x-1, y-1).

I. Hybrid Min Max Filter (H 5 F)
The first introduction of Hybrid Min Max Filter or H 5 F was in 2012. This H 5 F is the hybridization of H 2 F and H 3 F to remove Salt and Pepper noises. It is presented through the work done in [11]. This technique was tested using knee image with various noise level. Through the investigation, H 5 F has the best performance in removing random Impulse noise when compared with Fuzzy Hybrid Max (9) where g(p) is the output of the H 2 F filter at image point p, H 5 F(p) is the output of the H 5 F filter at image point p, max{.} is the maximum operator, min{.} is the minimum operator, median{.} is the median operator, f(p) is the input image of point p, L 3 is the LT neighbours of point p and R 3 is the RT neighbours of point p.
In 2014, this hybrid H 5 F technique was tested on brain images for Gaussian noise removal, dog image for speckle noise removal and the Lena image for impulse noise removal with comparison with Wiener filter technique. It has been concluded in [12] that H 5 F can independently remove Gaussian noise, Speckle noise and impulse noise in the respective images with significantly higher performance than Wiener filter. However, the images that contain multi-types of noises have neither been tested by this H 5 F nor the previous hybrid techniques.

II. MATERIAL AND METHOD
In this research, an enhanced Hybrid Median Filter or H 6 F has been proposed and tested. If point 'p' has (x, y) coordinate, then '+' neighbours of point 'p' are at coordinate (x-1, y), (x+1, y), (x, y-1) and (x, y+1). All the sub-masks are at coordinate (x+1, y+1), (x, y+1), (x-1, y+1), (x+1, y), (x, y), (x-1, y), (x+1, y-1), (x, y-1) and (x-1, y-1). Mathematically, H 6 F can be written as:  (10) where h 6 f(p) is the output of the H 6 F filter at image point p, median{.} is the median operator, f(p) is the input image of point p, + 5 is the '+'-neighbours of point p and N 8 is the 8neighbourhood pixel of point p. The algorithm of H 6 F technique can be defined as follows: • Read the original image, • Convert the original image from RGB to grayscale, • Determine the 3x3 sub-mask with padded replicate, • Find the median of '+'-neighbours, • Find the median of all sub-masks, • Select the centre pixel value, • Calculate the median of value from step (4), (5) and (6), • Replace the centre pixel value with the newly calculated value in step (7).
The performance of H 6 F technique has been analysed and compared to other hybrid techniques by using Mean Square Error (MSE) method. This MSE method basically represents the average difference between the original image and the predicted image [13]. MSE can be defined as: ( 1 (11) where MSE is the output of MSE value, X j,k is the desired output image, X' j,k is the predicted output image and m and n are the total number of pixels in the horizontal and the vertical dimensions of the image respectively.
The lower the value of MSE indicates better performance of the technique.

III. RESULTS AND DISCUSSION
The H 6 F filtering technique has been tested on a sample of 20 lead frame images, and the average of MSE was taken.  Based on Table 1, it can be concluded that the most successful image filtering technique in removing Salt and Pepper noise with different densities is H 6 F. The proposed technique has the lowest MSE value for each type of densities for Salt and Pepper noise which indicates that the technique has the low average difference between the original image and the filtered output image. Therefore, it can be said that this filter has recovered almost all part of the interrupted pixels in the image by the Salt and Pepper noise. The nearest filters that have as good performance as H 6 F are HMF followed by H 4 F, H 1 F, and H 5 F. The H 2 F and H 3 F techniques performed poorly and the MSE values are more than 10 times higher compared to the H 6 F.
Next, the performance of all filters when Gaussian noise with different densities was added into the 20 lead frame images is investigated. The average MSE values calculated were presented in Table 2. The average value of MSE for 20 lead frame images tested with different densities of Speckle noise was calculated and presented in Table 3.  Table 4.
In Table 5, the best performance in removing multi-type of noise in the lead frame image is H 6 F. The proposed filtering technique has the lowest average MSE value. HMF, H 4 F, and H 5 F also can be classified as good multi-type noise removal because the MSE value is almost same as H 6 F. Meanwhile, H 1 F, H 2 F, and H 3 F perform appallingly with a high value of MSE. The multi-type of noise with different density is then experimented, and the outcome of each filter are shown in Table 5. On the other hand, the execution time of each filter algorithm was taken 20 times by using MATLAB function 'tic' and 'toc'. The average times for all filters were then calculated and presented in Table 6  Firstly, Fig. 3 shows the example of an original image of a lead frame that was taken by a camera and converted to a grayscale image and used as the input image. Fig. 3 A sample of grayscale lead frame image that is used as input image In Fig. 4, black and white pixels can be seen scattered in the image. These black and white pixels that randomly appeared are known as Salt and Pepper noise with 0.10 density.    Image with multi-type of noise which Salt and Pepper, Gaussian, Speckle and Poisson noise is added together is presented in Fig, 8. Based on human vision perspective, image filtered by H 6 F technique (Fig. 9) has a better view and look almost same as the original image compared to H 2 F technique (Fig. 10). This indicates that the H 6 F can remove multi-type of noise efficiently and able to recover the original pixel quite well. Filtering image with multi-type of noise is considered as a big challenge in image processing. This is due to its complicated attributes such as the probability of salt and pepper, Gaussian distribution and Poisson process that are added together to the image. This noise can affect the Vision System inspection. For example, in Fig. 8, it is very confusing for human or machine to determine the originality of the image. Therefore, H 6 F is one of the good techniques to solve this issue. It is important to improve the image quality for visualization and analysis by eliminating the bad factors to recover the useful information from the degraded image as highlighted in [22], [23].

IV. CONCLUSION
This research has shown that H 6 F is a better filtering technique in removing Salt and Pepper noise, Speckle noise, Poisson noise and multi-type of noise when compared to other filtering techniques. This technique also works well with Gaussing noise for the density of 0.02 and 0.04. After conducting this H 6 F in lead frame images, the results have shown that it has the lowest MSE values for almost all noises tested, which mean that the filter performs well in removing noises in images. The nearest ones that can challenge the performance of this filter are HMF and H 4 F. In the analysis of execution time, the results have also shown that H 6 F had slightly lower and acceptable execution time which indicates that the algorithm of H 6 F can be considered as having higher quality than H 4 F's algorithm and it can save more time. Although the lowest execution time is owned by H 2 F and H 3 F respectively, the accomplishment on removing noises in lead frame images are lower in both of them when compared to H 6 F technique. Finally, with this performance achievement, it would be possible to apply H 6 F in Vision System in order to improve the performance of quality inspection.