Material defect detection method for keyboard and keycap production
By adaptively adjusting the fusion weights of pixels and using the Retinex algorithm for enhancement processing, the problem of low accuracy in keyboard and keycap detection is solved, achieving more efficient material defect detection.
Patent Information
- Application Number
- CN202511553877.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-10-29
AI Technical Summary
In existing technologies, the detection of material defects in keyboards and keycaps suffers from low accuracy. This is mainly because the traditional multi-scale Retinex decomposition algorithm cannot adaptively adjust the fusion weight of pixels when the illumination is normalized and enhanced, resulting in the blurring of color difference defect areas or the preservation of interference areas, which affects the detection effect.
By obtaining the adaptive weights of each pixel in the keyboard and keycap images, the Retinex algorithm is used for decomposition and enhancement processing. Combining the defect degree, color features, and texture features of the grayscale image, adaptive small-scale and large-scale weights are obtained and weighted fusion is performed to improve detection accuracy.
It enhances the display of detailed features in color difference defect areas in images, smooths uneven lighting areas, and improves the accuracy of material defect detection in keyboard and keycap production.
Smart Images

Figure CN121033031A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision, and in particular to a keyboard and keycap production material defect detection method. BACKGROUND
[0002] In the production process of keyboards and keycaps, batch differences of plastic raw materials (such as inconsistent color master batch ratio of ABS / PBT), uneven plastic dyeing, and ink distribution differences, etc. will all cause color difference defects in keyboards and keycaps. Color difference defects may cause the entire batch of keycaps to be scrapped (such as custom keycaps for high-end mechanical keyboards), directly resulting in material cost and labor loss. Due to weak features and easy influence by light, traditional manual identification is low in efficiency and high in error rate, which causes substandard products to flow into the market and reduces user satisfaction. Therefore, it is particularly important to improve the efficiency and accuracy of keyboard and keycap production material defect detection.
[0003] Since keyboards and keycaps are non-planar structures and have good reflectivity, the prior art usually uses a multi-scale Retinex decomposition algorithm to perform illumination normalization enhancement on keyboard and keycap images, and then uses an image processing algorithm to complete material defect detection of keyboard and keycap production. However, in the traditional multi-scale Retinex decomposition algorithm, the fusion weight of different scale images is fixed when the image is subjected to illumination normalization enhancement. If the same fusion weight is used for the interference areas such as reflection, shadow, etc. and the color difference defect areas in the keyboard and keycap image, the color difference defect areas will be blurred or the interference areas such as reflection, shadow, etc. will be retained, resulting in loss of details in the image defect area and extremely low elimination effect of the interference area after processing, which affects the accuracy of material defect detection of keyboard and keycap production.
[0004] Therefore, how to obtain the adaptive weight of the pixel points in the keyboard and keycap image and improve the accuracy of material defect detection of keyboard and keycap production has become a problem to be solved. SUMMARY
[0005] Therefore, the embodiments of the present application provide a keyboard and keycap production material defect detection method to solve the problem of how to obtain the adaptive weight of the pixel points in the keyboard and keycap image and improve the accuracy of material defect detection of keyboard and keycap production.
[0006] In the embodiments of the present application, a keyboard and keycap production material defect detection method is provided, which includes the following steps: An initial image and a gray image of a keyboard and keycap to be detected are obtained; According to the gray difference of the pixel points in the gray image, the defect degree of each pixel point in the gray image is obtained, and at least one suspected defect area in the gray image is obtained according to the defect degree of each pixel point in the gray image. According to the color feature of the pixel point in the corresponding area in the initial image, and the distribution feature and the texture feature of the pixel point in the any suspected defect area, a defect coefficient of each pixel point in the any suspected defect area is obtained, and a defect coefficient of each pixel point in a non-suspected defect area of the gray-scale image is set to 0. A defect coefficient of each pixel point in the gray-scale image is obtained, and an adaptive small-scale weight and an adaptive large-scale weight of each pixel point are obtained according to the defect coefficient of each pixel point in the gray-scale image. The gray-scale image is decomposed and enhanced by using a Retinex algorithm to obtain a large-scale enhanced image and a small-scale enhanced image, the adaptive large-scale weight and the adaptive small-scale weight of each pixel point are respectively taken as a fusion weight of each pixel point in the large-scale enhanced image and the small-scale enhanced image, the large-scale enhanced image and the small-scale enhanced image are weighted and fused to obtain an enhanced image, which is used for material defect detection of the keyboard and the keycap.
[0007] Preferably, the defect degree of each pixel point in the gray-scale image is obtained according to the gray-scale difference of the pixel point in the gray-scale image, including: A gray-scale histogram of the gray-scale image is obtained, the horizontal axis of the gray-scale histogram is a gray level, and the vertical axis is a pixel number corresponding to the gray level, the maximum gray level and the minimum gray level in the gray-scale histogram are obtained; For any pixel point in the gray-scale image, a difference value between the maximum gray level and the gray level of the any pixel point is obtained to obtain a first gray level difference value, and an inverse of an addition result of the first gray level difference value and a preset constant is obtained to obtain a first feature value; A difference value between the gray level of the any pixel point and the minimum gray level is obtained to obtain a second gray level difference value, and an inverse of an addition result of the second gray level difference value and a preset constant is obtained to obtain a second feature value; A product of the first feature value and the second feature value is obtained to obtain a defect feature value of the any pixel point; An inverse of the pixel number corresponding to the gray level of the any pixel point is obtained, and a product of the defect feature value of the any pixel point and the inverse is obtained to obtain the defect degree of the any pixel point.
[0008] Preferably, the at least one suspected defect area in the gray-scale image is obtained according to the defect degree of each pixel point in the gray-scale image, including: The coordinates of each pixel point in the gray image and the defect degree are combined to form a feature vector, the pixel points in the gray image are clustered according to the feature vector of each pixel point, at least one cluster is obtained, the mean value of the defect degree of the pixel points in each cluster is obtained, the cluster with a mean value of the defect degree greater than or equal to a preset defect degree threshold is recorded as a target cluster, and at least one suspected defect region is obtained according to the pixel points corresponding to each target cluster.
[0009] Preferably, the defect coefficient of each pixel point in the any suspected defect region is obtained according to the color feature of the pixel point of the corresponding region in the initial image and the distribution feature and the texture feature of the pixel point of the any suspected defect region, comprising: The first defect coefficient of each pixel point in the any suspected defect region is obtained according to the color feature of the pixel point of the corresponding region in the initial image and the gray distribution feature of the pixel point of the any suspected defect region. The second defect coefficient of each pixel point in the any suspected defect region is obtained according to the distribution feature and the texture feature of the pixel point in the any suspected defect region. For any pixel point in the any suspected defect region, the defect coefficient of the any pixel point is obtained according to the mean value between the first defect coefficient and the second defect coefficient of the any pixel point.
[0010] Preferably, the first defect coefficient of each pixel point in the any suspected defect region is obtained according to the color feature of the pixel point of the corresponding region in the initial image and the gray distribution feature of the pixel point of the any suspected defect region, comprising: The pixel points in each suspected defect region in the gray image are recorded as suspected defect pixel points, and the pixel points in the non-suspected defect region in the gray image are recorded as normal pixel points. For any suspected defect pixel point in the any suspected defect region, a target window of a preset size is established in the any suspected defect region with the any suspected defect pixel point as the center. In the gray image, a sliding window of a preset size is established with the any suspected defect pixel point as the center, for any direction in the four-neighbor direction of the sliding window, the sliding window is slid in the any direction until all the pixel points in the sliding window are normal pixel points, a reference window of the target window in the any direction is obtained, and if there is always at least one suspected defect pixel point in the sliding window when the sliding window is slid in the any direction, it is confirmed that there is no reference window of the target window in the any direction. An edge pixel point of the any suspected defect region is acquired, for any edge pixel point, a neighborhood window of a preset length containing neighborhood pixel points of the any edge pixel point is established in a normal direction of the any edge pixel point; All reference windows of the target window are acquired, a neighborhood window of each edge pixel point of the any suspected defect region is acquired, a first defect coefficient of the any suspected defect pixel point is acquired according to color difference between the target window and each reference window thereof and gray scale distribution characteristics of pixel points in the neighborhood window of each edge pixel point.
[0011] Preferably, the first defect coefficient of the any suspected defect pixel point is acquired according to the color difference between the target window and each reference window thereof and the gray scale distribution characteristics of the pixel points in the neighborhood window of each edge pixel point, comprising: Intensities of each pixel point in the initial image in RGB three color channels are recorded as three channel values, a two-dimensional rectangular coordinate system is established with lower left corners of the initial image and the gray scale image as origins, a horizontal direction as a transverse axis and a vertical direction as a longitudinal axis, and the three channel values of each pixel point in the initial image are taken as three channel values of a pixel point with the same coordinates in the gray scale image; A ratio of R channel value to G channel value of each suspected defect pixel point in the target window is acquired, and a ratio mean value is correspondingly obtained, recorded as a first color ratio of the target window, a ratio of B channel value to G channel value of each suspected defect pixel point in the target window is acquired, and a ratio mean value is correspondingly obtained, recorded as a second color ratio of the target window; For any reference window, a ratio of R channel value to G channel value of each normal pixel point in the reference window is acquired, and a ratio mean value is correspondingly obtained, recorded as a first color ratio of the any reference window, a ratio of B channel value to G channel value of each normal pixel point in the reference window is acquired, and a ratio mean value is correspondingly obtained, recorded as a second color ratio of the any reference window; A difference absolute value of the first color ratio of the target window and the first color ratio of the any reference window is acquired, and a first color difference value is obtained, a difference absolute value of the second color ratio of the target window and the second color ratio of the any reference window is acquired, and a second color difference value is obtained, and an addition result of the first color difference value and the second color difference value is acquired, and a color difference characteristic value of the target window and the any reference window is obtained; A mean value difference of gray scale values of pixel points in each neighborhood window is acquired, and a mean value difference accumulation value is correspondingly obtained, a gradient value of each pixel point in each neighborhood window is acquired, and a gradient value set is formed, and a gradient mean value of the gradient value set is acquired; Obtaining color difference characteristic values of the target window and each reference window, and obtaining color difference characteristic cumulative values correspondingly, performing normalization processing on the product of the color difference characteristic cumulative values, the mean difference cumulative values and the gradient mean, and obtaining the first defect coefficient of any suspected defect pixel point.
[0012] Preferably, the second defect coefficient of each pixel point in the any suspected defect region is obtained according to the distribution characteristics and texture characteristics of the pixel points in the any suspected defect region, and the second defect coefficient of each pixel point in the any suspected defect region comprises: In the gray-scale image, an external rectangle of the any suspected defect region is obtained, the aspect ratio of the external rectangle is calculated, the number of pixel points in the any suspected defect region is obtained, and the product of the number of pixel points and the aspect ratio is calculated to obtain a shape characteristic value of the any suspected defect region. A suspected defect region other than the any suspected defect region is recorded as a reference region, a shape characteristic value of each reference region is obtained, for any reference region, a ratio of the shape characteristic value of the any suspected defect region to the shape characteristic value of the any reference region is obtained, an absolute value of the difference between the constant 1 and the ratio is obtained to obtain a difference degree of the any suspected defect region and the any reference region, and the difference degree of the any suspected defect region and each reference region is obtained to obtain a difference degree cumulative value correspondingly. A gray-level co-occurrence matrix of the any suspected defect region is obtained to obtain an angular second moment and a contrast of the gray-level co-occurrence matrix, an addition result of the angular second moment and the contrast is obtained, and the product of the addition result and the difference degree cumulative value is obtained as the second defect coefficient of each suspected defect pixel point in the any suspected defect region.
[0013] Preferably, the adaptive small-scale weight and the adaptive large-scale weight of each pixel point are obtained according to the defect coefficients of each pixel point in the gray-scale image, and the adaptive small-scale weight and the adaptive large-scale weight of each pixel point comprise: For any pixel point in the gray-scale image, an addition result of a preset large-scale weight and a preset small-scale weight is obtained to obtain a total weight, a difference between the constant 1 and the total weight is obtained to obtain a weight coefficient, a product of the weight coefficient and the defect coefficient of the any pixel point is obtained to obtain a weight adjustment value, and an addition result of the preset small-scale weight and the weight adjustment value is obtained to obtain the adaptive small-scale weight of the any pixel point.
[0014] Preferably, the adaptive small-scale weight and the adaptive large-scale weight of each pixel point are obtained according to the defect coefficients of each pixel point in the gray-scale image, and the adaptive small-scale weight and the adaptive large-scale weight of each pixel point further comprise: A difference between the constant 1 and the adaptive small-scale weight of the any pixel point is obtained to obtain the adaptive large-scale weight of the any pixel point.
[0015] Preferably, the large-scale enhanced image and the small-scale enhanced image are weighted and fused to obtain an enhanced image, comprising: For any pixel point in the gray image, a two-dimensional rectangular coordinate system is established with the lower left corner of the large-scale enhanced image and the small-scale enhanced image as the origin, the horizontal direction as the transverse axis and the vertical direction as the longitudinal axis, a pixel point in the large-scale enhanced image with the same coordinate as the any pixel point is recorded as a large-scale pixel point, and a pixel point in the small-scale enhanced image with the same coordinate as the any pixel point is recorded as a small-scale pixel point; The large-scale weight of the any pixel point is taken as a weight coefficient of the gray value of the large-scale pixel point, the small-scale weight of the any pixel point is taken as a weight coefficient of the gray value of the small-scale pixel point, the gray value of the large-scale pixel point and the gray value of the small-scale pixel point are weighted and summed to obtain an enhanced gray value of the any pixel point; The enhanced gray value of each pixel point in the gray image is obtained to form an enhanced image.
[0016] Compared with the prior art, the embodiment of the present application has the beneficial effects that: The application obtains an initial image and a gray image of a keyboard and a keycap to be detected; obtains the defect degree of each pixel point in the gray image according to the gray difference of the pixel points in the gray image; obtains at least one suspected defect area in the gray image according to the defect degree of each pixel point in the gray image; for any suspected defect area, obtains the defect coefficient of each pixel point in the any suspected defect area according to the color feature of the pixel points in the corresponding area in the initial image and the distribution feature and the texture feature of the pixel points in the any suspected defect area, and sets the defect coefficient of each pixel point in the non-suspected defect area of the gray image as 0; obtains the defect coefficient of each pixel point in the gray image, and obtains the adaptive small-scale weight and the adaptive large-scale weight of each pixel point according to the defect coefficient of each pixel point in the gray image; decomposes and enhances the gray image by using the Retinex algorithm to obtain a large-scale enhanced image and a small-scale enhanced image, takes the adaptive large-scale weight and the adaptive small-scale weight of each pixel point as the fusion weight of each pixel point in the large-scale enhanced image and the small-scale enhanced image respectively, and performs weighted fusion on the large-scale enhanced image and the small-scale enhanced image to obtain an enhanced image, which is used for material defect detection of the keyboard and the keycap to be detected. Wherein, the adaptive small-scale weight and the adaptive large-scale weight of each pixel point are obtained according to the defect coefficient of each pixel point in the gray image, and the adaptive large-scale weight and the adaptive small-scale weight of each pixel point are taken as the fusion weight of each pixel point in the large-scale enhanced image and the small-scale enhanced image respectively, and the weighted fusion is performed on the large-scale enhanced image and the small-scale enhanced image to obtain the enhanced image, which increases the detail feature of the color difference defect area in the image, smooths the uneven light area in the image, and improves the accuracy of the material defect detection of the keyboard and the keycap production. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative labor.
[0018] Figure 1 is a method flow chart of a keyboard and keycap production material defect detection method provided by the first embodiment of the present application; Figure 2 is an image of the keyboard and keycap collected by the first embodiment of the present application. DETAILED DESCRIPTION
[0019] Embodiments of this disclosure are described in detail below, with examples of these embodiments illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting it.
[0020] It should be noted that the terms "first," "second," etc., used in this disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure.
[0021] To illustrate the technical solution of the present invention, specific embodiments are described below.
[0022] See Figure 1 This is a flowchart of a method for detecting material defects in keyboard and keycap production, provided in Embodiment 1 of the present invention. Figure 1 As shown, the method may include: Step S101: Obtain the initial image and grayscale image of the keyboard and keycaps to be detected.
[0023] During the keyboard and keycap production process, batch variations in plastic raw materials (such as inconsistent masterbatch ratios in ABS / PBT) or uneven plastic dyeing and ink distribution can lead to color difference defects in keyboards and keycaps. These defects may result in the scrapping of an entire batch of keycaps (such as custom keycaps for high-end mechanical keyboards), directly resulting in losses in material costs and labor time. Because keyboards and keycaps are non-planar structures and their materials have high reflectivity, current technologies typically use multi-scale Retinex decomposition to perform illumination normalization enhancement on keyboard and keycap images, and then use image processing algorithms to detect material defects in keyboard and keycap production.
[0024] In this embodiment, after the keyboard and keycaps are manufactured, the finished product (i.e., the keyboard and keycaps assembled together) is placed on a conveyor belt. An image acquisition device, consisting of a high-definition camera and a light source, is fixed at a position on the conveyor belt. When the product passes by this device, it pauses for 0.2 seconds to capture an image of the keyboard and keycaps. Figure 2As shown, no limitations are imposed here, and settings can be made according to the specific implementation scenario. Since the detection method for each keyboard and keycap to be detected is the same, this embodiment takes one keyboard and keycap to be detected as an example. Images of the keyboard and keycap to be detected are acquired, and the images are denoised using a non-local means denoising method. Then, the keyboard and keycap regions in the image are extracted using a semantic segmentation method to obtain the initial image of the keyboard and keycap to be detected. The initial image is an RGB image. The initial image is then converted to grayscale to obtain the grayscale image of the keyboard and keycap to be detected, which is used for material defect detection of the keyboard and keycap to be detected. Among them, non-local means denoising, semantic segmentation, and grayscale processing are existing technologies and will not be described in detail here.
[0025] Because the traditional multi-scale Retinex decomposition algorithm uses fixed fusion weights for images at different scales when performing illumination normalization enhancement, if interference areas such as reflections and shadows in keyboard and keycap images are given the same fusion weights as color difference defect areas, the color difference defect areas will be blurred or interference areas such as reflections and shadows will be preserved. This results in loss of detail in the image defect areas and extremely low elimination effect of interference areas after processing, affecting the accuracy of material defect detection in keyboard and keycap production.
[0026] Therefore, this embodiment first obtains the suspected defect area, then obtains the defect coefficient of each pixel in the grayscale image, and uses the defect coefficient of each pixel in the grayscale image to obtain the adaptive small-scale weight and adaptive large-scale weight of each pixel. Finally, based on the adaptive small-scale weight and adaptive large-scale weight of each pixel, the Retinex algorithm is used to obtain the enhanced image, thereby improving the accuracy of material defect detection in keyboard and keycap production.
[0027] Step S102: Based on the grayscale difference of pixels in the grayscale image, obtain the defect degree of each pixel in the grayscale image, and based on the defect degree of each pixel in the grayscale image, obtain at least one suspected defect area in the grayscale image.
[0028] First, identify potential defect areas. Since the main causes of color difference defects in keyboards and keycaps are batch differences in plastic raw materials (such as inconsistent masterbatch ratios in ABS / PBT) or uneven plastic dyeing and ink distribution, color difference defect areas appear as excessively bright or dark areas in grayscale images, distinct from normal areas. Furthermore, color difference defects have a relatively low probability of occurrence and constitute a small proportion of the entire keyboard and keycap area. Therefore, based on the grayscale differences of pixels in the grayscale image, the degree of defect for each pixel can be obtained. Then, based on the degree of defect for each pixel in the grayscale image, potential defect areas can be identified within the grayscale image.
[0029] The method for obtaining the degree of defect of each pixel in a grayscale image based on the grayscale difference of pixels in the grayscale image is as follows: Obtain the grayscale histogram of the grayscale image, where the horizontal axis of the grayscale histogram represents the grayscale level and the vertical axis represents the number of pixels corresponding to each grayscale level. Obtain the maximum and minimum grayscale levels in the grayscale histogram. For any pixel in the grayscale image, the difference between the maximum grayscale level and the grayscale level of any pixel is obtained to obtain a first grayscale level difference. The reciprocal of the sum of the first grayscale level difference and a preset constant is obtained to obtain a first feature value. The difference between the gray level of any pixel and the minimum gray level is obtained to obtain the second gray level difference. The reciprocal of the sum of the second gray level difference and a preset constant is obtained to obtain the second feature value. The defect feature value of any pixel is obtained by multiplying the first feature value and the second feature value. Obtain the reciprocal of the number of pixels corresponding to the gray level of any pixel, and obtain the defect degree of any pixel by multiplying the defect feature value of any pixel with the reciprocal.
[0030] In one embodiment, taking the i-th pixel in a grayscale image as an example, the formula for calculating the defect level of the i-th pixel is: in, The defect level of the i-th pixel; Maximum gray level; The minimum gray level; Let i be the gray level of the i-th pixel; is the number of pixels corresponding to the gray level of the i-th pixel; c is a preset constant. In this embodiment, c=0.01 is set to ensure that the fraction is meaningful. There is no restriction here, and it can be set according to the specific implementation scenario.
[0031] It should be noted that, The first feature value of the i-th pixel is the defect feature value. The closer the gray level of the i-th pixel is to the maximum or minimum gray level, the more likely the i-th pixel is to be either too bright or too dark. Or the second feature value of the i-th pixel The larger it is, the more... The larger the value, the more closely the i-th pixel matches the characteristics of a color difference defect region in a grayscale image. The larger it is; The smaller the value, the greater the probability that the i-th pixel belongs to one of the minority pixels in the grayscale image; that is, the greater the probability that the grayscale value of the i-th pixel is brighter or darker than the overall image. The larger it is.
[0032] Furthermore, the coordinates and defect severity of each pixel in the grayscale image are used to form a feature vector. Based on the feature vector of each pixel, mean-shift clustering is performed on the pixels in the grayscale image to obtain at least one cluster. The mean defect severity of the pixels in each cluster is obtained. The larger the mean defect severity of the pixels in a cluster, the more likely the pixels in the cluster are to be pixels in the defect region. Therefore, clusters with a mean defect severity greater than or equal to a preset defect severity threshold are recorded as target clusters. In this embodiment, the preset defect severity threshold is set to 0.7, but this is not limited and can be set according to the specific implementation scenario. All pixels in a target cluster form an initial region. For any initial region, the circumscribed ellipse of the initial region is obtained. In any initial region, the pixel with the shortest distance to the circumscribed ellipse in each direction is obtained as an edge pixel. Connecting all edge pixels yields the suspected defect region corresponding to any initial region. Similarly, the suspected defect region corresponding to each target cluster is obtained. Mean-shift clustering is an existing technology and will not be elaborated here.
[0033] At this point, the suspected defect areas in the grayscale image have been obtained.
[0034] Step S103: For any suspected defect area, based on the color features of the corresponding pixel in the initial image, as well as the distribution and texture features of the pixel in the suspected defect area, obtain the defect coefficient of each pixel in the suspected defect area, and set the defect coefficient of each pixel in the non-suspected defect area of the grayscale image to 0.
[0035] Because keyboards and keycaps are three-dimensional, lighting cannot cover every area, resulting in shadows. This creates shadowed areas when capturing images. Additionally, the reflective materials used in the keyboard and keycap production create highlight areas (i.e., reflective areas) in the captured images. Since both shadowed and highlighted areas exhibit localized brighter or darker grayscale values, meaning their grayscale levels deviate from the normal range, these are considered normal phenomena. Therefore, it's necessary to differentiate between suspected defects and minimize the impact of interfering areas (shadowed and highlighted areas) on the defective area.
[0036] Since the shadow areas are caused by insufficient lighting and are not defective areas, their color ratios are consistent with the surrounding normal areas, meaning their R / G and B / G ratios are highly consistent. In contrast, color difference defects occur when the color deviates from the normal area, resulting in lower consistency between their color ratios and the normal area. Furthermore, shadow areas are created by the edges of the keycaps, giving them clear boundaries. Color difference defects, due to poor material uniformity and their proximity to normal materials, have a blurred boundary with the normal area. Highlights are formed by reflections of light from the keycap material. Since keycaps are mostly uniform in shape, highlight areas have relatively consistent shapes. Defective areas, due to their random size and location, have lower shape consistency. Additionally, highlights appear overexposed in the image, resulting in blurred textures. Color difference defect areas, because they share the same processing technology as normal areas but with color issues, exhibit local textures consistent with normal areas, meaning their local textures are clear and regular.
[0037] Therefore, for any suspected defect area, the defect coefficient of each pixel in any suspected defect area can be obtained based on the color features of the corresponding pixels in the initial image, as well as the distribution and texture features of the pixels in any suspected defect area, so as to determine the possibility that any suspected defect area is a color difference defect area.
[0038] The method for obtaining the defect coefficient of each pixel in any suspected defect region based on the color features of the corresponding region in the initial image, and the distribution and texture features of the pixels in any suspected defect region, is as follows: (1) Based on the color features of the corresponding region of the initial image and the grayscale distribution features of the pixels in any suspected defect region, obtain the first defect coefficient of each pixel in any suspected defect region.
[0039] Specifically, pixels in each suspected defect area of the grayscale image are recorded as suspected defect pixels, and pixels in non-suspected defect areas of the grayscale image are recorded as normal pixels. For any suspected defect pixel in any suspected defect area, a target window of a preset size of 5×5 is established with the suspected defect pixel as the center in any suspected defect area (if the number of suspected defect pixels is insufficient to establish a 5×5 target window with the suspected defect pixel as the center, then the suspected defect pixels are arranged into a target window within the 5×5 range of the suspected defect pixel). There is no limitation here, and it can be set according to the specific implementation scenario. In the grayscale image, a sliding window of a preset size of 5×5 is established with any suspected defective pixel as the center. This is not limited and can be set according to the specific implementation scenario. For any of the four neighboring directions of the sliding window, the sliding window is slid in any direction until all the pixels in the sliding window are normal pixels. A reference window for the target window in any direction is obtained. If at least one suspected defective pixel always exists in the sliding window while it is sliding in any direction, it is confirmed that the target window does not have a reference window in any direction. Obtain the edge pixels of any suspected defect region. For any edge pixel, establish a neighborhood window with a preset length of 5 containing the neighboring pixels of the edge pixel in the normal direction of the edge pixel. There is no limit here, and it can be set according to the specific implementation scenario. The intensity value of each pixel in the initial image in the three color channels of RGB is recorded as the three-channel value. A two-dimensional rectangular coordinate system is established with the lower left corner of the initial image and the grayscale image as the origin, the horizontal direction as the horizontal axis and the vertical direction as the vertical axis. The three-channel value of each pixel in the initial image is used as the three-channel value of the pixel with the same coordinates in the grayscale image. The ratio of the R channel value to the G channel value of each suspected defective pixel in the target window is obtained, and the average ratio is recorded as the first color ratio of the target window. The ratio of the B channel value to the G channel value of each suspected defective pixel in the target window is obtained, and the average ratio is recorded as the second color ratio of the target window. Obtain all reference windows of the target window. For any reference window, obtain the ratio of the R channel value to the G channel value of each normal pixel in the reference window, and obtain the average ratio, which is recorded as the first color ratio of the reference window. Obtain the ratio of the B channel value to the G channel value of each normal pixel in the reference window, and obtain the average ratio, which is recorded as the second color ratio of the reference window. Obtain the absolute value of the difference between the first color ratio of the target window and the first color ratio of any reference window to obtain the first color difference value; obtain the absolute value of the difference between the second color ratio of the target window and the second color ratio of any reference window to obtain the second color difference value; obtain the sum of the first color difference value and the second color difference value to obtain the color difference feature value between the target window and the any reference window. Obtain the neighborhood window of each edge pixel in any suspected defect region, obtain the mean difference of the gray values of the pixels in each neighborhood window, obtain the cumulative value of the mean difference, obtain the gradient value of each pixel in each neighborhood window, form a gradient value set, and obtain the gradient mean of the gradient value set. Obtain the color difference feature value between the target window and each reference window, and obtain the corresponding cumulative value of color difference feature. Then, normalize the product of the cumulative value of color difference feature, the cumulative value of mean difference, and the mean gradient to obtain the first defect coefficient of any suspected defective pixel.
[0040] In one embodiment, taking the d-th suspected defect pixel in any suspected defect region as an example, the formula for calculating the first defect coefficient of the d-th suspected defect pixel is as follows: in, is the first defect coefficient of the d-th suspected defective pixel; The R channel value of the j-th pixel in the target window; The G channel value of the j-th pixel in the target window; The number of pixels in the target window; This represents the R channel value of the m-th pixel in the k-th reference window. This represents the G channel value of the m-th pixel in the k-th reference window; This refers to the number of pixels in the reference window. The number of reference windows; The value of the B channel for the j-th pixel in the target window; is the B channel value of the m-th pixel in the k-th reference window; D is the accumulated mean difference value. The gradient mean; It is the absolute value symbol; This is the normalization function.
[0041] It should be noted that, The first color ratio of the target window. Let be the first color ratio of the k-th reference window of the target window. The first color difference, The larger the value, the greater the difference in color ratio between the target window and its k-th reference window. In other words, the greater the difference in color ratio between the target window and its surrounding normal area, the more likely the target window is to belong to a color difference defect area. The larger it is; The second color ratio for the target window. The second color ratio of the k-th reference window of the target window. The difference between the second and third colors. The larger the value, the greater the difference in the second color ratio between the target window and its k-th reference window. In other words, the greater the difference in color ratio between the target window and its surrounding normal area, the more likely the target window is to belong to a color difference defect area. The larger the value of D, the higher the degree of edge blurring in the suspected defect region where the d-th suspected defect pixel is located, and the greater the likelihood that it belongs to a color difference defect region. The larger it is; The larger the value, the worse the edge grayscale consistency and edge sharpness of the suspected defect region where the d-th suspected defect pixel is located, and the more it matches the blurred edge characteristics of a color difference defect region. The larger it is.
[0042] (2) Based on the distribution characteristics and texture characteristics of the pixels in any suspected defect region, obtain the second defect coefficient of each pixel in any suspected defect region.
[0043] Specifically, in the grayscale image, the bounding rectangle of any suspected defect region is obtained, the aspect ratio of the bounding rectangle is calculated, the number of pixels in any suspected defect region is obtained, and the product between the number of pixels and the aspect ratio is calculated to obtain the shape feature value of any suspected defect region. The suspected defect areas other than any of the suspected defect areas are recorded as reference areas. The shape feature value of each reference area is obtained. For any reference area, the ratio of the shape feature value of any suspected defect area to the shape feature value of any reference area is obtained. The absolute value of the difference between the constant 1 and the ratio is obtained. The degree of difference between any suspected defect area and any reference area is obtained. The degree of difference between any suspected defect area and each reference area is obtained. The cumulative value of the degree of difference is obtained accordingly. Obtain the gray-level co-occurrence matrix of any suspected defect region, obtain the angular second moment and contrast of the gray-level co-occurrence matrix, obtain the sum of the angular second moment and contrast of the gray-level co-occurrence matrix, obtain the product of the sum and the cumulative difference value, and use it as the second defect coefficient of each suspected defect pixel in any suspected defect region.
[0044] In one embodiment, taking the d-th suspected defect pixel in any suspected defect region as an example, the formula for calculating the second defect coefficient of the d-th suspected defect pixel is as follows: in, The second defect coefficient is the d-th suspected defective pixel. The number of pixels in any suspected defect area; Let be the length of the bounding rectangle of any suspected defect region; The width of the bounding rectangle of any suspected defect area; Let be the number of pixels in the a-th reference region; Let be the length of the bounding rectangle of the a-th reference region; Let be the width of the bounding rectangle of the a-th reference region; The number of reference areas; Let be the second angular moment of the gray-level co-occurrence matrix of any suspected defect region; The contrast of the gray-level co-occurrence matrix for any suspected defect region; It is the absolute value symbol; This is the normalization function.
[0045] It should be noted that, For any suspected defect region, the shape feature value is... Let a be the shape feature value of the a-th reference region. The closer the value is to 1, the more similar the area and shape of any suspected defect area are to the a-th reference area, and the more consistent the shape of the highlight area is. In other words, it represents the degree of difference between any suspected defect area and the a-th reference area. The smaller, The smaller it is; Reflecting the texture clarity of any suspected defect area, clear textures typically exhibit regular local patterns, meaning the texture is uniform and regular. The larger the value, the more it matches the characteristic of clear texture in areas with color difference defects. The larger it is; Let be the contrast of the gray-level co-occurrence matrix of any suspected defect region. The larger the value, the clearer the texture of any suspected defect area, and the less it conforms to the characteristic of blurred texture in highlight areas. The larger it is.
[0046] (3) For any pixel in any suspected defect region, the defect coefficient of any pixel is obtained based on the average of the first defect coefficient and the second defect coefficient of the pixel.
[0047] In one embodiment, taking the d-th pixel in any suspected defect region as an example, the formula for calculating the defect coefficient of the d-th pixel is as follows: in, Let d be the defect coefficient of the d-th pixel; Let be the first defect coefficient of the d-th pixel; is the second defect coefficient of the d-th pixel.
[0048] It should be noted that, The larger the value, the less the d-th pixel matches the characteristics of pixels in the shadow region, and the more it matches the characteristics of pixels in the color difference defect region. The larger it is; The larger the value, the less the d-th pixel matches the characteristics of pixels in the highlight region, and the more it matches the characteristics of pixels in the chromatic aberration defect region. The larger it is.
[0049] Following the method described above for obtaining the defect coefficient of the d-th pixel in any suspected defect region, the defect coefficient of each pixel in each defect region of the grayscale image is obtained.
[0050] Since the pixels in the non-suspected defect area of the grayscale image are normal pixels, that is, the non-suspected defect area is a normal area, the defect coefficient of each pixel in the non-suspected defect area of the grayscale image is set to 0.
[0051] Thus, the defect coefficient of each pixel in the grayscale image is obtained.
[0052] Step S104: Obtain the defect coefficient of each pixel in the grayscale image, and obtain the adaptive small-scale weight and adaptive large-scale weight of each pixel based on the defect coefficient of each pixel in the grayscale image.
[0053] The higher the defect coefficient, the more likely the pixel belongs to a color difference defect region. In this embodiment, the Retinex algorithm is used to decompose the grayscale image into large-scale and small-scale images. Pixels with higher defect coefficients are more likely to belong to color difference defect regions, so their small-scale weights need to be increased to capture local details of the image and enhance the details of color difference defect regions.
[0054] Therefore, the adaptive small-scale weight and adaptive large-scale weight of each pixel can be obtained based on the defect coefficient of each pixel in the grayscale image. The method for obtaining the adaptive small-scale weight and adaptive large-scale weight of any pixel in the grayscale image is as follows: (1) Obtain the adaptive small-scale weight of any pixel.
[0055] Specifically, the total weight is obtained by adding the preset large-scale weight and the preset small-scale weight, the weight coefficient is obtained by obtaining the difference between the constant 1 and the total weight, the weight coefficient is obtained by multiplying the weight coefficient and the defect coefficient of any pixel, the weight adjustment value is obtained, and the adaptive small-scale weight of any pixel is obtained by adding the preset small-scale weight and the weight adjustment value.
[0056] In one embodiment, taking the i-th pixel in a grayscale image as an example, the formula for calculating the adaptive small-scale weight of the i-th pixel is: in, The adaptive small-scale weights for the i-th pixel; G is the defect coefficient of the i-th pixel; G is the preset small-scale weight; D is the preset large-scale weight; in this embodiment, the preset small-scale weight and the preset large-scale weight are set to G=D=0.2, which is not limited here and can be set according to the specific implementation scenario.
[0057] It should be noted that, The larger the value, the greater the likelihood that the i-th pixel belongs to a color difference defect region. In order to capture local details of the image and enhance the details in color difference defect regions, the smaller the scale weight of the i-th pixel needs to be increased. The larger it is; The smaller the value, the greater the probability that the i-th pixel belongs to the normal region. In order to extract global illumination information of the image, suppress local fluctuations, and smooth illumination unevenness, the smaller the small-scale weight of the i-th pixel does not need to be increased. The smaller it is.
[0058] (2) Obtain the adaptive large-scale weight of any pixel.
[0059] Specifically, the difference between the constant 1 and the adaptive small-scale weight of any pixel is obtained to get the adaptive large-scale weight of any pixel.
[0060] In one embodiment, taking the i-th pixel in a grayscale image as an example, the formula for calculating the adaptive large-scale weight of the i-th pixel is as follows: in, The adaptive small-scale weights for the i-th pixel; is the adaptive small-scale weight of the i-th pixel.
[0061] Similarly, obtain the adaptive large-scale weight and adaptive small-scale weight of each pixel in the grayscale image.
[0062] Step S105: The grayscale image is decomposed and enhanced using the Retinex algorithm to obtain a large-scale enhanced image and a small-scale enhanced image. The adaptive large-scale weight and adaptive small-scale weight of each pixel are used as the fusion weight of each pixel in the large-scale enhanced image and the small-scale enhanced image, respectively. The large-scale enhanced image and the small-scale enhanced image are weighted and fused to obtain an enhanced image, which is used to detect material defects in the keyboard and keycaps to be inspected.
[0063] In this embodiment, the Retinex algorithm is used to decompose the grayscale image into a large-scale image and a small-scale image, and the large-scale image and the small-scale image are enhanced to obtain a large-scale enhanced image and a small-scale enhanced image. The Retinex algorithm is an existing technology and will not be described in detail here. Then, for any pixel in the grayscale image, a two-dimensional rectangular coordinate system is established with the lower left corner of the large-scale enhanced image and the small-scale enhanced image as the origin, the horizontal direction as the horizontal axis and the vertical direction as the vertical axis. Pixels in the large-scale enhanced image with the same coordinates as any pixel are recorded as large-scale pixels, and pixels in the small-scale enhanced image with the same coordinates as any pixel are recorded as small-scale pixels. The large-scale weight of any pixel is used as the weight coefficient of the gray value of the large-scale pixel, and the small-scale weight of any pixel is used as the weight coefficient of the gray value of the small-scale pixel. The gray values of the large-scale pixel and the gray values of the small-scale pixel are weighted and summed to obtain the enhanced gray value of any pixel. According to the above-described method for obtaining the enhanced grayscale value of any pixel, the enhanced grayscale value of each pixel in the grayscale image is obtained to form an enhanced image.
[0064] After obtaining the enhanced image, it is input into a pre-trained keyboard and keycap material defect detection model to detect color difference defects in the keyboard and keycaps. Keyboards and keycaps that do not meet production requirements are marked to assist workers in secondary inspection. The keyboard and keycap material defect detection model is based on a convolutional neural network (CNN) or object detection model (such as YOLO, Faster R-CNN) and trained using a deep learning framework (such as TensorFlow, PyTorch). The training of the keyboard and keycap material defect detection model, as well as the detection of color difference defects in the keyboard and keycaps based on the model, are existing technologies and will not be elaborated here.
[0065] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for detecting material defects in keyboard and keycap manufacturing, characterized in that, The method for detecting material defects in keyboard and keycap production includes: Obtain the initial image and grayscale image of the keyboard and keycaps to be inspected; Based on the grayscale differences of pixels in the grayscale image, the degree of defect of each pixel in the grayscale image is obtained, and based on the degree of defect of each pixel in the grayscale image, at least one suspected defect area is obtained in the grayscale image. For any suspected defect area, based on the color features of the corresponding pixels in the initial image, as well as the distribution and texture features of the pixels in any suspected defect area, the defect coefficient of each pixel in any suspected defect area is obtained, and the defect coefficient of each pixel in the non-suspected defect area of the grayscale image is set to 0. Obtain the defect coefficient of each pixel in the grayscale image, and based on the defect coefficient of each pixel in the grayscale image, obtain the adaptive small-scale weight and adaptive large-scale weight of each pixel. The grayscale image is decomposed and enhanced using the Retinex algorithm to obtain a large-scale enhanced image and a small-scale enhanced image. The adaptive large-scale weight and adaptive small-scale weight of each pixel are used as the fusion weight of each pixel in the large-scale enhanced image and the small-scale enhanced image, respectively. The large-scale enhanced image and the small-scale enhanced image are then weighted and fused to obtain an enhanced image, which is used to detect material defects in the keyboard and keycaps to be inspected.
2. The method for detecting material defects in keyboard and keycap production according to claim 1, characterized in that, The step of obtaining the defect degree of each pixel in the grayscale image based on the grayscale difference of the pixels in the grayscale image includes: Obtain the grayscale histogram of the grayscale image, where the horizontal axis of the grayscale histogram represents the grayscale level and the vertical axis represents the number of pixels corresponding to each grayscale level. Obtain the maximum and minimum grayscale levels in the grayscale histogram. For any pixel in the grayscale image, the difference between the maximum grayscale level and the grayscale level of any pixel is obtained to obtain a first grayscale level difference. The reciprocal of the sum of the first grayscale level difference and a preset constant is obtained to obtain a first feature value. The difference between the gray level of any pixel and the minimum gray level is obtained to obtain the second gray level difference. The reciprocal of the sum of the second gray level difference and a preset constant is obtained to obtain the second feature value. The defect feature value of any pixel is obtained by multiplying the first feature value and the second feature value. Obtain the reciprocal of the number of pixels corresponding to the gray level of any pixel, and obtain the defect degree of any pixel by multiplying the defect feature value of any pixel with the reciprocal.
3. The method for detecting material defects in keyboard and keycap production according to claim 1, characterized in that, The step of obtaining at least one suspected defect region in the grayscale image based on the defect degree of each pixel in the grayscale image includes: The coordinates and defect degree of each pixel in the grayscale image are used to form a feature vector. Based on the feature vector of each pixel, the pixels in the grayscale image are clustered to obtain at least one cluster. The average defect degree of the pixels in each cluster is obtained. The clusters with the average defect degree greater than or equal to the preset defect degree threshold are recorded as target clusters. Based on the pixels corresponding to each target cluster, at least one suspected defect region is obtained.
4. The method for detecting material defects in keyboard and keycap production according to claim 1, characterized in that, The step of obtaining the defect coefficient of each pixel in any suspected defect region based on the color features of the corresponding region in the initial image, and the distribution and texture features of the pixels in any suspected defect region, includes: Based on the color features of the corresponding pixels in the initial image and the grayscale distribution features of the pixels in any suspected defect region, the first defect coefficient of each pixel in any suspected defect region is obtained. Based on the distribution characteristics and texture characteristics of pixels in any suspected defect region, obtain the second defect coefficient of each pixel in any suspected defect region; For any pixel in any suspected defect region, the defect coefficient of the pixel is obtained based on the average of the first defect coefficient and the second defect coefficient of the pixel.
5. The method for detecting material defects in keyboard and keycap production according to claim 4, characterized in that, The step of obtaining the first defect coefficient of each pixel in any suspected defect region based on the color features of the corresponding region of the initial image and the grayscale distribution features of the pixels in any suspected defect region includes: Each pixel in a suspected defect region of the grayscale image is recorded as a suspected defect pixel, and pixels in non-suspected defect regions of the grayscale image are recorded as normal pixels. For any suspected defect pixel in any suspected defect region, a target window of a preset size is established in any suspected defect region, centered on the suspected defect pixel. In the grayscale image, a sliding window of a preset size is established with any suspected defective pixel as the center. The sliding window is slid in any of the four neighboring directions of the sliding window until all pixels in the sliding window are normal pixels, thus obtaining a reference window for the target window in any direction. If at least one suspected defective pixel always exists in the sliding window while it is sliding in any direction, then it is confirmed that the target window does not have a reference window in any direction. Obtain the edge pixels of any suspected defect region, and for any edge pixel, establish a neighborhood window of a preset length containing the neighboring pixels of the edge pixel in the normal direction of the edge pixel; Obtain all reference windows of the target window, obtain the neighborhood window of each edge pixel of any suspected defect region, and obtain the first defect coefficient of any suspected defect pixel based on the color difference between the target window and each of its reference windows, and the grayscale distribution characteristics of the pixels in the neighborhood window of each edge pixel.
6. The method for detecting material defects in keyboard and keycap production according to claim 5, characterized in that, The step of obtaining the first defect coefficient of any suspected defective pixel based on the color difference between the target window and each of its reference windows, and the grayscale distribution characteristics of pixels in the neighborhood windows of each edge pixel, includes: The intensity value of each pixel in the initial image in the three color channels of RGB is recorded as the three-channel value. A two-dimensional rectangular coordinate system is established with the lower left corner of the initial image and the grayscale image as the origin, the horizontal direction as the horizontal axis and the vertical direction as the vertical axis. The three-channel value of each pixel in the initial image is used as the three-channel value of the pixel with the same coordinates in the grayscale image. The ratio of the R channel value to the G channel value of each suspected defective pixel in the target window is obtained, and the average ratio is recorded as the first color ratio of the target window. The ratio of the B channel value to the G channel value of each suspected defective pixel in the target window is obtained, and the average ratio is recorded as the second color ratio of the target window. For any reference window, the ratio of the R channel value to the G channel value of each normal pixel in the reference window is obtained, and the average ratio is recorded as the first color ratio of the reference window. The ratio of the B channel value to the G channel value of each normal pixel in the reference window is obtained, and the average ratio is recorded as the second color ratio of the reference window. Obtain the absolute value of the difference between the first color ratio of the target window and the first color ratio of any reference window to obtain the first color difference value; obtain the absolute value of the difference between the second color ratio of the target window and the second color ratio of any reference window to obtain the second color difference value; obtain the sum of the first color difference value and the second color difference value to obtain the color difference feature value between the target window and the any reference window. Obtain the mean difference of gray values of pixels in each neighborhood window, and obtain the cumulative value of the mean difference. Obtain the gradient value of each pixel in each neighborhood window, form a gradient value set, and obtain the gradient mean of the gradient value set. Obtain the color difference feature value between the target window and each reference window, and obtain the corresponding cumulative value of color difference feature. Then, normalize the product of the cumulative value of color difference feature, the cumulative value of mean difference, and the mean gradient to obtain the first defect coefficient of any suspected defective pixel.
7. The method for detecting material defects in keyboard and keycap production according to claim 5, characterized in that, The step of obtaining the second defect coefficient for each pixel in any suspected defect region based on the distribution and texture features of pixels in any suspected defect region includes: In the grayscale image, the bounding rectangle of any suspected defect region is obtained, the aspect ratio of the bounding rectangle is calculated, the number of pixels in any suspected defect region is obtained, and the product between the number of pixels and the aspect ratio is calculated to obtain the shape feature value of any suspected defect region. The suspected defect areas other than any of the suspected defect areas are recorded as reference areas. The shape feature value of each reference area is obtained. For any reference area, the ratio of the shape feature value of any suspected defect area to the shape feature value of any reference area is obtained. The absolute value of the difference between the constant 1 and the ratio is obtained. The degree of difference between any suspected defect area and any reference area is obtained. The degree of difference between any suspected defect area and each reference area is obtained. The cumulative value of the degree of difference is obtained accordingly. Obtain the gray-level co-occurrence matrix of any suspected defect region, obtain the angular second moment and contrast of the gray-level co-occurrence matrix, obtain the sum of the angular second moment and contrast of the gray-level co-occurrence matrix, obtain the product of the sum and the cumulative difference value, and use it as the second defect coefficient of each suspected defect pixel in any suspected defect region.
8. The method for detecting material defects in keyboard and keycap production according to claim 1, characterized in that, The step of obtaining the adaptive small-scale weight and adaptive large-scale weight of each pixel based on the defect coefficient of each pixel in the grayscale image includes: For any pixel in the grayscale image, the sum of the preset large-scale weight and the preset small-scale weight is obtained to get the total weight. The difference between the constant 1 and the total weight is obtained to get the weight coefficient. The product of the weight coefficient and the defect coefficient of the pixel is obtained to get the weight adjustment value. The sum of the preset small-scale weight and the weight adjustment value is obtained to get the adaptive small-scale weight of the pixel.
9. A method for detecting material defects in keyboard and keycap production according to claim 8, characterized in that, The step of obtaining the adaptive small-scale weight and adaptive large-scale weight of each pixel based on the defect coefficient of each pixel in the grayscale image further includes: The difference between the constant 1 and the adaptive small-scale weight of any pixel is obtained to obtain the adaptive large-scale weight of any pixel.
10. The method for detecting material defects in keyboard and keycap production according to claim 1, characterized in that, The weighted fusion of the large-scale enhanced image and the small-scale enhanced image to obtain the enhanced image includes: For any pixel in the grayscale image, a two-dimensional rectangular coordinate system is established with the lower left corner of the large-scale enhanced image and the small-scale enhanced image as the origin, the horizontal direction as the horizontal axis, and the vertical direction as the vertical axis. Pixels in the large-scale enhanced image with the same coordinates as any pixel are denoted as large-scale pixels, and pixels in the small-scale enhanced image with the same coordinates as any pixel are denoted as small-scale pixels. The large-scale weight of any pixel is used as the weight coefficient of the gray value of the large-scale pixel, and the small-scale weight of any pixel is used as the weight coefficient of the gray value of the small-scale pixel. The gray values of the large-scale pixel and the gray values of the small-scale pixel are weighted and summed to obtain the enhanced gray value of any pixel. The enhanced grayscale value of each pixel in the grayscale image is obtained to form an enhanced image.
Citation Information
Patent Citations
Method for processing video image of portable night vision instrument
CN103700066A
Traffic construction pavement quality monitoring method and system
CN117635611A
Image enhancement method and system for optical imaging acupoint auxiliary identification
CN119090750A
Industrial surface defect detection method, system and equipment and storage medium
CN120107175A
PCBA surface defect detection method and system based on deep learning and medium
CN120823145A