Preserving Median Filtering Algorithm in Chip Images

The types and characteristics of noise in chip images were analyzed in this paper. A new kind of details preserving adaptive median filtering algorithm with directional sub-window was introduced in which the shape and size of filtering window can be adjusted according to the noise level and the sensitivity can be set by parameter. The filter can effectively get rid of most of the impulse noise and speckles from the chip image, and improve the accuracy of processing and analyzing image.


INTRODUCTION
LED light has been developed rapidly in its production and application at home and abroad.Because it shows great advantages in energy consumption, life expectancy and stability, it tends to replace the traditional incandescent lamp and fluorescent lamp.The produced LED chips should be tested.First they are power-tested, photoelectric parameters are classified and then thousands of chips of the same class are put on a plastic platter.Defective chips are detected and sorted by their appearance.Those with appearance defects such as scratches and deface are automatically detected and sorted out using special machines.Machine vision is an usual method to detect chips by appearance, which is of accuracy, quickness and non-contact.Generally CCD cameras and appropriate light equipments are employed to get chips image, which may exist noise.To obtain stable detective effect, the noise must be erased before detection.And because of the low quality of chips, speckles may exist in the image.All these will influence the performance of image detecting system, which has higher demands on the detection algorithms.
Median filtering algorithm is a general method to erase the noise in images.The traditional method may destroy the peripheral of images and other detailed information, thus having a negative influence on successive image processing and recognition algorithm.Many scholars at home and abroad have tried to improve median filtering, such as K nearest neighbor smoothing algorithm [1], symmetric nearest neighbor smoothing algorithm [2], smoothing algorithm [3] and so on.And many scholars have improve filtering algorithm in certain fields according to the characteristics of engineering drawing and medical imaging [4][5][6].
This paper analyzes the characteristics of LED chip images and accompanied noise, and introduces a new kind of adaptive median filtering algorithm, which can improve the accuracy of visual system by effectively getting rid of the noise and speckles from the chip image on the premise of maintaining image detail.

CHARACTERISTICS OF CHIP IMAGES
Chips produced by different factories are different.To apply chip detecting equipments to different types of chips, image processing algorithm should be designed to meet the common features of chip images.For example, chip images are generally square or rectangular.The electrode is made of precipitated gold material after the wafer is etched in a specific location.The reflectivity of the chip images is high.So it is white in the image.

NOISE OF CHIP IMAGES
The noise signal in the real world is generally random, which can be described and processed by statistics.In chip detecting equipments, there are three sources of noise in chip images.
(1) Gaussian noise is generated from the inside of resistive components, which can be reduced by CCD cameral with high signal-noise ratio.
(2) Poisson noise is generated in the process of photoelectric conversion, which can be reduced by lights with high brightness.
(3) Environmental noise, which can be reduced by reasonably designed light path.
Noise can be reduced by a variety of measures to get high commanded images and stabilize successive detective algorithm.Because of un-uniform plastic material on the platter and bubbles between the chip and platter, there exist a great number of speckles in the image, which are not noise, inconsistent with statistical characteristics of noise.But the speckles are random and should be handled in the successive detective algorithm.

UNIFORM CORRECTION AND PRETREATMENT OF BR GHTNESS
In the chip detection and sorting equipments, a single white light diodes is used as light source, which is a point light whose brightness is different with changing distance and may inevitably generate uneven brightness in the image.And thus pretreatment on brightness uniform correction should be made to adjust brightness by changing pixel values.This paper collects the distribution of light source by a CCD camera and designs algorithms to correct uneven brightness in the image just as follows.
(1) To obtain the image sample, choose the part of platter without chips to take photos and get images and calculate the average.The formula is as follows.
B k (i,j) is the grayscale value of point (i,j) in the k image.
(2) If the maximum grayscale value of Image B is B Max , the correction factor of every pixel is: (3) All the correction pixels constitute a matrix R which is equal to the width and height of the input image.Uneven light source correction can be achieved by multiplying R and the corresponding element I.
When the light source and light path are not changed, the light intensity of the light source in every visual location remains stable.So R is a constant which can be calculated and restored in adjusting the equipment and can be used when the equipment works.
To increase the dynamic range of the image, this paper also makes histogram equalization of the image.Fig. ( 2) is a typical histogram of the chip platter after equalization.

