Keyence Image Processing Useful Tips Vol.7 Pre Processing
Keyence Image Processing Useful Tips Vol.7 Pre Processing
Vol. 7 Preprocessing
01
What is preprocessing?
To perform quality inspections or measurements using image processing, it is essential to first obtain images of a high enough quality for their respective purposes. Images simply captured by a camera are not always suitable for these purposes due to the type of light source, material of workpiece or image capturing environment, which may result in an inconsistency in inspection results. To avoid this problem, the captured images are sometimes processed (converted) using image filters in accordance with the intended use of images. This processing procedure is called image preprocessing. Image preprocessing can enhance the clarity of captured images, make the elements required for applications (shapes, colors, etc.) more distinct or eliminate undesirable components (noise). When preprocessing with filters, materials such as image processing devices and PC photo retouch software are used. There
Example of image preprocessing
Filters eliminate noise to provide a clear image.
are many different types of filters, and it is important to understand their characteristics to select the optimum filter for the respective applications.
02
03
Filter coefficients
The typical filters used for preprocessing consist of filter coefficients of 3 x 3 9 x 9 16 x 16 etc. With the 3 x 3 type, which is the , , , most commonly used, the image data for 3 horizontal and vertical pixels are referenced, and the filter is applied to the pixel in the center. For example, if an image is composed of 320 horizontal pixels and 240 vertical pixels, the image is filtered 76,800 times (320 x 240).
Example of filter coefficient
Filter coefficient used for averaging of an image 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9
2 2 2
3 3 3
Pixel values
Operator
1 3 1
3 4 2
2 2 0
1 9
1 9 1 9 1 9
1 9 1 9 1 9
1 9 1 9
1 1 1 9 1 + 9 3 + 9 2 1 1 1 + 9 3 + 9 4 + 9 2 1 1 1 + 9 1 + 9 2 + 9 0 = 2
Multiply pixel values by up the obtained values.
Replace a pixel value for each pixel with an average of pixel values of surrounding pixels.
1 and add 9
04
Typical filters
The following section introduces major filters typically used for image preprocessing. In actual applications, the combined use of multiple filters to obtain images which meet application needs has become a mainstream method.
Expansion filter
This filter eliminates noise components (dirt) which are undesirable for image processing. It replaces the pixel value of the center pixel in the 3 3 area with that of the highest value among nine pixels. When an expansion filter is applied to a monochrome image, it will make all nine pixels white if any one of pixels surrounding the center pixel in the 3 x 3 area is white.
Shrink filter
A shrink filter is also effective to eliminate noise components. In contrast to the expansion filter, the shrink filter replaces the pixel value of the center pixel in the 3 3 area with that of the lowest value among nine pixels. When the shrink filter is applied to a monochrome image, it will make all nine pixels black if any one of pixels surrounding the center pixel in the 3 x 3 area is black.
2 3 0 5 5 1 9 3 2 2 5 0 1 9 3 2
Expansion
Replace a pixel value of the center pixel with a maximum value of 9.
2 3 0
5 9 1
9 3 2
Shrink
Replace a pixel value of the center pixel with a minimum value of 0.
3 0
Original image
Averaging filter
The filter improves image quality by smoothing (softening) shading on them. It averages pixel values of all nine pixels including the one in the center. The impact of noise components can be also reduced by softening images. The filter also helps position measurements such as the edge detection of workpieces or pattern search stable. To provide more natural smoothing, a weighted average filter can be used.
1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9 1 9
Original image
Averaging
Median filter
The filter sorts pixel values of nine pixels and then assigns their median to the center pixel as its pixel value. Unlike the averaging filter, it can reduce noise components without blurring images. The filter is effective especially for removing noise which is caused by pixels of very different color and intensity from those in their area.
Original image
Median
05
Other preprocessing
Color extraction
It is processing to extract specified color elements from a captured color image. The color video signals are converted into R (Red), G (Green) and B (Blue) digital data. The color extraction is performed using these data. This processing binary-converts each pixel into an extracted pixel or an unextracted one. For this reason, the process not only ensures a stable extraction even for dark colors but also diminishes the amount of color information data to be processed, eventually allowing high-speed post-processing.
Gray-scale processing
The gray-scale processing, which is also known as shade-scale processing, is used to obtain the shade-scale information for an image captured with a camera. This processing divides the shade gradation of pixel into 8 bits (= 256 levels) and utilizes all of these 256-level shade data. Therefore, this processing significantly increases the accuracy in the detection of workpieces. It is very useful in the applications like the detection of workpieces which are difficult to detect with monochromatic binary processing.
1-888-KEYENCE
1 - 8 8 8 - 5 3 9 - 3 6 2 3
T O C O N TA C T Y O U R L O C A L O F F I C E
www.keyence.com
SAFETY INFORMATION
Please read the instruction manual carefully in order to safely operate any KEYENCE product.
KEYENCE CORPORATION OF AMERICA Corporate Office 669 River Drive, Suite 403, Elmwood Park, NJ 07407 PHONE: 201-930-0100 FAX: 201-930-0099 E-mail: [email protected] Sales & Marketing Head Office 1100 North Arlington Heights Road, Suite 350, Itasca, IL 60143 PHONE: 888-539-3623 FAX: 630-285-1316
Regional offices AL Birmingham CA N.California CA Los Angeles CO FL GA IL Denver Tampa Atlanta Chicago IN KS KY MA Indianapolis Kansas City Louisville Boston MI MI MN MO Detroit Grand Rapids Minneapolis St. Louis NJ NY NC NC Elmwood Park Rochester Charlotte Raleigh OH OH OR PA Cincinnati Cleveland Portland Philadelphia SC TN TN TX Greenville Knoxville Nashville Austin TX VA WA WI Dallas Richmond Seattle Milwaukee
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima, Higashi-Yodogawa-ku, Osaka, 533-8555, Japan PHONE: +81-6-6379-2211
KA1-1091
The information in this publication is based on KEYENCEs internal research/evaluation at the time of release and is subject to change without notice. Copyright (c) 2011 KEYENCE CORPORATION. All rights reserved. CVLensTip7-KA-EN0124-E 1012-1 E 611623 Printed in Japan
* 6 1 1 6 2 3 *