A keyboard and a keycap production material defect detection method
By obtaining the defect degree and features of grayscale images during keyboard and keycap production, and using the Retinex algorithm for adaptive weight decomposition enhancement processing, the problem of low detection accuracy in traditional methods is solved, and the efficiency and accuracy of detection are improved.
Patent Information
- Application Number
- CN202511553877.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-10-29
AI Technical Summary
In the production of keyboards and keycaps, the traditional multi-scale Retinex decomposition algorithm cannot effectively distinguish between areas of uneven lighting and color difference defects, resulting in low detection accuracy. Furthermore, traditional methods have difficulty obtaining adaptive weights for pixels, affecting the efficiency and accuracy of material defect detection.
By acquiring the defect degree and features of each pixel in the grayscale image, the Retinex algorithm is used for adaptive weight decomposition enhancement processing to obtain adaptive small-scale and large-scale weights, and then weighted fusion is performed to improve detection accuracy.
It enhances the detail features of 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 CN121033031B_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 the keyboard and keycap, the batch difference of the plastic raw material (such as the inconsistent color master batch ratio of ABS / PBT), the uneven plastic dyeing, and the ink distribution difference, etc. will all cause the color difference defect of the keyboard and keycap, which may cause the whole batch of keycaps to be scrapped (such as the customized keycaps of high-end mechanical keyboards), directly resulting in material cost and time loss. The color difference defect has weak features and is easily affected by light, so the traditional manual identification has low efficiency and high error rate, which causes the defective products to flow into the market and reduces the user satisfaction, so it is particularly important to improve the efficiency and accuracy of the keyboard and keycap production material defect detection.
[0003] Since the keyboard and keycap are non-planar structures and have good reflectivity, the existing technology usually uses a multi-scale Retinex decomposition algorithm to perform illumination normalization enhancement on the keyboard and keycap image, and then uses an image processing algorithm to complete the keyboard and keycap production material defect detection. However, in the illumination normalization enhancement of the image by the traditional multi-scale Retinex decomposition algorithm, the fusion weight of the images of different scales is fixed, and if the same fusion weight is used for the interference areas such as the reflection, shadow, etc. and the color difference defect area in the keyboard and keycap image, the color difference defect area will be blurred or the interference areas such as the reflection, shadow, etc. will be retained, so that the details of the image defect area are lost and the elimination effect of the interference areas after processing is very low, which affects the accuracy of the keyboard and keycap production material defect detection.
[0004] Therefore, how to obtain the adaptive weight of the pixel points in the keyboard and keycap image and improve the accuracy of the keyboard and keycap production material defect detection becomes 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 the keyboard and keycap production material defect detection.
[0006] In the embodiments of the present application, a keyboard and keycap production material defect detection method is provided, which includes the following steps:
[0007] An initial image and a gray image of a keyboard and keycap to be detected are obtained;
[0008] 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.
[0009] For any suspected defect area, the defect coefficient of each pixel point in the any suspected defect area is obtained according to the color feature of the pixel points in the corresponding area of the initial image and the distribution feature and the texture feature of the pixel points in the any suspected defect area, and the defect coefficient of each pixel point in the non-suspected defect area of the gray image is set to 0.
[0010] The defect coefficient of each pixel point in the gray image is obtained, and 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.
[0011] The gray image is decomposed and enhanced by using the 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 used as the fusion weight of each pixel point 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 for material defect detection of the keyboard and the keycap to be detected.
[0012] Preferably, the defect degree of each pixel point in the gray image is obtained according to the gray difference of the pixel points in the gray image, comprising:
[0013] The gray histogram of the gray image is obtained, the horizontal axis of the gray histogram is the gray level, and the vertical axis is the pixel number corresponding to the gray level, the maximum gray level and the minimum gray level in the gray histogram are obtained;
[0014] For any pixel point in the gray image, the difference between the maximum gray level and the gray level of the any pixel point is obtained to obtain a first gray level difference, and the reciprocal of the addition result of the first gray level difference and a preset constant is obtained to obtain a first feature value;
[0015] The difference between the gray level of the any pixel point and the minimum gray level is obtained to obtain a second gray level difference, and the reciprocal of the addition result of the second gray level difference and a preset constant is obtained to obtain a second feature value;
[0016] The product of the first feature value and the second feature value is obtained to obtain the defect feature value of the any pixel point;
[0017] Obtaining the reciprocal of the pixel quantity corresponding to the gray level of the any pixel point, and obtaining the defect degree of the any pixel point according to the product of the defect feature value of the any pixel point and the reciprocal.
[0018] Preferably, the obtaining of the at least one suspected defect region in the gray-scale image according to the defect degree of each pixel point in the gray-scale image comprises:
[0019] The coordinates and the defect degree of each pixel point in the gray-scale image are combined to form a feature vector, and the pixel points in the gray-scale image are processed by clustering according to the feature vector of each pixel point to obtain at least one cluster, the defect degree mean of the pixel points in each cluster is obtained, the cluster with the defect degree mean 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.
[0020] Preferably, the obtaining of the defect coefficient of each pixel point in the any suspected defect region 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 comprises:
[0021] 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-scale distribution feature of the pixel point of the any suspected defect region.
[0022] 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.
[0023] For the 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.
[0024] Preferably, the obtaining of the first defect coefficient of each pixel point in the any suspected defect region according to the color feature of the pixel point of the corresponding region in the initial image and the gray-scale distribution feature of the pixel point of the any suspected defect region comprises:
[0025] The pixel points in each suspected defect region in the gray-scale image are recorded as suspected defect pixel points, and the pixel points in the non-suspected defect region in the gray-scale image are recorded as normal pixel points.
[0026] For the 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.
[0027] In the gray-scale image, a sliding window of a preset size is established with the any suspected defect pixel point as the center, and the sliding window is slid in any direction of four neighborhood directions of the sliding window until all pixel points in the sliding window are normal pixel points, to obtain a reference window of the target window in the any direction, and if there is 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 the target window does not have a reference window in the any direction.
[0028] An edge pixel point of the any suspected defect region is obtained, and 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.
[0029] All reference windows of the target window are obtained, a neighborhood window of each edge pixel point of the any suspected defect region is obtained, and a first defect coefficient of the any suspected defect pixel point is obtained according to color differences 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.
[0030] Preferably, the first defect coefficient of the any suspected defect pixel point is obtained according to the color differences 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, including:
[0031] Intensities of each pixel point in the initial image in three color channels of RGB 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 coordinate in the gray-scale image.
[0032] A ratio of an R channel value to a G channel value of each suspected defect pixel point in the target window is obtained, and a mean value of the ratio is obtained as a first color ratio of the target window, and a ratio of a B channel value to a G channel value of each suspected defect pixel point in the target window is obtained, and a mean value of the ratio is obtained as a second color ratio of the target window.
[0033] For any reference window, a ratio of an R channel value to a G channel value of each normal pixel point in the reference window is obtained, and a mean value of the ratio is obtained as a first color ratio of the any reference window, and a ratio of a B channel value to a G channel value of each normal pixel point in the reference window is obtained, and a mean value of the ratio is obtained as a second color ratio of the any reference window.
[0034] 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.
[0035] 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.
[0036] 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.
[0037] Preferably, obtaining the second defect coefficient for each pixel in any suspected defect region based on the distribution characteristics and texture characteristics of pixels in any suspected defect region includes:
[0038] 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.
[0039] 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.
[0040] 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.
[0041] Preferably, 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 method comprises the following steps of:
[0042] For any pixel point in the gray 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 a 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.
[0043] Preferably, 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 method further comprises the following steps of:
[0044] A difference between a 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.
[0045] Preferably, 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 method further comprises the following steps of:
[0046] 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 horizontal axis and the vertical direction as the vertical axis, the 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 the 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.
[0047] 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.
[0048] The enhanced gray value of each pixel point in the gray image is obtained to form an enhanced image.
[0049] Compared with the prior art, the embodiment of the application has the following beneficial effects:
[0050] The application obtains an initial image and a gray image of a keyboard and a keycap to be detected, obtains a 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, obtains a defect coefficient of each pixel point in 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 texture feature of the pixel points in the any suspected defect area, 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, obtains an adaptive small-scale weight and an 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 a 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 weights 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. BRIEF DESCRIPTION OF DRAWINGS
[0051] 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 prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative labor under the premise of the drawings.
[0052] Figure 1 is a method flow chart of a material defect detection method for keyboard and keycap production provided by the first embodiment of the present application.
[0053] Figure 2 is an image of a keyboard and a keycap collected by the first embodiment of the present application. DETAILED DESCRIPTION
[0054] Embodiments of the present disclosure are described in detail below with reference to the attached drawing figures, wherein the embodiments given herein are by way of illustration only and are not intended to be limiting of the present disclosure.
[0055] It should be noted that the terms "first", "second", and the like in the description of the present disclosure and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present disclosure.
[0056] In order to illustrate the technical solutions of the present application, the following will be described by specific embodiments.
[0057] Referring to Figure 1 , a method flowchart of a keyboard and keycap production material defect detection method provided by Embodiment One of the present application is shown in Figure 1 , which can include:
[0058] Step S101, obtaining the initial image and the gray image of the keyboard and keycap to be detected.
[0059] During the production of the keyboard and keycap, batch differences of plastic raw materials (such as inconsistent color master batch ratio of ABS / PBT), uneven plastic dyeing, ink distribution differences, etc. will all cause color difference defects in the keyboard and keycap, which 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. Since the keyboard and keycap are non-planar structures and have good material reflectivity, the prior art usually uses multi-scale Retinex decomposition to perform light normalization enhancement on the keyboard and keycap image, and then uses an image processing algorithm to complete the material defect detection of the keyboard and keycap production.
[0060] In this embodiment, after the keyboard and keycap are completed, the finished product (i.e., the keyboard and keycap are assembled together) is placed on a transmission track, and the transmission track is provided with an image acquisition device at a fixed position, the image acquisition device is composed of a high-definition camera and a light source, when the product passes through the device, it is stopped for 0.2s, and the image of the keyboard and keycap is collected, as shown in Figure 2It is not limited here and can be set according to the specific implementation scene. Since the detection method of each keyboard and keycap to be detected is the same, in this embodiment, an image of a keyboard and keycap to be detected is collected, a non-local mean denoising method is used to denoise the image, and a semantic segmentation method is used to extract the keyboard and keycap region in the image to obtain an initial image of the keyboard and keycap to be detected. The initial image is an RGB image. The initial image is subjected to grayscale processing to obtain a 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. The non-local mean denoising, semantic segmentation method and grayscale processing belong to the prior art and will not be described here.
[0061] When the traditional multi-scale Retinex decomposition algorithm is used to perform illumination normalization enhancement on an image, the fusion weight of different scale images is fixed. If the same fusion weight is used for the interference regions such as reflection and shadow and the color difference defect region in the keyboard and keycap image, the color difference defect region will be blurred or the interference regions such as reflection and shadow will be retained, thereby causing loss of details of the image defect region and extremely low elimination effect of the interference regions after processing, which affects the accuracy of the material defect detection of the keyboard and keycap production.
[0062] Therefore, in this embodiment, a suspected defect region is first obtained, then a defect coefficient of each pixel point in the grayscale image is obtained, and the adaptive small-scale weight and the adaptive large-scale weight of each pixel point are obtained by using the defect coefficient of each pixel point in the grayscale image. Finally, an enhanced image is obtained by using the Retinex algorithm according to the adaptive small-scale weight and the adaptive large-scale weight of each pixel point, thereby improving the accuracy of the material defect detection of the keyboard and keycap production.
[0063] In step S102, the defect degree of each pixel point in the grayscale image is obtained according to the grayscale difference of the pixel points in the grayscale image, and at least one suspected defect region in the grayscale image is obtained according to the defect degree of each pixel point in the grayscale image.
[0064] First, a suspected defect region is obtained. Since the main reason for the color difference defect of the keyboard and keycap is the batch difference of the plastic raw material (such as inconsistent ABS / PBT color master batch ratio) or uneven plastic dyeing, uneven ink distribution, the color difference defect region in the grayscale image is a brighter or darker region than the normal region. At the same time, the probability of color difference defect is relatively small, and the proportion of the color difference defect region in the entire keyboard and keycap region is small. Therefore, the defect degree of each pixel point in the grayscale image can be obtained according to the grayscale difference of the pixel points in the grayscale image, and then the suspected defect region in the grayscale image can be obtained according to the defect degree of each pixel point in the grayscale image.
[0065] The method for obtaining the defect degree of each pixel point in the gray image according to the gray difference of the pixel points in the gray image is as follows:
[0066] A gray histogram of the gray image is obtained, the horizontal axis of the gray 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 histogram are obtained;
[0067] For any pixel point in the gray image, a difference value between the maximum gray level and the gray level of the 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;
[0068] A difference value between the gray level of the 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;
[0069] A product of the first feature value and the second feature value is obtained, to obtain a defect feature value of the pixel point;
[0070] An inverse of the pixel number corresponding to the gray level of the pixel point is obtained, and a product of the defect feature value of the pixel point and the inverse is obtained, to obtain the defect degree of the pixel point.
[0071] In an embodiment, taking an i-th pixel point in the gray image as an example, a calculation formula of the defect degree of the i-th pixel point is as follows:
[0072]
[0073] wherein, is the defect degree of the i-th pixel point; is the maximum gray level; is the minimum gray level; is the gray level of the i-th pixel point; is the pixel number corresponding to the gray level of the i-th pixel point; c is a preset constant, which is set to 0.01 in the embodiment, and is used to ensure that the fraction is meaningful, and is not limited here, and can be set according to a specific implementation scenario.
[0074] It should be noted that, is the defect feature value of the i-th pixel point, and the closer the gray level of the i-th pixel point to the maximum gray level or the minimum gray level, the more likely that the i-th pixel point is an over-bright pixel point or an over-dark pixel point, and the greater the first feature value of the i-th pixel point or the second feature value of the i-th pixel point is, and then The greater the value is, the more the i-th pixel point conforms to the feature of the color difference defect region in the gray image. The greater the value is, the more the i-th pixel point conforms to the feature of the color difference defect region in the gray image. The smaller the value is, the more the i-th pixel point belongs to the minority pixel points in the gray image, that is, the more the i-th pixel point is likely to be brighter or darker in the global gray image. The greater the value is, the more the i-th pixel point belongs to the minority pixel points in the gray image, that is, the more the i-th pixel point is likely to be brighter or darker in the global gray image.
[0075] Further, coordinates and defect degrees of each pixel point in the gray image are combined to form a feature vector, and each pixel point is subjected to mean shift clustering processing according to the feature vector of each pixel point, to obtain at least one class cluster, and the defect degree mean value of the pixel points in each class cluster is obtained. The greater the defect degree mean value of the pixel points in the class cluster is, the more likely the pixel points in the class cluster are the pixel points in the defect region. Therefore, the class cluster with a defect degree mean value greater than or equal to a preset defect degree threshold is recorded as a target class cluster. In the present embodiment, the preset defect degree threshold is set to 0.7, which is not limited here and can be set according to the specific implementation scenario. All pixel points in a target class cluster form an initial region. For any initial region, an inscribed ellipse of the initial region is obtained. In any initial region, the pixel points with the shortest distance to the inscribed ellipse in each direction of the inscribed ellipse are obtained as edge pixel points, and all edge pixel points are connected to obtain a suspected defect region corresponding to any initial region. Similarly, a suspected defect region corresponding to each target class cluster is obtained. The mean shift clustering belongs to the prior art, and will not be described here.
[0076] Thus, the suspected defect region in the gray image is obtained.
[0077] In step S103, for any suspected defect region, the defect coefficient of each pixel point in the suspected defect region is obtained according to the color feature of the pixel points in the corresponding region of the initial image and the distribution feature and texture feature of the pixel points in the suspected defect region, and the defect coefficient of each pixel point in the non-suspected defect region of the gray image is set to 0.
[0078] Since the keyboard and the keycap are three-dimensional, the light cannot cover every region of the keyboard and the keycap, which causes light shadows. The shadow regions exist in the collected image, and the keyboard and the keycap are made of materials with good reflectivity, so the highlight regions (i.e. the light reflection regions) exist in the collected image. Since the shadow regions and the highlight regions also exhibit the feature of local brighter or darker gray levels, that is, the gray levels of the shadow regions and the highlight regions also contain features deviating from the normal regions. However, the shadow regions and the highlight regions are normal phenomena, so it is necessary to distinguish the suspected defects and reduce the influence of the interference regions (the shadow regions and the highlight regions) on the defect regions.
[0079] 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.
[0080] 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.
[0081] 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:
[0082] (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.
[0083] 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.
[0084] 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.
[0085] In the gray-scale image, a sliding window with a preset size of 5x5 is established with the any suspected defect pixel point as the center, which is not limited here and can be set according to a specific implementation scenario; for any direction in the four neighborhood directions 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, to obtain a reference window of the target window in the any direction; if there is 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 the target window does not exist in the reference window in the any direction;
[0086] An edge pixel point of the any suspected defect region is obtained, and for any edge pixel point, a neighborhood window with a preset length of 5 containing the neighborhood pixel points of the any edge pixel point is established in the normal direction of the any edge pixel point, which is not limited here and can be set according to a specific implementation scenario;
[0087] The intensity values of each pixel point in the initial image in the RGB three color channels are recorded as three-channel values, a two-dimensional rectangular coordinate system is established with the lower left corner of the initial image and the gray-scale image as the origin, the horizontal direction as the horizontal axis and the vertical direction as the vertical axis, and the three-channel values of each pixel point in the initial image are taken as the three-channel values of the pixel points with the same coordinates in the gray-scale image;
[0088] The ratio of the R channel value to the G channel value of each suspected defect pixel point in the target window is obtained, and the average ratio value is obtained, which 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 defect pixel point in the target window is obtained, and the average ratio value is obtained, which is recorded as the second color ratio of the target window;
[0089] All reference windows of the target window are obtained, for any reference window, the ratio of the R channel value to the G channel value of each normal pixel point in the reference window is obtained, and the average ratio value is obtained, which is recorded as the first color ratio of the any reference window; the ratio of the B channel value to the G channel value of each normal pixel point in the reference window is obtained, and the average ratio value is obtained, which is recorded as the second color ratio of the any reference window;
[0090] The absolute value of the difference between the first color ratio of the target window and the first color ratio of the any reference window is obtained, to obtain a first color difference value; the absolute value of the difference between the second color ratio of the target window and the second color ratio of the any reference window is obtained, to obtain a second color difference value; the addition result of the first color difference value and the second color difference value is obtained, to obtain a color difference feature value of the target window and the any reference window;
[0091] obtaining a neighborhood window of each edge pixel point of the any suspected defect region, obtaining a mean difference of gray scale values of pixel points in each neighborhood window, obtaining a gradient value of each pixel point in each neighborhood window to form a gradient value set, and obtaining a gradient mean value of the gradient value set;
[0092] obtaining a color difference feature value of the target window and each reference window, obtaining a color difference feature accumulation value, and performing a product process normalization between the color difference feature accumulation value, the mean difference accumulation value and the gradient mean value to obtain a first defect coefficient of the any suspected defect pixel point.
[0093] In an embodiment, taking a dth suspected defect pixel point in any suspected defect region as an example, a calculation formula of the first defect coefficient of the dth suspected defect pixel point is as follows:
[0094]
[0095] wherein, the first defect coefficient of the dth suspected defect pixel point; an R channel value of the jth pixel point in the target window; a G channel value of the jth pixel point in the target window; a number of pixel points in the target window; an R channel value of the mth pixel point in the kth reference window; a G channel value of the mth pixel point in the kth reference window; a number of pixel points in the reference window; a number of reference windows; a B channel value of the jth pixel point in the target window; a B channel value of the mth pixel point in the kth reference window; and the gradient mean value; an absolute value symbol; a normalization function.
[0096] It should be noted that, a first color proportion of the target window, a first color proportion of the kth reference window of the target window, a first color difference value, the greater the first color difference value, the greater the difference between the first color proportion of the target window and the first color proportion of the kth reference window of the target window, i.e., the greater the difference between the color proportion of the target window and the color proportion of the surrounding normal region, and the more likely the target window belongs to a color difference defect region, the greater the first color difference value; a second color proportion of the target window, a second color proportion of the kth reference window of the target window, a second color difference value, The greater the D, the greater the difference between the target window and the second color proportion in the kth reference window of the target window, that is, the greater the difference between the color proportion of the target window and the color proportion of the surrounding normal region, the more likely the target window belongs to the color difference defect region, The greater the D, the higher the edge blur degree of the suspected defect region where the dth suspected defect pixel point is located, and the greater the possibility of belonging to the color difference defect region, The greater the D, the greater the possibility of belonging to the color difference defect region, The greater the D, the worse the edge gray consistency of the suspected defect region where the dth suspected defect pixel point is located, the worse the edge definition, and the more in line with the edge blur characteristics of the color difference defect region, The greater the D, the greater the possibility of belonging to the color difference defect region.
[0097] (2) According to the distribution characteristics and texture characteristics of the pixel points in any suspected defect region, a second defect coefficient of each pixel point in the suspected defect region is obtained.
[0098] Specifically, in the gray-scale image, a circumscribed rectangle of the any suspected defect region is obtained, the aspect ratio of the circumscribed rectangle is calculated, the number of pixel points in the any suspected defect region is obtained, the product between the number of pixel points and the aspect ratio is calculated, and a shape feature value of the any suspected defect region is obtained.
[0099] A suspected defect region other than the any suspected defect region is recorded as a reference region, a shape feature value of each reference region is obtained, for any reference region, a ratio of the shape feature value of the any suspected defect region to the shape feature value of the any reference region is obtained, an absolute value of the difference between the constant 1 and the ratio is obtained, a difference degree between the any suspected defect region and the any reference region is obtained, and a difference degree accumulation value is obtained.
[0100] A gray-level co-occurrence matrix of the any suspected defect region is obtained, the angular second moment and the contrast of the gray-level co-occurrence matrix are obtained, an addition result of the angular second moment and the contrast of the gray-level co-occurrence matrix is obtained, and the product of the addition result and the difference degree accumulation value is obtained as the second defect coefficient of each suspected defect pixel point in the any suspected defect region.
[0101] In an embodiment, taking the dth suspected defect pixel point in any suspected defect region as an example, the calculation formula of the second defect coefficient of the dth suspected defect pixel point is:
[0102]
[0103] wherein, is the second defect coefficient of the dth suspected defect pixel point; is the number of pixel points in any suspected defect region; is the length of the circumscribed rectangle of any suspected defect region; is the width of the circumscribed rectangle of any suspected defect region; is the number of pixel points in the ath reference region; is the length of the circumscribed rectangle of the ath reference region; is the width of the circumscribed rectangle of the ath reference region; is the number of reference regions; is the angular second moment of the gray level co-occurrence matrix of any suspected defect region; is the contrast of the gray level co-occurrence matrix of any suspected defect region; is the absolute value sign; is the normalization function.
[0104] It should be noted that, is the shape feature value of any suspected defect region, is the shape feature value of the ath reference region, the closer to 1, the more similar the area and shape of any suspected defect region and the ath reference region are, the more consistent with the feature that the shape of the highlight region is relatively consistent, that is, the difference between any suspected defect region and the ath reference region is smaller, is smaller; reflects the texture clarity of any suspected defect region, and clear texture usually has regular local patterns, that is, the texture is uniform and regular, so, is larger, the more consistent with the feature that the texture of the color difference defect region is clear, is larger; is the contrast of the gray level co-occurrence matrix of any suspected defect region, is larger, indicating that the texture of any suspected defect region is clearer, and the more inconsistent with the feature that the texture of the highlight region is blurred, is larger.
[0105] (3) 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.
[0106] In an embodiment, taking the dth pixel point in any suspected defect region as an example, the calculation formula of the defect coefficient of the dth pixel point is:
[0107]
[0108] wherein, a defect coefficient of the dth pixel point; a first defect coefficient of the dth pixel point; a second defect coefficient of the dth pixel point.
[0109] It should be noted that, The greater the defect coefficient of the dth pixel point is, the more the dth pixel point does not conform to the characteristics of the pixel points in the shadow area, that is, the more the dth pixel point conforms to the characteristics of the pixel points in the color difference defect area, the greater the defect coefficient of the dth pixel point is. The greater the defect coefficient of the dth pixel point is, the more the dth pixel point does not conform to the characteristics of the pixel points in the highlight area, that is, the more the dth pixel point conforms to the characteristics of the pixel points in the color difference defect area, the greater the defect coefficient of the dth pixel point is.
[0110] According to any one of the defect coefficient acquisition methods of the dth pixel point in the suspected defect area described above, the defect coefficient of each pixel point in each defect area in the gray-scale image is acquired.
[0111] Since the pixel points in the non-suspected defect area of the gray-scale image are normal pixel points, that is, the non-suspected defect area is a normal area, the defect coefficient of each pixel point in the non-suspected defect area of the gray-scale image is set to 0.
[0112] At this point, the defect coefficient of each pixel point in the gray-scale image is obtained.
[0113] In step S104, the defect coefficient of each pixel point in the gray-scale image is acquired, and the adaptive small-scale weight and the adaptive large-scale weight of each pixel point are acquired according to the defect coefficient of each pixel point in the gray-scale image.
[0114] The greater the defect coefficient is, the higher the possibility that the pixel point belongs to the color difference defect area is. In the embodiment, the gray-scale image is decomposed into a large-scale image and a small-scale image by using the Retinex algorithm, the pixel point with a higher defect coefficient has a greater possibility of belonging to the color difference defect area, and the small-scale weight thereof needs to be improved to capture the local details of the image and enhance the details of the color difference defect area.
[0115] Therefore, the adaptive small-scale weight and the adaptive large-scale weight of each pixel point can be acquired according to the defect coefficient of each pixel point in the gray-scale image, and the acquisition method of the adaptive small-scale weight and the adaptive large-scale weight of any pixel point in the gray-scale image is as follows:
[0116] (1) The adaptive small-scale weight of any pixel point is acquired.
[0117] Specifically, an addition result of the preset large-scale weight and the preset small-scale weight is obtained to obtain a total weight, a difference between a constant 1 and the total weight is obtained to obtain a weight coefficient, a product of the weight coefficient and a 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.
[0118] In an embodiment, taking an i-th pixel point in a gray image as an example, a calculation formula of the adaptive small-scale weight of the i-th pixel point is:
[0119]
[0120] wherein, is the adaptive small-scale weight of the i-th pixel point; is the defect coefficient of the i-th pixel point; 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 a specific implementation scenario.
[0121] It should be noted that, The larger the value is, the greater the possibility that the i-th pixel point belongs to the color difference defect region is, and in order to capture local details of the image and enhance details of the color difference defect region, the small-scale weight of the i-th pixel point needs to be increased, the larger the value is; The smaller the value is, the greater the possibility that the i-th pixel point belongs to a normal region is, and in order to extract global illumination information of the image and suppress local fluctuations and smooth uneven illumination, the small-scale weight of the i-th pixel point does not need to be increased, the smaller the value is.
[0122] (2) Obtain an adaptive large-scale weight of the any pixel point.
[0123] Specifically, a difference between a 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.
[0124] In an embodiment, taking an i-th pixel point in a gray image as an example, a calculation formula of the adaptive large-scale weight of the i-th pixel point is:
[0125]
[0126] wherein, is the adaptive small-scale weight of the i-th pixel point; is the adaptive small-scale weight of the i-th pixel point.
[0127] Similarly, the adaptive large-scale weight and the adaptive small-scale weight of each pixel point in the gray image are obtained.
[0128] In step S105, the Retinex algorithm is used to perform decomposition and enhancement processing on the gray image 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 the fusion weights 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.
[0129] In this embodiment, the Retinex algorithm is used to decompose the gray 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 belongs to the prior art and will not be described here. Then, 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 horizontal axis, and the vertical direction as the vertical axis. The pixel point in the large-scale enhanced image with the same coordinates as the any pixel point is denoted as a large-scale pixel point, and the pixel point in the small-scale enhanced image with the same coordinates as the any pixel point is denoted as a small-scale pixel point.
[0130] The large-scale weight of the any pixel point is taken as the weight coefficient of the gray value of the large-scale pixel point, and the small-scale weight of the any pixel point is taken as the weight coefficient of the gray value of the small-scale pixel point. The gray values of the large-scale pixel point and the small-scale pixel point are weighted and summed to obtain the enhanced gray value of the any pixel point.
[0131] According to the above method for obtaining the enhanced gray value of any pixel point, the enhanced gray value of each pixel point in the gray image is obtained to form an enhanced image.
[0132] After obtaining the enhanced image, the enhanced image is input into a previously trained material defect detection model of the keyboard and the keycap to detect the color difference defects of the keyboard and the keycap. The keyboard and the keycap that do not meet the production requirements are marked to assist the staff in secondary detection. The material defect detection model of the keyboard and the keycap is based on a convolutional neural network (CNN) or a target detection model (such as YOLO or Faster R-CNN) and is trained using a deep learning framework (such as TensorFlow or PyTorch). The training of the material defect detection model of the keyboard and the keycap and the detection of the color difference defects of the keyboard and the keycap based on the material defect detection model of the keyboard and the keycap belong to the prior art and will not be described here.
[0133] The above examples are only used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing examples, those ordinarily skilled in the art should understand: the technical solutions recorded in the foregoing examples can still be modified, or some technical features can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for detecting material defects in the production of keyboards and keycaps, characterized by, The keyboard and keycap production material defect detection method comprises: Obtain the initial image and the gray image of the keyboard and keycap to be detected; According to the gray difference of the pixel points in the gray image, obtain the defect degree of each pixel point in the gray image, and obtain 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, according to the color characteristics of the pixel points in the corresponding area in the initial image, and the distribution characteristics and texture characteristics of the pixel points in the any suspected defect area, obtain the defect coefficient of each pixel point in the any suspected defect area, and set the defect coefficient of each pixel point in the non-suspected defect area of the gray image to 0; Obtain the defect coefficient of each pixel point in the gray image, and obtain 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; The Retinex algorithm is used to decompose and enhance the gray image 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 used as the fusion weight of each pixel point 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 for material defect detection of the keyboard and keycap to be detected; 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, which comprises: For any pixel point in the gray image, obtain the addition result of the preset large-scale weight and the preset small-scale weight to obtain a total weight, obtain the difference between the constant 1 and the total weight to obtain a weight coefficient, obtain the product of the weight coefficient and the defect coefficient of the any pixel point to obtain a weight adjustment value, and obtain the addition result of the preset small-scale weight and the weight adjustment value to obtain the adaptive small-scale weight of the any pixel point; obtain the difference between the constant 1 and the adaptive small-scale weight of the any pixel point to obtain the adaptive large-scale weight of the any pixel point.
2. The method of claim 1, wherein the material defect of the keyboard and the keycap is detected. The defect degree of each pixel point in the gray image is obtained according to the gray difference of the pixel points in the gray image, which comprises: Obtain the gray histogram of the gray image, the horizontal axis of the gray histogram is the gray level, and the vertical axis is the pixel number corresponding to the gray level, obtain the maximum gray level and the minimum gray level in the gray histogram; For any pixel point in the gray image, obtain the difference between the maximum gray level and the gray level of the any pixel point to obtain a first gray level difference, and obtain the reciprocal of the addition result of the first gray level difference and the preset constant to obtain a first feature value; Obtain the difference between the gray level of the any pixel point and the minimum gray level to obtain a second gray level difference, and obtain the reciprocal of the addition result of the second gray level difference and the preset constant to obtain a second feature value; Obtain the product of the first feature value and the second feature value to obtain the defect feature value of the any pixel point; 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 of claim 1, wherein the material defect of the keyboard and the keycap is detected. 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 of claim 1, wherein the material defect of the keyboard and the keycap is detected. 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 of claim 4, wherein the method is characterized by: 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; Obtaining all reference windows of the target window, obtaining a neighborhood window of each edge pixel point of the any suspected defect region, and obtaining a first defect coefficient of the any suspected defect pixel point according to color difference between the target window and each reference window and gray scale distribution characteristics of pixel points in the neighborhood window of each edge pixel point.
6. The method of claim 5, wherein the method is characterized by: The first defect coefficient of the any suspected defect pixel point is obtained according to the color difference between the target window and each reference window and the gray scale distribution characteristics of the pixel points in the neighborhood window of each edge pixel point. The intensity values of each pixel point in the initial image in the RGB three color channels are recorded as three channel values, a two-dimensional rectangular coordinate system is established with the lower left corner of the initial image and the gray scale image as the origin, the horizontal direction as the horizontal axis and the vertical direction as the vertical axis, and the three channel values of each pixel point in the initial image are taken as the three channel values of the pixel points with the same coordinates in the gray scale image. The ratio of the R channel value to the G channel value of each suspected defect pixel point in the target window is obtained, and a ratio mean value is correspondingly obtained, which is recorded as a first color ratio of the target window. The ratio of the R channel value to the G channel value of each normal pixel point in the reference window is obtained, and a ratio mean value is correspondingly obtained, which is recorded as a first color ratio of the any reference window. The absolute value of the difference between the first color ratio of the target window and the first color ratio of the any reference window is obtained, and a first color difference value is obtained. The mean difference of the gray scale values of the pixel points in each neighborhood window is obtained, and a mean difference cumulative value is correspondingly obtained. The gradient values of each pixel point in each neighborhood window are obtained to form a gradient value set, and a gradient mean value of the gradient value set is obtained.
7. The method of claim 5, wherein the method further comprises: determining the material defect of the keyboard and the keycap by using the image data. The color difference characteristic value of the target window and each reference window is obtained, and a color difference characteristic cumulative value is correspondingly obtained. The product process between the color difference characteristic cumulative value, the mean difference cumulative value and the gradient mean value is normalized to obtain the first defect coefficient of the any suspected defect pixel point. 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. In the gray image, an outer rectangle of the any suspected defect region is obtained, an aspect ratio of the outer rectangle is calculated, a number of pixel points in the any suspected defect region is obtained, a product between the number of pixel points and the aspect ratio is calculated, and a shape feature value of the any suspected defect region is obtained; A suspected defect region other than the any suspected defect region is recorded as a reference region, a shape feature value of each reference region is obtained, for any reference region, a ratio of the shape feature value of the any suspected defect region to the shape feature value of the any reference region is obtained, a difference absolute value between the constant 1 and the ratio is obtained, a difference degree between the any suspected defect region and the any reference region is obtained, the difference degree between the any suspected defect region and each reference region is obtained, and a difference degree accumulation value is obtained correspondingly; A gray level co-occurrence matrix of the any suspected defect region is obtained, an angular second moment and a contrast of the gray level co-occurrence matrix are obtained, an addition result of the angular second moment and the contrast is obtained, and a product of the addition result and the difference degree accumulation value is taken as a second defect coefficient of each suspected defect pixel point in the any suspected defect region.
8. The method of claim 1, wherein the material defect of the keyboard and the keycap is detected. The large-scale enhanced image and the small-scale enhanced image are weighted and fused to obtain an enhanced image, including: For any pixel point in the gray image, a two-dimensional rectangular coordinate system is established with a lower left corner of the large-scale enhanced image and the small-scale enhanced image as an origin, a horizontal direction as a transverse axis, and a vertical direction as a 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; A large-scale weight of the any pixel point is taken as a weight coefficient of a gray value of the large-scale pixel point, a small-scale weight of the any pixel point is taken as a weight coefficient of a 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, and an enhanced gray value of the any pixel point is obtained; Enhanced gray values of each pixel point in the gray image are obtained to form an enhanced image.
Citation Information
Patent Citations
Method for processing video image of portable night vision instrument
CN103700066A
Industrial surface defect detection method, system and equipment and storage medium
CN120107175A
Screw conveyor blade pressing quality detection method based on image recognition
CN120833334A