ADAPTIVE MEDIAN FILTERING ALGORITHM
This paper chooses a CCD camera with high signal noise ratio.Gaussian noise in the chip image is low and there are mainly impulse noise and some speckles in the images, so the present paper uses median filtering to get rid of the noise.To keep details of the image during getting rid of noise, it introduces filtering templates and differentiates the pixel according to the consistency of the gray in the templates to keep the details.

Defects of Median Filtering Algorithm
Median filter is nonlinear, which was proposed by J.W. Jukey in 1971 [7].Its basic principle is that the gray value of one point in the digital image is replaced by the average value of the points around in the same region.If x(i,j) represents the gray value of a certain point, the two dimensional median filter with filter window S can be defined as: According to the principle of median filter, it is effective to get rid of the noise when the filter window is bigger.However, the bigger the filter window is, the greater the loss of the details in the peripheral and corner points of the image, the more the computational complexity, bringing the difficulty to handle.
The main reason to lose details of median filter image is not to distinguish the image pixel, which can be avoided by introduces sub-filter window into the traditional one [8][9][10][11][12].The range influence by noise is limited.According to the correlation of images, when the filter window arrives at a certain scale, the consistency in a certain direction will be higher.The essence of the sub-window is to build multidirectional filter window centered on pixels to be treated and choose the filter window of the present pixel by comparing the gray consistency of every one.For example, for 9 9 square window, sub-windows of 8 directions can be built, just as Fig.Then, we need to select criteria to evaluate the pixel's consistency in the sub-window, and choose one W d value of the sub-window as the value of the pixel after the filtering.

The Adaptive Median Filtering in Directional Sub-Window
Introduce threshold value h, as follows: X i is taken as the first pixel value in sub-window W d .The following defines V d as consistency evaluation function in the window: When V d = 0, we think the consistency of the grey level of pixels within the sub-window is higher.All the subwindows V d among 8 sub-windows form the final median filtering window, the shape of which is changing with the surrounding changing noise of the pixels.When V d is not zero in all sub-windows, we can find the pixels in an area seriously disturbed by noises.Therefore, we can improve its ability to remove noise by expanding the scope of median filtering window, such as, expanding it from 3 3 to 5 5, and then to 7 7, etc.
The edge and electrode in chip images is the main information for subsequent processing and analysis and need to be highly protected.When we introduce another threshold value p, and when the gray value of the pending pixel is greater than p, don't use filter processing to it in case of the loss of image information.
The above algorithm has four advantages: (1) Filtering sensitivity can be adjusted.By setting a specific value h, we can adjust the filter's sensitivity to noise.H is the threshold value to assess the consistency in subwindow.The smaller the value is, the more sensitive the filter is, and the filtering effect is better, but we may encounter the possible loss of image details.
(2) Window is adaptive.The shape and size of the window in the algorithm change with the changing situation of the interference in the pixels and the surrounding pixels, which has better filtering effect than that of a single linear window.
(3) Filtering is selective.We can set threshold value p based on grey value of the edge and electrode in chip images and deal with pixels selectively.

Fast Median Filtering Algorithm
In the median filtering algorithm, to calculate the median for a set of data requires the largest amount of calculation.In 8-bit grayscale image, the gap of gray value between two pixels is 0-255, so we can get the median quickly through binary from high-order to avoid sorting all data, and hence improve the efficiency of algorithm.The specific algorithm is as follows: (1) Set the grey value of all pixels as G 1 { X 1 , X 2 ,... Repeat steps (1) and ( 2) until the number of elements in the group where the median exists equals 1 or all elements' value is equal, and then the median of all the elements in G 1 is the element's value.
The algorithm only need to regroup elements according to any single bit that is 0 or 1 in 8-bit binary.8 times is the maximum for us to group elements to obtain the median, which can avoid sorting all elements.Especially, when there is a large number of elements, this method can significantly improve the efficiency of median calculating, which is 40% higher than median calculating through bubble sorting.

FILTERING EXPERIMENT AND ANALYSIS
Through the adoption of image acquisition device with high signal to noise ratio (SNR), in LED chip images, the pulse noise can be controlled at a low level, and the zone radius under its influence is usually within 1-2 pixels, so the size of initial filtering window can be set to 5 5.The radius of tiny bumps and concave on the plastic film is usually in 3-5 pixels, so the radius of the filtering window should be five, which can filter out most of texture noise of the filter, i.e. the maximum size of the filtering window should be 9 9.The gap of grey value in non-edge area in chip images is smaller with the threshold value of h as 32.After light uniformity correction and histogram equalization, chip electrode and edge grayscale value are all above 180, and the threshold value of p can be set as 180.

Filtering De-noising Effect Experiment
Fig. (4) shows the effect contrast between the use of traditional median filtering and adaptive median filtering for processing chip image: (4a) is the image before filtering, (4b) is the image after traditional median filtering by using square filtering window with the size of 5 5, and (4c) is the image after adaptive median filtering.
As is shown in Fig. (4), although traditional median filtering can filter out impulse noise in the image, a lot of image information is also lost.Especially, the electrode edge is blurred and some spots in the image can not be removed.Compared with traditional median filtering, the adaptive median filtering can also filter out the noise in the image, as well as retain some details in the image, such as, fine lines, edges and corners, etc. and the spots in the image also get effective filtering.The filter's filtering performance and its comprehensive performance to protect details are usually evaluated by mean square error (MSE), average error (MAE) and subjective observation.Process the image with the size of M x N by filtering, and define normalized MSE and MAE respectively as follows: In formula (7)  adopting the filtering method advocated in this paper.Apparently, two indexes are significantly lower, which proves that the adaptive median filtering algorithm preserves more information in the original image.

Algorithm Efficiency
For a typical chip image with a resolution ratio of 1280 1024, it takes 239 ms by using traditional median filtering calculation.In contrast, by using the methods we introduced, it takes 300 ms when we conduct 3 3 to 7 7 window fil-tering, and 350 ms for 3 3-9 9 window.By using more meticulous processing, the processing time is longer than that of traditional median filtering algorithm.However, in chip testing equipment, it only identifies one chip every time, and the image size to be processed is small, with a typical image size within 200 200.The filtering time is less than 15 ms, which can fully meet the requirement of the real-time nature of the visual system of the equipment.

Value Analysis of the Threshold Value h
In the algorithm discussed in this paper, h is the threshold value for consistency judgment in the sub-window.The evaluation of h is determined by experiment.As is seen in picture (5a-e), when the threshold value h = 32, filtering effect is best.When h is small (h 16), its filtering effect is similar to that by traditional median filtering algorithm.It can filter out most noise, yet a lot of information details are also lost and the electrode edge is blurred.When h is much high (h 64), spots in the image can not be removed, So the part of image details also get lost.

CONCLUSION
On the basis of traditional median filtering algorithm, this paper proposes adaptive median filtering algorithm, which set parameters sensitivity of the filter and adjust the shape and size of the window according to the influence of changing noise.It has achieved better de-noising effect and preserved image details.
Fig. (1) sees the images of four kinds of chips.In Fig. (1a) is a single-electrode chip image.The substrate of this chip is conductive, with gold-plated base as one electrode.There is only one electrode on the positive.The gold-plated base brightens the whole image.(b) and (c) are double-electrode chip images.The base of this kind of chip is not conductive, and the two electrodes are on the same side brightening two areas in the images.Influenced by cutting, the chip peripherals are also highlighted.(d) is a chip with high power.It has more than four electrodes.Because of its complicated outer structure, the image has more details.
(3).Set W d (d = 1 ~ 8) as a directional sub-window, and X i (i = 1, 2,..., N) to refer to gray value of each pixel in the original image under the function of W d .Put W d (m, n) = Median { X 1 , X 2 ,... X N }as the Wd value of the sub-window.

X( 2 )( 3 )
N }.According to the highest level of binary number (8 bit) , and divide it into two groups G 11 and G 12 .The eighth element of G 11 is 0, while the eighth element of G 12 is 1, so all elements of G 12 are greater than those of G 11 .If the number of elements in G 11 is greater than G 12 , the median exists in G 11 , vice versa.If the median exists in G 11 and the number of elements in G 11 is greater than 1, we can regroup G 11 based on the method of step (1) for 7 bit, and record them as G 111 and G 112 .All elements in G 112 are greater than those in G 111 .If the median exists in G 112 , group it.If they are equal in 7 bit, group the 6 bit.The rest can be done in the same manner.If the median exists in G 11 , and the number of ele- ments in G 111 is greater than the sum of elements in G 112 and G 12 , the median exists in G 111 , or else, it exists in G 112 .
Fig. (5) is the experimental filtering results of different values of h.