Image analysis-based special-shaped sample color defect correction and error compensation method and system

By identifying and correcting defects in irregularly shaped samples using image analysis technology, and combining this with a colorimetric defect standard database for parameter adjustment and color compensation, the problems of low colorimetric accuracy and poor automation in irregularly shaped samples have been solved, resulting in efficient and accurate colorimetric results.

CN121937693BActive Publication Date: 2026-06-23GUANGDONG SANENSHI TECH CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG SANENSHI TECH CO LTD
Filing Date
2026-03-26
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing technologies suffer from low colorimetric accuracy and poor automation in colorimetric measurement of irregularly shaped samples, failing to meet the high-precision and high-efficiency colorimetric requirements of industry. Furthermore, image analysis technology has not fully realized its core value, lacking automated image-level correction methods and error compensation strategies adapted to the material and morphological characteristics of irregularly shaped samples.

Method used

By using image analysis technology, raw images are acquired and preprocessed to identify defect features and locations. These are then matched against a colorimetric defect standard database to perform defect correction and parameter adjustment. Color compensation is performed by combining core image features to construct a colorimetric defect standard database, thus achieving fully automated processing.

Benefits of technology

It has achieved full automation of color measurement of irregularly shaped samples, improved color measurement accuracy and efficiency, met the industrial field's demand for high-precision and automated color quality control, eliminated image acquisition distortion and color measurement area deviation, and reduced manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121937693B_ABST
    Figure CN121937693B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image analysis, and specifically provides a special-shaped sample color measurement defect correction and error compensation method and system based on image analysis, which comprises the following steps: collecting an original image of a sample to be measured and preprocessing the original image to obtain a to-be-measured image; matching the to-be-measured image with a pre-constructed color measurement defect standard database, identifying defect features and positions through an image analysis algorithm, matching a correction strategy to obtain a correction image of an effective color measurement area; adjusting color measurement instrument parameters according to the defect features, collecting color values of the effective area, and performing mean value processing to obtain original average color values; extracting image shape, material and color core features, matching a color compensation algorithm in association with the original average color values, and completing compensation to obtain target color values. The method realizes full-process automation of special-shaped sample color measurement, effectively eliminates collection deviations caused by shapes, improves color measurement precision and efficiency, and adapts to industrial high-precision control requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image analysis technology, specifically to a method and system for correcting color measurement defects and compensating for errors in irregularly shaped samples based on image analysis. Background Technology

[0002] Color measurement is a core component of industrial product quality control, widely used in fields such as plastics and electronics, automotive painting, packaging and printing, and cosmetic packaging materials. Its measurement accuracy directly determines the appearance quality and consistency of products. With the diversification of industrial product design, the demand for color measurement of irregularly shaped samples such as curved surfaces, concave and convex surfaces, and irregular shapes is increasing. Currently, the industry mainly uses spectrophotometers and non-contact colorimeters to complete related measurements, and image analysis technology has been initially applied to basic aspects of colorimeters such as image framing and positioning, becoming an important direction for the intelligent development of color measurement technology.

[0003] However, existing technologies still have many technical shortcomings in the colorimetric measurement of irregularly shaped samples, resulting in low colorimetric accuracy and poor automation, which cannot meet the high-precision and high-efficiency colorimetric measurement requirements of industry. The specific problems are as follows:

[0004] (1) Due to the irregular shape of the sample, the color measurement is prone to image acquisition distortion (curved surface reflection, concave and convex structure shadow, blurred outline, etc.) and color measurement area deviation. Existing technology lacks automated image level correction methods and relies on manual adjustment of supplementary light, measurement angle, etc., which is cumbersome and easily leads to distortion of the original color value data, becoming the core source of color measurement error.

[0005] (2) Existing color measurement error compensation is mostly general color value adjustment. It does not eliminate the basic defects at the acquisition level, nor does it have a scenario-based compensation strategy that is adapted to the material and shape characteristics of irregular samples. The compensation effect is poor, and the color difference accuracy of the final color measurement result is difficult to meet the requirements of high-precision industrial applications.

[0006] (3) The integration of image analysis technology with color measurement of irregular samples is extremely low. It is only used as a basic auxiliary means of color measurement and has not formed a technical closed loop of "image analysis-defect correction-error compensation". It is impossible to achieve automatic identification and correction of defects through image analysis, and it has not associated image features with compensation algorithms. The color measurement process requires a lot of manual intervention and has low production efficiency.

[0007] In summary, existing technologies cannot solve the problems of automated correction of defects and accurate error compensation in the color measurement of irregularly shaped samples, and they do not fully utilize the core value of image analysis technology, resulting in low color measurement accuracy, poor automation, and high labor costs for irregularly shaped samples. Therefore, it is necessary to develop a method that utilizes image analysis technology to correct defects and compensate for errors generated during the color measurement of irregularly shaped samples, achieving integrated and automated defect correction and error compensation. This has become an urgent technical problem to be solved in this field. Summary of the Invention

[0008] To overcome the shortcomings of existing technologies, this invention provides a method and system for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis, in order to solve the problems in existing technologies.

[0009] One embodiment of the present invention provides a method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis, comprising the following steps:

[0010] S10. Acquire the original image of the sample to be tested, and preprocess the original image to obtain the image to be tested;

[0011] S20. The image to be tested is matched with a pre-constructed color measurement defect standard database. A preset image analysis algorithm is used to identify the defect features and defect locations of the image to be tested. The defect features include image acquisition defects and color measurement area deviations.

[0012] S30. Based on the defect features and defect locations, match the corresponding defect correction strategies in the color measurement defect standard database, and perform defect correction on the image to be measured according to the defect correction strategies and defect locations to obtain a corrected image with marked effective color measurement areas.

[0013] S40. Adjust the acquisition parameters of the colorimeter according to the defect characteristics, use the colorimeter with the adjusted acquisition parameters to acquire color values ​​of the effective color measurement area of ​​the corrected image, and perform mean processing on the acquired color values ​​to obtain the original average color value.

[0014] S50. Extract the core features of the corrected image, including morphological features, material features and color features. Associate the core features with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. Use the color compensation algorithm to perform color compensation on the original average color value to obtain the target color value of the sample to be tested.

[0015] This application also relates to an image analysis-based system for correcting color measurement defects and compensating for errors in irregularly shaped samples, including:

[0016] The image acquisition module is used to acquire the original image of the sample to be tested, and to preprocess the original image to obtain the image to be tested;

[0017] The image recognition module is used to match the image to be tested with a pre-constructed color measurement defect standard database, and to identify the defect features and defect locations of the image to be tested using a preset image analysis algorithm. The defect features include image acquisition defects and color measurement area deviations.

[0018] The image correction module is used to match the corresponding defect correction strategy in the colorimetric defect standard database based on defect features and defect locations, and to correct defects in the image to be tested according to the defect correction strategy and defect locations, so as to obtain a corrected image with effective colorimetric areas marked.

[0019] The color value acquisition module is used to adjust the acquisition parameters of the colorimeter according to the defect characteristics. The colorimeter with the acquisition parameters adjusted is used to acquire color values ​​of the effective color measurement area of ​​the corrected image, and the acquired color values ​​are averaged to obtain the original average color value.

[0020] The color compensation module is used to extract the core features of the corrected image, including morphological features, material features, and color features. The core features are associated with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. The color compensation algorithm is then used to perform color compensation on the original average color value to obtain the target color value of the sample to be tested.

[0021] The image analysis-based colorimetric defect correction and error compensation method and system for irregularly shaped samples provided in the above embodiments have the following beneficial effects:

[0022] This application obtains the test image by acquiring the original image of the sample and preprocessing it. The test image is then matched with a pre-constructed colorimetric defect standard database. A preset image analysis algorithm automatically identifies defect features and locations, such as image acquisition defects and colorimetric region deviations. Based on these defect features and locations, a corresponding defect correction strategy is matched and the test image is corrected, resulting in a corrected image with marked effective colorimetric regions. The colorimeter's acquisition parameters are then adjusted according to the defect features. The adjusted colorimeter is used to acquire and average color values ​​in the effective colorimetric regions to obtain the original average color value. Finally, the corrected color value is extracted. The system analyzes the morphological, material, and color features of the positive image and associates them with the original average color value. It then matches the corresponding color compensation algorithm in the database to complete the color compensation and obtain the target color value of the sample under test. This fully automates the color measurement process for irregularly shaped samples, effectively solving problems such as image acquisition distortion and color measurement area deviation caused by the irregular shape of irregularly shaped samples without manual intervention. At the same time, it relies on the core features of the image to match a dedicated color compensation algorithm, eliminating the shortcomings of existing generalized color value adjustment and significantly improving the accuracy and efficiency of color measurement for irregularly shaped samples. This meets the industrial field's demand for high-precision and automated color quality control of irregularly shaped samples. Attached Figure Description

[0023] Figure 1 This is a flowchart of a method for correcting color measurement defects and compensating errors in irregularly shaped samples based on image analysis, provided as an embodiment of the present invention. Detailed Implementation

[0024] The technical solutions in the embodiments of the present invention will now be clearly and completely described in conjunction with the accompanying drawings.

[0025] Reference Figure 1 One embodiment of the present invention provides a method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis, comprising the following steps:

[0026] S10. Acquire the original image of the sample to be tested, and preprocess the original image to obtain the image to be tested;

[0027] S20. The image to be tested is matched with a pre-constructed color measurement defect standard database. A preset image analysis algorithm is used to identify the defect features and defect locations of the image to be tested. The defect features include image acquisition defects and color measurement area deviations.

[0028] S30. Based on the defect features and defect locations, match the corresponding defect correction strategies in the color measurement defect standard database, and perform defect correction on the image to be measured according to the defect correction strategies and defect locations to obtain a corrected image with marked effective color measurement areas.

[0029] S40. Adjust the acquisition parameters of the colorimeter according to the defect characteristics, use the colorimeter with the adjusted acquisition parameters to acquire color values ​​of the effective color measurement area of ​​the corrected image, and perform mean processing on the acquired color values ​​to obtain the original average color value.

[0030] S50. Extract the core features of the corrected image, including morphological features, material features and color features. Associate the core features with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. Use the color compensation algorithm to perform color compensation on the original average color value to obtain the target color value of the sample to be tested.

[0031] In this embodiment, as described in steps S10-S50 above, the core is a color error compensation process involving original image acquisition and preprocessing → automatic defect identification and location → image defect correction and effective color measurement area labeling → adaptive adjustment of colorimeter parameters and color value acquisition → image feature association. This addresses the technical pain points in existing technologies caused by irregular shapes of irregularly shaped samples, such as image acquisition distortion, color measurement area deviation, generalized error compensation, excessive manual intervention, and low color measurement accuracy. By integrating image analysis technology with the entire color measurement process for irregularly shaped samples, a complete technical closed loop of "image analysis - defect correction - error compensation" is constructed. Automatic defect correction and precise error compensation can be achieved without manual adjustment of supplementary lighting or measurement angles, eliminating the root cause of acquisition distortion at the image level. Furthermore, combined with sample-specific characteristics, customized color compensation is achieved, significantly improving the automation and measurement accuracy of color measurement for irregularly shaped samples. This meets the high-precision and high-efficiency color quality control requirements of the industrial field, as detailed below:

[0032] Step S10 involves the acquisition and preprocessing of the original image of the sample to be tested. The core of this step is to eliminate fundamental acquisition problems such as reflections, highlights, geometric distortions, and background interference in the acquired original image, and to standardize the image color to obtain a suitable image for defect identification. This addresses the root cause of color measurement errors caused by distortion in the original image acquisition. Specifically, the original image of the irregularly shaped sample to be tested is acquired using the colorimeter's built-in image acquisition module. Addressing the acquisition interference easily caused by the curved, uneven, and irregular shapes of the sample, operations such as reflection and highlight processing, geometric distortion correction, background interference removal, and color normalization are performed according to the specific circumstances. All image interference factors not related to the sample itself are eliminated, providing a high-quality image for image matching, defect identification, and other operations.

[0033] Step S20 is the image matching and defect identification and localization step. Its core is based on a pre-built colorimetric defect standard database. Image analysis algorithms automatically identify defect features and their corresponding locations in the image under test, solving the problem that existing technologies cannot automatically identify image acquisition defects and colorimetric area deviations. Specifically, the pre-processed image under test is matched against the colorimetric defect standard database. An image analysis algorithm adapted to the current irregularly shaped sample is invoked. This algorithm identifies image acquisition defects (such as reflections, shadows, blurred outlines, etc.) and colorimetric area deviations (such as colorimetric area offset, misjudgment, inappropriate range, etc.) in the image under test, and locates the specific position of the defect in the image, providing a basis for defect correction.

[0034] Step S30 is the defect correction and effective color measurement area annotation stage. Its core is to automatically correct the image based on the identified defect features and locations using a defect correction strategy adapted from the color measurement defect standard database, and to annotate the effective color measurement areas suitable for color measurement. This solves the problems of existing technologies relying on manual correction and unreasonable color measurement area selection. Specifically, a dedicated defect correction strategy is matched using defect features and locations as indexes to specifically correct defect areas in the image to be measured, eliminating the deviation between defects and color measurement areas generated during acquisition. Then, using standard samples in the color measurement defect standard database as a benchmark, the effective color measurement areas of the corrected image are adaptively annotated, thus obtaining a corrected image with annotated effective color measurement areas. This ensures that color value acquisition is performed only in the optimal area without defects and adapted to irregular shapes, ensuring the accuracy of color value data from the source of acquisition.

[0035] Step S40 involves adjusting the colorimeter parameters and acquiring the raw average color value. The core of this step is to adaptively optimize the colorimeter's acquisition parameters based on defect characteristics. Color value acquisition and preprocessing are completed within the effective measurement area, resolving data distortion issues caused by the generalization of colorimeter parameters and abnormal color values. Specifically, the exposure, white balance, and focus parameters of the colorimeter's color value acquisition module are adjusted according to the identified defect characteristics, ensuring that the colorimeter's color value acquisition matches the defect type and morphological characteristics of the sample being tested. Then, multiple color values ​​are acquired within the effective measurement area, outliers are removed, and the mean is calculated to obtain the raw average color value after removing random errors, providing accurate basic color value data for color compensation.

[0036] Step S50 is the image feature association and color error compensation stage. Its core is to combine sample-specific image features with a customized compensation algorithm, eliminating the shortcomings of generalized color value adjustments, and completing error compensation to obtain the final target color value of the sample under test. This solves the problems of poor compensation effect and substandard color difference accuracy in existing technologies. Specifically, it extracts the core features of the corrected image's shape, material, and color, associates them with the original average color value, and matches them with a color compensation algorithm adapted to the sample's features from the color measurement defect standard database. Customized compensation and correction are performed for inherent color deviations of irregularly shaped samples, such as curved surface reflection, material diffuse reflection, and edge shadow shift, ultimately obtaining a high-precision target color value that closely matches the sample's true color. This achieves fully automated and high-precision output for the color measurement of irregularly shaped samples.

[0037] It should be noted that the image acquisition module mentioned in step S10 and the color value acquisition module mentioned in step S40 in this solution are both integrated hardware modules built into the colorimeter. They are integrated inside the same colorimeter device and do not require additional independent acquisition devices. At the same time, the colorimeter mentioned in this solution can be a spectrophotometer, a non-contact colorimeter, or other mainstream industrial color measurement devices. These devices all have built-in image framing and color value acquisition functions, and their hardware structure and functional parameters are fully compatible with the entire process of image acquisition, parameter adjustment, color value acquisition, and error compensation in this solution.

[0038] In one embodiment, the construction of the pre-built colorimetric defect standard database specifically includes the following steps:

[0039] S101. Collect standard images and defect images of several irregularly shaped samples of different shapes, mark the effective color measurement area that is adapted to the shape for the standard image of each irregularly shaped sample, and record the standard color value corresponding to the effective color measurement area.

[0040] S102. Extract the corresponding image acquisition defects and color measurement area deviations from the defect images of each type of irregular sample, match the extracted defect features with appropriate defect correction strategies and parameter adjustment rules, and establish a defect feature mapping relationship based on the image acquisition defects and color measurement area deviations.

[0041] S103. Extract the core features of the standard image corresponding to each type of irregular sample, and match the appropriate color compensation algorithm based on the correlation between the morphological features, material features and color features in the core image features.

[0042] S104. Integrate and store the standard images, defect images, effective color measurement areas, standard color values, defect features, defect feature mapping relationships, defect correction strategies, parameter adjustment rules, image core features and color compensation algorithms corresponding to different shaped samples to form a color measurement defect standard database containing several different shaped sample reference groups, and associate corresponding image analysis algorithms for different shaped sample reference groups.

[0043] In this embodiment, as described in steps S101-S104 above, the core is a database construction process that involves multi-morphological sample image acquisition and annotation → defect feature extraction and rule matching → association of core features and compensation algorithms → multi-dimensional data integration and storage. This addresses the technical pain points of existing technologies, such as the lack of dedicated reference data adapted to the color measurement of irregularly shaped samples, leading to a lack of basis for defect identification and a lack of standards for correction and compensation. A color measurement defect standard database covering different irregularly shaped samples and associating "image-defect-strategy-algorithm" is constructed. This provides accurate and traceable reference data for defect identification in step S20, defect correction in S30, parameter adjustment in S40, and color compensation in S50, ensuring the consistency and accuracy of the entire automated color measurement process. Specifically, as follows:

[0044] Step S101 is the process of acquiring images of multi-morphological and irregularly shaped samples and annotating basic information. The core is to build the basic image resources and standard reference benchmarks for the database to avoid problems such as lack of original basis for defect comparison and color value calibration. Specifically, typical irregularly shaped samples from industrial settings (such as curved surfaces, concave and convex surfaces, irregular contours, and angular surfaces) are selected. At least 3-5 sets of samples are collected for each shape to cover material differences (such as glossy materials, matte materials, and transparent materials). Using the image acquisition module of the colorimeter, standard images (sample images with no acquisition defects and clear imaging) and defect images (sample images with acquisition defects such as reflections, shadows, and blurred contours) are acquired under uniform lighting conditions (such as D65 standard light source) and a fixed shooting angle (45° to the sample surface). For the standard images, the effective color measurement area is marked based on the sample shape characteristics (the marked area fits the main contour of the sample and avoids edge distortion areas). The color value acquisition module of the colorimeter is used to collect color values ​​at multiple points (no less than 5 acquisition points) in this area. The average value is calculated and used as the standard color value corresponding to the effective color measurement area to ensure the accuracy and representativeness of the standard color value.

[0045] Step S102 is the defect feature extraction and association rule matching step. The core is to establish the correspondence between "defect features - correction strategy - parameter adjustment" to avoid the problem of no suitable correction scheme after defect identification and no basis for parameter adjustment. Specifically, image feature extraction techniques (such as edge detection and grayscale histogram analysis; specific techniques can be chosen by those skilled in the art based on actual needs and are not limited here) are used to extract defect features from defect images. This clearly distinguishes between image acquisition defects (such as abnormal grayscale values ​​in reflective areas, brightness attenuation in shadow areas, and weakened edge gradients corresponding to blurred contours) and color measurement area deviations (such as the labeled area deviating from the sample subject, the range being too large and including the background, or the range being too small and missing key color measurement areas). For each defect feature, a suitable defect correction strategy is matched (such as brightness equalization strategy for reflective defects, grayscale compensation strategy for shadow defects, and edge enhancement strategy for blurred contours), while corresponding parameter adjustment rules are formulated (such as reducing exposure parameters and enabling anti-reflective filtering parameters for reflective defects; and fine-tuning focus parameters and calibrating the framing range for color measurement area deviations). Based on the above correspondence, a defect feature mapping table is established, binding defect features, defect correction strategies, and parameter adjustment rules one-to-one. This allows for the direct output of corresponding processing solutions after defect identification. See the following example (not exhaustive):

[0046] Table 1 Defect Feature Mapping Relationship Table

[0047]

[0048] Step S103 involves core feature extraction and color compensation algorithm matching. The core of this step is establishing a compatibility relationship between sample-specific features and compensation algorithms to address the poor compatibility of general compensation algorithms. Specifically, core image features are extracted from the standard image: morphological features (such as the curvature distribution of the sample contour, key dimensions, and the location of concave and convex structures), material features (such as diffuse reflectance, reflectivity, and image texture features corresponding to surface roughness), and color features (such as the RGB components, color temperature, and saturation of standard color values). The correlation between these three types of features is analyzed (e.g., highly reflective materials + curved surfaces are prone to color shifts, while matte materials + planar surfaces have high color value stability). Based on this correlation, a suitable color compensation algorithm is matched (e.g., a reflection correction compensation algorithm is matched for highly reflective curved surfaces, and a basic color shift correction algorithm is matched for matte planar materials), ensuring that the compensation algorithm matches the sample features. Based on the above correlation between core image features, a table of correspondence between core image features and color compensation algorithms is established to match specific compensation algorithms for irregularly shaped samples with different shapes, materials, and color characteristics. See the following example (not exhaustive):

[0049] Table 2. Correspondence between Image Core Features and Color Compensation Algorithms

[0050]

[0051] Step S104 is the multi-dimensional data integration, storage, and reference group construction step. The core is to form a structured, fast-retrieval database that integrates "data + algorithm". This avoids the problem of low retrieval efficiency caused by data dispersion, and provides a suitable image analysis algorithm for defect identification, ensuring the full-link association between database resources and color measurement process. Specifically, all data is categorized and integrated according to the "morphology + material" dimension, with each category forming an independent reference group for irregularly shaped samples (such as "curved high-reflectivity material reference group" and "concave-convex matte material reference group"). Within each reference group, standard images, defect images, effective color measurement area annotation information, standard color values, defect features, defect feature mapping relationship tables, defect correction strategies, parameter adjustment rules, core image features, color compensation algorithms, and corresponding image analysis algorithms customized and optimized for the morphology, material features, and typical defect types of that reference group (such as the "grayscale difference + reflectivity feature analysis" algorithm associated with the curved high-reflectivity material reference group, and the "contour fitting + edge feature comparison" algorithm associated with the concave-convex matte material reference group) are integrated and stored together. A composite index is constructed using a structured database format (such as an SQL database), with the index dimensions including "morphological features + material features + algorithm adaptation type". This allows for rapid retrieval of the corresponding reference group and associated image analysis algorithms based on the morphology and material features of the sample under test, providing dual assurance for the accuracy and efficiency of defect identification.

[0052] In one embodiment, step S10 involves preprocessing the original image to obtain the image to be tested, specifically including the following steps:

[0053] S11. Extract the morphological features of the original image of the sample to be tested, and detect the reflective and highlight areas of the original image based on the morphological features; if a reflective area is detected, perform reflective correction on the area; if a highlight area is detected, perform highlight suppression on the area; if neither is detected, keep the original image unchanged.

[0054] S12. Perform geometric distortion detection on the original image based on the morphological features; if geometric distortion is detected, perform geometric distortion correction on the distorted area; if no geometric distortion is detected, keep the original image unchanged.

[0055] S13. Identify the irregular sample region and background region in the original image based on the morphological features, and remove the interference information in the background region to locate the main region of the irregular sample.

[0056] S14. Perform color normalization processing on the main area of ​​the irregular sample to obtain the image to be tested.

[0057] In this embodiment, the core is a layered preprocessing flow that guides through morphological features → precise processing of reflective highlights → geometric distortion correction → background interference removal → color standard unification. This process addresses the technical challenges of irregularly shaped samples, such as "reflective highlight interference, geometric distortion, background clutter, and inconsistent color standards" in the original image. It systematically eliminates fundamental defects at the image acquisition level, resulting in a high-quality image that is "interference-free, distortion-free, with a clear subject, and unified color." This provides a precise and reliable image foundation for defect identification in step S20 and defect correction in step S30, preventing fundamental acquisition defects from propagating to subsequent processes and causing color measurement errors to amplify at each stage. Specifically:

[0058] Step S11 is the detection and processing of reflective and highlight areas. The core is to eliminate local brightness anomalies caused by the shape of the sample surface (such as curved surfaces and edges) and avoid color value acquisition distortion caused by reflection / highlight. Specifically, the morphological features of the sample to be tested (such as surface curvature and angular distribution) are first extracted from the original image to identify areas prone to reflection / highlight (such as convex parts of curved surfaces and angular edges). A grayscale threshold detection method is used for area identification: the threshold for reflecting areas is set to a grayscale value > 240 (the grayscale range of a typical RGB image is [0, 255], which can be adjusted according to the sample material), and the threshold for highlight areas is a local brightness value higher than 1.5 times the average brightness of the sample body. If a reflecting area is detected, a brightness equalization algorithm is used for grayscale correction, adjusting the grayscale value of the reflecting area to within ±5 of the average grayscale value of the sample body. If a highlight area is detected, a highlight suppression algorithm is used to reduce the brightness attenuation coefficient of that area (values ​​range from 0.3 to 0.5, with higher coefficients for higher reflectivity) to avoid color information loss due to overexposure. If no abnormalities are detected, the image remains unchanged to ensure targeted and accurate processing.

[0059] Step S12 is the geometric distortion detection and correction step, the core of which is to correct the image contour distortion caused by the shooting angle and sample shape, ensuring the authenticity of the sample's morphological features. Specifically, based on the morphological features extracted in step S11, a contour fitting deviation detection method is used: the sample contour in the original image is fitted and compared with a preset standard contour of the same shape. If the contour fitting deviation is >5 pixels (a conventional detection threshold, which can be adjusted according to the sample size), it is determined that there is geometric distortion. For different distortion types (such as perspective distortion and barrel distortion), corresponding correction algorithms are used: perspective distortion is corrected using a perspective transformation matrix (the matrix parameters are calibrated by more than 3 standard feature points), and barrel distortion is corrected using a polynomial correction algorithm (the correction coefficient ranges from -0.1 to 0.1). If no distortion is detected, the image remains unchanged to ensure that the sample's morphological features are consistent with reality, providing an accurate basis for the labeling of effective color measurement areas.

[0060] Step S13 involves segmenting the sample area from the background area and locating the main subject. The core of this step is to eliminate background interference, focus on the sample itself, and avoid background information affecting defect identification and color measurement area determination. Specifically, combining sample morphological features and color differences, a joint identification method of "contour extraction + color contrast analysis" is adopted: First, all contours in the original image are extracted using an edge detection algorithm, and contours with a matching degree > 0.8 with the morphological features of the sample to be tested are selected as candidate sample areas. Then, the color contrast between the candidate area and the surrounding area is calculated. If the contrast difference is > 30 (the sum of the RGB component differences, a conventional threshold), it is determined as the boundary between the sample area and the background area. Based on the boundary range, interference information in the background area (such as work surfaces, environmental clutter, etc.) is eliminated, retaining only the main sample area. The coordinate range of the main sample area is located using a contour bounding box (e.g., pixel coordinates x∈[100,800], y∈[50,600]), ensuring that subsequent processing is only for the sample itself.

[0061] Step S14 is the color normalization process, the core of which is to unify the image color standard and eliminate the inconsistency of color reference caused by differences in lighting and equipment, providing a unified reference for image matching and color value acquisition. Specifically, for the sample subject area located in step S13, the RGB component normalization algorithm is used: the R, G, and B components of each pixel in the subject area are divided by 255 respectively, normalized to the [0,1] interval; at the same time, color temperature calibration is performed to uniformly correct the image color temperature to the color temperature corresponding to the D65 standard light source (6500K), ensuring that the image colors under different acquisition scenarios are comparable; after normalization, the image to be tested is obtained, with a unified color reference, clear subject, and no basic acquisition defects, which can be directly used for matching in the color measurement defect standard database and defect identification process.

[0062] In one embodiment, step S20 involves image matching between the image to be tested and a pre-built colorimetric defect standard database, specifically including the following steps:

[0063] S211. Extract the morphological and material features of the image to be tested;

[0064] S212. Perform similarity matching between the morphological and material characteristics of the image to be tested and the reference groups of various irregular samples in the color measurement defect standard database, and select the target irregular sample reference groups whose morphological and material characteristics are more similar to the sample to be tested than the preset similarity threshold.

[0065] S213. Retrieve and determine an image analysis algorithm suitable for the current sample to be tested from the target irregular sample reference group.

[0066] In this embodiment, as described in steps S211-S213 above, the core is an image matching process that involves feature extraction → dual-dimensional feature similarity matching → targeted retrieval of adaptation algorithms. Addressing the problems of existing technologies where image matching relies solely on a single feature, resulting in low matching accuracy and lack of basis for adaptation algorithm selection, this embodiment uses "morphology + material" as the dual core features for matching. Relying on the structured reference group of the colorimetric defect standard database, it achieves accurate association between the sample to be tested and the database resources. This provides a highly adaptable and accurate image analysis algorithm for defect feature identification, ensuring the targeted and accurate nature of defect identification. Specifically, as follows:

[0067] Step S211 is the core feature extraction step for the image to be tested. The core of this step is to obtain key features that characterize the essential attributes of the sample, providing a unified and comparable feature basis for similarity matching. Specifically, a hierarchical feature extraction strategy is adopted:

[0068] Morphological feature extraction: Contour information of the sample in the image under test is extracted using contour detection algorithms (such as Canny edge detection), and the curvature distribution of the contour is calculated (e.g., curvature values ​​for curved surfaces range from 0.05 to 0.2). The curvature value of the corner parts is >0.5 Quantitative features such as key dimensions (e.g., the ratio of the longest axis to the shortest axis) and the coordinate distribution of concave and convex structures are used to form morphological feature vectors.

[0069] Material feature extraction: Texture analysis techniques (such as gray-level co-occurrence matrix) are used to extract texture feature parameters (such as contrast, correlation, and uniformity) of the sample surface. Combined with reflectivity detection (calculated by local gray-level value fluctuations, reflectivity > 0.7 is judged as high reflectivity material, and < 0.3 is judged as matte material), a material feature vector is formed.

[0070] Both types of feature vectors are standardized (values ​​are normalized to the [0,1] interval) to ensure consistency in feature matching.

[0071] Step S212 is the two-dimensional feature similarity matching and target reference group screening step. Its core is to establish a precise association between the sample to be tested and the database reference group, solving the problems of single matching criteria and unreliable screening results. Specifically:

[0072] Similarity matching algorithm: The cosine similarity algorithm of feature vectors is used to calculate the similarity between the morphological feature vector of the image to be tested and the morphological feature vectors of each reference group in the database. And the similarity between the material feature vector and the material feature vectors of each reference group. Final overall similarity (The influence of morphological features on defect type and acquisition interference is higher than that of material features, so the weight of morphological similarity is set to 0.6 and the weight of material similarity is set to 0.4).

[0073] Preset similarity threshold: The standard value is 0.8, which can be adjusted according to the matching accuracy requirements of industrial scenarios (the threshold can be set to 0.85 when high accuracy is required, and 0.75 when efficiency is also considered).

[0074] Target reference group selection: Traverse all irregular sample reference groups in the database and select the reference group with a comprehensive similarity S > 0.8 as the target irregular sample reference group; if there are multiple target reference groups (such as 3 reference groups with similarity of 0.82, 0.85, and 0.88), select the reference group with the highest comprehensive similarity as the core target reference group, and the rest as auxiliary reference groups to ensure the accuracy and redundancy of the matching results.

[0075] Step S213 is the adaptation image analysis algorithm retrieval step. The core is to match a dedicated recognition algorithm for the current sample to be tested, so as to solve the problem of low defect recognition accuracy caused by the generalization of algorithms. At the same time, it forms a closed loop with the algorithm association logic in the color measurement defect standard database construction stage. Specifically, during the construction of the colorimetric defect standard database, each irregularly shaped sample reference group has been pre-associated and stored with customized and optimized corresponding image analysis algorithms (i.e., the "pre-defined image analysis algorithm" mentioned above, which integrates grayscale difference analysis, contour fitting comparison, feature difference comparison and other adaptation analysis methods) based on its own shape, material characteristics and typical defect types. From the core target reference group selected in step S212, the pre-associated image analysis algorithm can be directly and synchronously retrieved. This algorithm is highly consistent with the features of the core target reference group and can accurately identify the potential defects of the sample to be tested. If there are multiple target reference groups and the algorithm of the core reference group has limitations in adapting to the local features of the sample (such as local special concave and convex structures), the image analysis logic module of the auxiliary reference group is integrated for supplementary optimization (such as supplementing local edge gradient detection logic). Finally, the image analysis algorithm that adapts to the full features of the current sample to be tested is determined, ensuring that the algorithm is completely matched with the shape, material characteristics and possible defect types of the sample to be tested, and providing reliable algorithmic support for the identification of defect features and defect locations.

[0076] In one embodiment, step S20 involves using a preset image analysis algorithm to identify the defect features and locations of the image under test, specifically including the following steps:

[0077] S221. Based on the determined image analysis algorithm adapted to the current sample to be tested, retrieve the standard image and defect image of the target irregular sample reference group that has the same morphological and material characteristics as the sample to be tested from the colorimetric defect standard database.

[0078] S222. Compare the image to be tested with the standard image and the defective image respectively, and extract the feature difference parameters between the image to be tested and the standard image and the defective image based on the feature comparison results.

[0079] S223. Based on the aforementioned feature difference parameters, and according to the defect feature mapping relationship in the color measurement defect standard database, match and determine the corresponding image acquisition defect and color measurement area deviation in the image to be tested;

[0080] S224. Based on the distribution position of the effective color measurement area marked by the feature difference parameters relative to the standard image in the target irregular sample reference group, locate the defect location of the defect feature in the image to be measured.

[0081] In this embodiment, as described in steps S221-S224 above, the core is a defect identification process that involves retrieving a reference image → comparing multi-dimensional image features → quantifying and extracting difference parameters → mapping and matching defect types → locating defect positions. Relying on the matched target irregularly shaped sample reference group and image analysis algorithms, this addresses the technical pain points of existing technologies, such as reliance on manual identification of irregularly shaped sample defects, ambiguous defect type determination, and inaccurate defect location. It achieves fully automatic and quantitative identification of image acquisition defects and color measurement area deviations, providing accurate defect type and location information for targeted defect correction in step S30, ensuring the accuracy and effectiveness of the correction operation. Specifically, as follows:

[0082] Step S221 is the reference image retrieval step, the core of which is to obtain a standard comparison image that is highly compatible with the sample to be tested, avoiding recognition errors caused by the mismatch between the comparison benchmark and the sample features. Specifically, based on the image analysis algorithm determined in step S213 and the target irregular sample reference group selected in step S212, the standard image (a benchmark image without acquisition defects and imaging specifications) and defect image (a comparison image containing various typical acquisition defects and regional deviations) within the reference group are retrieved simultaneously from the colorimetric defect standard database. Since the reference group and the sample to be tested have the same morphological and material characteristics, the consistency of the benchmark for subsequent image feature comparison can be guaranteed, reducing the probability of defect misidentification from the source.

[0083] Step S222 is the image feature comparison and difference parameter extraction stage. Its core is to transform the abnormal features of the image under test into quantified difference parameters, providing data support for defect type determination. Specifically, using the determined image analysis algorithm, methods such as grayscale difference analysis, contour fitting comparison, and feature difference comparison are employed to sequentially compare the image under test with the standard image and the defect image across the entire domain. The comparison dimensions include local brightness distribution, grayscale value fluctuation, contour gradient change, color measurement area position offset, and area size. Quantified feature difference parameters are extracted through comparison, such as grayscale difference in reflective areas, brightness attenuation in shadow areas, number of contour offset pixels, and color measurement area range deviation ratio. This transforms abstract image defects into calculable and comparable numerical parameters, achieving a quantitative representation of defect features.

[0084] Step S223 is the defect feature mapping and matching and type determination step. Its core is to automatically determine the defect type based on the difference parameters, solving the problems of ambiguous defect classification and strong subjectivity in manual judgment. Specifically, the extracted feature difference parameters are input into the defect feature mapping relationship table (Table 1) in the colorimetric defect standard database. Through the one-to-one correspondence between parameters and defect features, the defect type in the image to be tested is automatically matched and determined: if the difference parameters show excessively high local gray values ​​or overexposure, it is determined to be a reflective defect in image acquisition; if the difference parameters show a colorimetric area coordinate offset or the range includes the background, it is determined to be a positional offset or range abnormality in the colorimetric area deviation. Through the mapping relationship, various types of defects can be accurately distinguished, and the automatic determination of defect types can be completed without manual intervention.

[0085] Step S224 is the precise location of the defect. Its core is to clearly define the specific distribution area of ​​the defect in the image, providing coordinate basis for subsequent point-based defect correction. Specifically, using the effective color measurement area marked on the standard image within the target irregular sample reference group as the positioning benchmark, and combining the pixel distribution and area range of the feature difference parameters in the image to be measured, the specific location corresponding to the defect feature is determined: by calculating the horizontal and vertical pixel offsets of the difference parameters relative to the effective color measurement area, the boundary coordinates and center coordinates of the defect area are marked, clarifying whether the defect is located inside, at the edge, or outside the effective color measurement area, and simultaneously determining the size and range of the defect area; finally, the defect location is completed, ensuring that subsequent correction operations can be directly applied to the defect area without damaging the normal image area of ​​the sample.

[0086] In one embodiment, step S30 specifically includes the following steps:

[0087] S31. Using defect features and defect locations as indexes, and combining the morphological and material features of the sample to be tested, a defect correction strategy suitable for the current sample to be tested is matched from the target irregular sample reference group.

[0088] S32. Based on the defect correction strategy, perform defect correction on the corresponding defect area of ​​the image to be tested according to the defect location;

[0089] S33. Based on the effective color measurement area marked in the standard image of the target irregular sample reference group, and combined with the morphological characteristics of the sample to be tested, adaptively mark the effective color measurement area of ​​the corrected image to be tested, and obtain the corrected image marked with the effective color measurement area.

[0090] In this embodiment, as described in steps S31-S33 above, the core is an image correction process that uses defect information index matching → defect area pinpoint correction → effective color measurement area adaptive annotation. This addresses the technical pain points in color measurement of irregularly shaped samples, such as reliance on manual correction, low correction accuracy, and unreasonable color measurement area annotation. It leverages pre-stored defect correction strategies in the color measurement defect standard database to achieve targeted correction that precisely matches defect and sample characteristics, and automatically annotates the optimal effective color measurement area. This eliminates color measurement interference caused by image acquisition defects and color measurement area deviations, providing a defect-free, area-accurate corrected image for color value acquisition. Specifically, as follows:

[0091] Step S31 is the defect correction strategy matching stage. Its core is to match a specific correction scheme to the defect type and location of the current sample under test, ensuring the relevance and adaptability of the correction strategy. Specifically, using the defect features determined in step S223 and the defect locations located in step S224 as core indexes, and combining the morphological and material characteristics of the sample under test, a search and matching process is performed within the target irregular sample reference group selected in step S212. The database directly retrieves the defect correction strategies that are one-to-one bound to the defect features (such as brightness equalization and grayscale correction strategies for localized reflective defects, perspective calibration strategies for geometric distortion, and position calibration strategies for color measurement area offset). This strategy has already been specifically optimized during the database construction phase and is highly compatible with the sample's morphology, material, and defect type, eliminating the need for manual formulation of correction schemes.

[0092] Step S32 is the targeted correction step for defect areas. Its core is to perform point-to-point correction on the image according to the defect location, eliminating defects without damaging the image information of the normal sample area. Specifically, based on the defect correction strategy matched in step S31, and using the coordinates and range of the defect area located in step S224 as the execution target, correction is performed only on the local area where the defect is located: grayscale equalization correction is performed on reflective and highlight areas to adjust abnormal grayscale values ​​to the normal range of the sample body; brightness compensation and edge enhancement are performed on shadow and blurred contour areas; perspective transformation and contour calibration are performed on geometrically distorted areas; and position and range calibration are performed on color measurement area deviations. Point-to-point correction avoids color distortion caused by global image adjustment, preserving the true color and shape information of the sample to the greatest extent possible.

[0093] Step S33 is the adaptive annotation of the effective color measurement area. Its core is to automatically annotate the optimal color measurement area for irregularly shaped samples based on a standard benchmark, solving the problems of subjective nature and inappropriate area selection in manual annotation. Specifically, using the pre-annotated effective color measurement area of ​​the target irregularly shaped sample within the reference group's standard image as a benchmark, adaptive matching and adjustment are performed based on the actual contour and size ratio of the sample to be measured. The annotation range strictly adheres to the main contour of the sample, automatically avoiding unstable color measurement areas such as edge distortion and sharp corner shadows, ultimately forming an effective color measurement area that perfectly matches the shape of the sample to be measured. After annotation, a corrected image with the annotated effective color measurement area is obtained. This image has no acquisition defects, and the color measurement area is accurate and reasonable, and can be directly used for color value acquisition operations of the colorimeter.

[0094] In one embodiment, step S40 specifically includes the following steps:

[0095] S41. Match the corresponding parameter adjustment rules according to the defect characteristics, and adjust the acquisition parameters of the colorimeter based on the parameter adjustment rules;

[0096] S42. Using the colorimeter with adjusted parameters, adaptive point placement is performed based on the irregular shape of the effective color measurement area, and multi-point color value acquisition is performed on the effective color measurement area marked in the corrected image.

[0097] S43. Using outlier judgment rules that match the material characteristics of the sample to be tested, outliers are removed from all collected color value data, valid color value samples are retained, and the mean of the valid color value samples is calculated to obtain the original average color value of the sample to be tested.

[0098] In this embodiment, as described in steps S41-S43 above, the core is a precise color value acquisition process through adaptive adjustment of acquisition parameters → adaptive point acquisition in irregularly shaped color measurement areas → outlier removal and mean calculation based on material adaptation. This addresses the problems of distorted original color values ​​caused by the generalization of colorimeter parameters, unreasonable point acquisition, and failure to remove outlier data in existing technologies. By combining defect characteristics and material characteristics, the entire acquisition process is optimized to obtain stable and reliable color value data within the effective color measurement area, resulting in the original average color value after removing random errors and acquisition interference. This provides basic data for color error compensation, as detailed below:

[0099] Step S41 is the parameter matching and adjustment step. Its core is to adapt the corresponding parameter adjustment rules based on the defect characteristics, optimize the colorimeter's hardware operation, and avoid secondary color value deviations caused by parameter mismatch. Specifically, based on the image acquisition defects and color measurement area deviations determined in step S223, corresponding parameter adjustment rules are matched from the target irregular sample reference group. These rules are consistent with the defect feature mapping table in the color measurement defect standard database. For image acquisition defects, the exposure parameters, white balance parameters, and anti-reflective filtering parameters of the colorimeter's color value acquisition module are adaptively adjusted. For color measurement area deviations, the focus parameters, framing parameters, and area recognition sensitivity of the colorimeter's color value acquisition module are adaptively adjusted to match the colorimeter's acquisition parameters with the defect-corrected state of the sample under test, ensuring the stability of color value acquisition from a hardware perspective.

[0100] Step S42 involves adaptive point placement and multi-point color value acquisition in irregularly shaped regions. The core of this step is to flexibly place points to fit the irregular shape of the effective color measurement area, overcoming the problem of traditional uniform point placement being unsuitable for irregular samples. Specifically, based on the outline and morphological features of the effective color measurement area marked in the corrected image, an adaptive point placement strategy is adopted: for irregularly shaped areas such as curved surfaces and concave-convex areas, the number of acquisition points is increased in areas with large curvature changes and prone to color shifts; conventional acquisition points are reasonably placed in stable planar areas, avoiding unstable color measurement areas such as edges, corners, and structural gaps; using a colorimeter with adjusted parameters, color values ​​are acquired point-by-point at all placement locations to ensure that the acquisition points fully cover the effective color measurement area and accurately reflect the overall color distribution of the sample.

[0101] Step S43 involves outlier removal and mean calculation for material adaptation. Its core purpose is to eliminate random errors and abnormal interference during the data acquisition process, obtaining a representative original average color value. Specifically, outlier judgment rules are selected based on the material characteristics of the sample to be tested: for highly reflective materials (such as metal and paint) and semi-transparent materials (such as glass and transparent plastic), the quartile judgment rule is used to remove outlier data; for matte materials (such as plastic and fabric) and low-reflective materials (such as rubber and wood), the 3σ principle judgment rule is used to remove outlier data. After removing outlier color value samples that deviate from the normal range, the arithmetic mean of the remaining valid color value samples is calculated, and the calculation result is used as the original average color value of the sample to be tested, effectively reducing random errors in a single acquisition and improving the reliability of the basic color value data.

[0102] In one embodiment, the parameter adjustment rules include:

[0103] To address image acquisition defects, the adjustment of acquisition parameters should include at least one of the following: exposure parameters, white balance parameters, and anti-reflection filter parameters.

[0104] To address color measurement area deviation, the adjustment of acquisition parameters should include at least one of the following: focus parameters, framing range parameters, and area recognition sensitivity.

[0105] In this embodiment, the core is to establish a correspondence between "defect type - parameter category - adjustment logic," addressing the technical pain points of existing colorimeter parameter adjustments, such as lack of clear classification, lack of scenario-based adaptation, and ambiguous adjustment direction. It provides directly implementable parameter adjustment solutions for different defect types, ensuring a high degree of compatibility between the colorimeter's collected parameters and defect correction needs and sample characteristics. This guarantees the accuracy of color value acquisition from a hardware perspective, as detailed below:

[0106] (1) Parameter adjustment rules for image acquisition defects:

[0107] The core causes of image acquisition defects (such as reflections, highlights, shadows, and blurred outlines) are the mismatch between the acquisition lighting, equipment color calibration, anti-interference capabilities, and sample shape / material. Therefore, parameter adjustment should focus on "light optimization, color calibration, and anti-interference enhancement," with the specific rules as follows:

[0108] Exposure parameter adjustment: The core purpose is to solve the problem of color information loss caused by overexposure of reflective areas and underexposure of shadows. Specifically, if reflective areas or overexposure defects are detected (corresponding to item 1 in Table 1), the exposure parameters are reduced (the usual adjustment range is 0.6 to 0.8 times the original parameter; the higher the reflectivity of the material, the larger the adjustment range), to avoid color value distortion caused by overexposure. If shadow areas or underexposure defects are detected (corresponding to item 2 in Table 1), the exposure parameters are appropriately increased (the usual adjustment range is 1.2 to 1.5 times the original parameter), to compensate for the brightness attenuation in shadow areas and ensure complete acquisition of color information in these areas.

[0109] White balance parameter adjustment: The core purpose is to unify the color reference and solve the color deviation problem caused by differences in light color temperature and the reflective characteristics of the sample. Specifically, for reflection correction of highly reflective materials (corresponding to item 1 in Table 1) and color distortion in blurred outlines (corresponding to item 3 in Table 1), the white balance parameter is calibrated to the color temperature range (6500K±200K) corresponding to the D65 standard light source, or a custom white balance reference is defined according to the color characteristics of the sample material (e.g., calibrate to 5500K~6000K for warm-toned samples) to ensure the consistency of the color temperature between the collected color value and the true color of the sample.

[0110] Anti-reflective filter parameter adjustment: The core purpose is to suppress specular reflection and localized strong light reflection on the sample surface, specifically adapted to the reflective defects of highly reflective materials (such as metals, paint, and transparent materials) (corresponding to item 1 in Table 1). Specifically, the anti-reflective filter function of the colorimeter is activated, and the filter level is adjusted according to the reflective intensity (generally divided into 3 levels: level 1 for mild reflectivity, level 2 for moderate reflectivity, and level 3 for severe reflectivity). The filtering algorithm filters out excess reflected light, retains the diffuse color information of the sample itself, and avoids color value jumps caused by reflection.

[0111] (2) Parameter adjustment rules for colorimetric area deviation:

[0112] The core cause of colorimetric area deviation (such as area offset, range too large / too small, inclusion of background interference, etc.) is the mismatch between the colorimeter's field of view positioning, area recognition ability, and sample morphology. Therefore, parameter adjustment focuses on "precise positioning, range adaptation, and sensitive recognition," with the specific rules as follows:

[0113] Focus parameter adjustment: The core purpose is to ensure clear imaging of the effective color measurement area and resolve the area recognition deviation caused by focus blur (corresponding to items 5, 6, and 7 in Table 1). Specifically, if the color measurement area deviates from the sample body (corresponding to item 5 in Table 1), the focus parameters are finely adjusted (the focal length adjustment range is ±5%, applicable to standard-sized irregularly shaped samples; for ultra-large / ultra-small samples, the adjustment range can be ±10%, which can be conventionally selected by those skilled in the art according to actual needs, and is not limited here), so that the focus center of the colorimeter coincides with the color measurement area of ​​the sample body; if the color measurement area contains background interference (corresponding to item 6 in Table 1) or the range is too small (corresponding to item 7 in Table 1), the focus sharpness parameters are optimized to improve the edge differentiation between the sample area and the background area, providing a clear image basis for area recognition.

[0114] Viewing range parameter adjustment: The core purpose is to adapt to the contour shape of irregularly shaped samples and solve the problem of mismatch between the viewing range and the effective color measurement area. Specifically, if the color measurement area is too large (corresponding to item 6 in Table 1), the viewing range parameter is reduced (adjusted by 0.7 to 0.9 times the original range) to eliminate background interference areas; if the color measurement area is too small (corresponding to item 7 in Table 1), the viewing range parameter is expanded (adjusted by 1.1 to 1.3 times the original range) to ensure complete coverage of the effective color measurement area; if the color measurement area is offset (corresponding to item 5 in Table 1), the coordinates of the viewing center are shifted (adjusted synchronously according to the pixel offset of the defect position) to make the viewing range accurately aligned with the effective color measurement area.

[0115] Region recognition sensitivity adjustment: The core purpose is to improve the colorimeter's ability to recognize the contours of irregularly shaped samples, and to solve the problem of region misjudgment caused by insufficient recognition sensitivity (corresponding to items 6 and 7 in Table 1). Specifically, for irregularly shaped samples with complex contours (such as multi-curved composite shapes and irregular contours), the region recognition sensitivity should be increased (the normal adjustment range is 80-90%, and the higher the sensitivity, the more refined the contour recognition), ensuring that the colorimeter accurately distinguishes the main sample area from the background area; for irregularly shaped samples with simple contours (such as single curved surfaces and regular concave-convex shapes), the recognition sensitivity can be appropriately reduced (the normal adjustment range is 60-70%), balancing recognition efficiency and accuracy, and avoiding region fragmentation misjudgment caused by excessive sensitivity.

[0116] In one embodiment, step S50 involves using the color compensation algorithm to perform color compensation on the original average color value to obtain the target color value of the sample to be tested. This specifically includes the following steps:

[0117] S51. Based on the morphological and material features of the extracted corrected image, determine the color influence factor of the sample to be tested. The color influence factor includes at least one of the color deviation parameter corresponding to the diffuse reflection of the material, the surface reflection distribution, and the edge shadow offset.

[0118] S52. Retrieve the standard color values ​​corresponding to the standard images in the reference group of the target irregular sample, and calculate the inherent color deviation between the original average color value and the standard color value based on the color influence factor;

[0119] S53. Using the color compensation algorithm, set corresponding compensation weights for different parts of the morphological features of the sample to be tested, and perform corresponding compensation and correction on the inherent color deviation to obtain the target color value of the sample to be tested.

[0120] In this embodiment, as described in steps S51-S53 above, the core is a customized color compensation process that involves quantitative characterization of color influence factors → precise calculation of inherent color deviation → weighted compensation correction based on different parts. This addresses the technical pain points of existing technologies that use a unified algorithm for color compensation, ignore the differences in shape and material characteristics of irregularly shaped samples, resulting in low compensation accuracy and large deviations between color values ​​and true colors. By relying on the standard benchmark of the target irregularly shaped sample reference group and a dedicated color compensation algorithm, the entire process of "factor quantification → deviation calculation → precise compensation" is optimized. Ultimately, a target color value that closely matches the true color of the sample being tested is obtained, providing high-precision data support for industrial color measurement. Specifically, as follows:

[0121] Step S51 is the quantification and determination of color influence factors. Its core is to transform the influence of form and material on color into calculable quantitative parameters, providing data for deviation calculation. Specifically, based on the morphological features (such as surface curvature, edge distribution, and planar proportion) and material features (such as diffuse reflectance and reflectivity) extracted from the corrected image, three types of color influence factors are specifically determined:

[0122] The color cast parameter corresponding to the diffuse reflection of the material is calculated by the difference between the material's diffuse reflection coefficient and the standard diffuse reflection coefficient (usually taken as 0.5). The formula is: Color Cast Parameter = (sample diffuse reflectance coefficient - 0.5) × 100, with a value range of [-50, 50]. A positive value indicates a warmer color tone, while a negative value indicates a cooler color tone.

[0123] Reflection distribution on curved surfaces: Characterized by the proportion of the curved area to the effective colorimetric area, combined with reflectance calculation, the formula is: Reflection distribution =Surface area ratio × Sample reflectance, with a value range of [0,1]. The larger the value, the more significant the effect of reflection on color.

[0124] Corner Light and Shadow Offset: Calculated by the brightness difference between the corner area and the main body area of ​​the sample. The offset ΔL = average brightness of the corner area - average brightness of the main body area, with a value range of [-50, 50]. A negative ΔL indicates that the corner area is darker, and a positive ΔL indicates that it is brighter.

[0125] The three types of factors can be selected in one or more combinations according to the actual characteristics of the sample, so as to comprehensively characterize the inherent influence of form and material on color.

[0126] Step S52 is the inherent color deviation calculation step, the core of which is to quantify the difference between the original average color value and the standard color value, and to clarify the specific compensation range. Specifically:

[0127] Standard color value retrieval: From the target irregular sample reference group screened in step S212, simultaneously retrieve the standard color values ​​corresponding to the effective color measurement area of ​​the standard image (the RGB three-channel components are denoted as follows). , , );

[0128] Deviation calculation logic: Based on the color influence factor determined in step S51, the inherent color deviation is calculated using a weighted summation algorithm, as shown in the formula:

[0129] ΔR=( ×0.3+ ×0.5+ΔL×0.2)×( - ) / 255

[0130] ΔG=( ×0.3+ ×0.5+ΔL×0.2)×( - ) / 255

[0131] ΔB=( ×0.3+ ×0.5+ΔL×0.2)×( - ) / 255

[0132] in, , , The original average color value components obtained in step S43 are ΔR, ΔG, and ΔB, which are the inherent color deviations of the RGB three channels, respectively. This calculation logic integrates the weight ratio of color influence factors to ensure the accuracy of deviation quantification.

[0133] Step S53 is the part-specific weight compensation and target color value determination stage. Its core is to achieve precise, region-specific, and weighted compensation and correction based on the color characteristic differences of different parts of the irregularly shaped sample. Specifically:

[0134] Compensation weight settings: Based on the morphological characteristics of the sample to be tested, differentiated compensation weights are set for different parts (the compensation weights for each part are relative weights and can be set according to the differences in morphological characteristics), as shown in the following examples (not exhaustive):

[0135] Planar areas: Compensation weight 0.9~1.0 (high color stability, small compensation range);

[0136] Curved areas: compensation weight 1.0~1.1 (significant reflection effect, moderate compensation range);

[0137] Sharp corners: compensation weight 1.1~1.2 (significant light and shadow shift, compensation range slightly larger);

[0138] Compensation algorithm execution: The pre-associated color compensation algorithm of the target irregular sample reference group is invoked. The inherent color deviation is multiplied by the weight of the corresponding part to obtain the compensation amount for each part. The formula is as follows:

[0139] = -ΔR×Location Weight

[0140] = -ΔG×Location Weight

[0141] = -ΔB×Location Weight

[0142] Target color value output: The compensated color values ​​of each part are fused and optimized using the following formula:

[0143]

[0144]

[0145]

[0146] in, To determine the number of morphological types within the effective color measurement area, For the first Area of ​​each morphological part The total area of ​​the effective color measurement region, This is a traversal index used to sequentially refer to the first colorimetric unit within the valid colorimetric area. Each morphological part, among which... =1 corresponds to the planar region. =2 corresponds to the curved surface region. =3 corresponds to the angular area (other types of parts can also be included based on the actual morphological characteristics of the irregular sample).

[0147] Finally, the color values ​​of each part after compensation are weighted and fused using the above formula to obtain the target color value of the RGB three channels (value range [0,255]). This color value has eliminated the inherent color deviation caused by shape and material, accurately matches the true color of the sample to be tested, and realizes high-precision output of color measurement for irregularly shaped samples.

[0148] In one embodiment, an image analysis-based system for correcting color measurement defects and compensating errors in irregularly shaped samples is provided. This system corresponds to the image analysis-based method for correcting color measurement defects and compensating errors in irregularly shaped samples described in the previous embodiment. The image analysis-based system for correcting color measurement defects and compensating errors in irregularly shaped samples includes:

[0149] The image acquisition module is used to acquire the original image of the sample to be tested, and to preprocess the original image to obtain the image to be tested;

[0150] The image recognition module is used to match the image to be tested with a pre-constructed color measurement defect standard database, and to identify the defect features and defect locations of the image to be tested using a preset image analysis algorithm. The defect features include image acquisition defects and color measurement area deviations.

[0151] The image correction module is used to match the corresponding defect correction strategy in the colorimetric defect standard database based on defect features and defect locations, and to correct defects in the image to be tested according to the defect correction strategy and defect locations, so as to obtain a corrected image with effective colorimetric areas marked.

[0152] The color value acquisition module is used to adjust the acquisition parameters of the colorimeter according to the defect characteristics. The colorimeter with the acquisition parameters adjusted is used to acquire color values ​​of the effective color measurement area of ​​the corrected image, and the acquired color values ​​are averaged to obtain the original average color value.

[0153] The color compensation module is used to extract the core features of the corrected image, including morphological features, material features, and color features. The core features are associated with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. The color compensation algorithm is then used to perform color compensation on the original average color value to obtain the target color value of the sample to be tested.

[0154] Specific limitations regarding the image analysis-based system for colorimetric defect correction and error compensation for irregularly shaped samples can be found in the above description of the image analysis-based method for colorimetric defect correction and error compensation for irregularly shaped samples, and will not be repeated here. Each module in the aforementioned image analysis-based system for colorimetric defect correction and error compensation for irregularly shaped samples can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0155] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0156] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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 this application, and should all be included within the protection scope of this application.

Claims

1. A method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis, characterized in that, Includes the following steps: Acquire the original image of the sample to be tested, and preprocess the original image to obtain the image to be tested; The image to be tested is matched with a pre-constructed color measurement defect standard database, and a preset image analysis algorithm is used to identify the defect features and defect locations of the image to be tested. The defect features include image acquisition defects and color measurement area deviations. Based on the defect features and defect locations, the corresponding defect correction strategies in the color measurement defect standard database are matched. The defect correction strategies and defect locations are used to correct the defects in the image to be measured, resulting in a corrected image with marked effective color measurement areas. The acquisition parameters of the colorimeter are adjusted according to the defect characteristics. The colorimeter with the adjusted acquisition parameters is used to acquire color values ​​in the effective color measurement area of ​​the corrected image. The acquired color values ​​are then averaged to obtain the original average color value. The image core features of the corrected image are extracted. The image core features include morphological features, material features and color features. The image core features are associated with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. The color compensation algorithm is used to perform color compensation on the original average color value to obtain the target color value of the sample to be tested. The step of using the color compensation algorithm to perform color compensation on the original average color value to obtain the target color value of the sample to be tested specifically includes the following steps: Based on the morphological and material features of the extracted corrected image, the color influence factor of the sample to be tested is determined. The color influence factor includes at least one of the following: color deviation parameter corresponding to diffuse reflection of material, surface reflection distribution, and edge shadow offset. Retrieve the standard color values ​​corresponding to the standard images in the reference group of the target irregular sample, and calculate the inherent color deviation between the original average color value and the standard color value based on the color influence factor; Using the color compensation algorithm, corresponding compensation weights are set for different parts of the morphological features of the sample to be tested, and the inherent color deviation is compensated and corrected accordingly to obtain the target color value of the sample to be tested.

2. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 1, characterized in that, The construction of the pre-built colorimetric defect standard database specifically includes the following steps: Collect standard images and defect images of several irregularly shaped samples of different shapes, mark the effective color measurement area for each shape in the standard image, and record the standard color value corresponding to the effective color measurement area. Defect features corresponding to image acquisition defects and color measurement area deviations are extracted from defect images of each type of irregular sample. Adaptive defect correction strategies and parameter adjustment rules are matched for the extracted defect features, and a defect feature mapping relationship is established based on image acquisition defects and color measurement area deviations. Extract the core features of the standard image corresponding to each type of irregular sample, and match the appropriate color compensation algorithm based on the correlation between morphological features, material features and color features in the core image features. The standard images, defect images, effective color measurement areas, standard color values, defect features, defect feature mapping relationships, defect correction strategies, parameter adjustment rules, core image features, and color compensation algorithms corresponding to different shaped samples are integrated and stored together to form a color measurement defect standard database containing several reference groups of shaped samples with different shapes. Corresponding image analysis algorithms are associated with reference groups of shaped samples with different shapes.

3. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 1, characterized in that, The step of preprocessing the original image to obtain the image to be tested specifically includes the following steps: The morphological features of the original image of the sample to be tested are extracted, and the reflective and highlight areas of the original image are detected based on the morphological features. If a reflective area is detected, the reflective area is corrected. If a highlight area is detected, the highlight area is suppressed. If neither is detected, the original image remains unchanged. Based on the morphological features, the original image is captured and geometric distortion is detected; if geometric distortion is detected, geometric distortion correction is performed on the distorted area; if no geometric distortion is detected, the original image remains unchanged. Based on the morphological features, the irregular sample region and background region in the original image are identified, and the interference information in the background region is removed to locate the main region of the irregular sample. The main area of ​​the irregularly shaped sample is subjected to color normalization processing to obtain the image to be tested.

4. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 2, characterized in that, The step of matching the image to be tested with a pre-constructed colorimetric defect standard database specifically includes the following steps: Extract the morphological and material features of the image to be tested; The morphological and material characteristics of the image to be tested are matched with the reference groups of various irregular samples in the color measurement defect standard database. The target irregular sample reference group with the morphological and material characteristics of the image to be tested that are greater than the preset similarity threshold is selected. Image analysis algorithms adapted to the current sample to be tested are retrieved and determined from the target irregular sample reference group.

5. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 4, characterized in that, The step of identifying the defect features and defect locations of the image under test using a preset image analysis algorithm specifically includes the following steps: Based on the determined image analysis algorithm adapted to the current sample to be tested, the standard image and defect image of the target irregular sample reference group with the same morphological and material characteristics as the sample to be tested are retrieved from the colorimetric defect standard database. The image to be tested is compared with the standard image and the defective image respectively. Based on the feature comparison results, the feature difference parameters between the image to be tested and the standard image and the defective image are extracted. Based on the aforementioned feature difference parameters, and according to the defect feature mapping relationship in the color measurement defect standard database, the corresponding image acquisition defect and color measurement area deviation in the image to be tested are matched and determined. Based on the distribution of the effective color measurement area marked by the feature difference parameters relative to the standard image in the target irregular sample reference group, the defect location of the defect feature in the image to be measured is located.

6. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 5, characterized in that, The step of matching defect correction strategies from the colorimetric defect standard database based on defect features and defect locations, and then correcting defects in the image to be tested according to the defect correction strategies and defect locations to obtain a corrected image with marked effective colorimetric areas, specifically includes the following steps: Using defect features and defect locations as indexes, and combining the morphological and material characteristics of the sample to be tested, a defect correction strategy suitable for the current sample to be tested is matched from the target irregular sample reference group. Based on the aforementioned defect correction strategy, defect correction is performed on the corresponding defect area of ​​the image to be tested according to the defect location; Based on the effective color measurement area marked in the standard image of the target irregular sample reference group, and combined with the morphological characteristics of the sample to be tested, the effective color measurement area is adaptively marked on the corrected image to be tested, resulting in a corrected image marked with the effective color measurement area.

7. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 2, characterized in that, The steps of adjusting the acquisition parameters of the colorimeter according to the defect characteristics, using the colorimeter with adjusted acquisition parameters to acquire color values ​​of the effective color measurement area of ​​the corrected image, and averaging the acquired color values ​​to obtain the original average color value specifically include the following steps: Based on the defect characteristics, match the corresponding parameter adjustment rules, and adjust the acquisition parameters of the colorimeter based on the parameter adjustment rules; Using a colorimeter with adjusted parameters, adaptive point placement is performed based on the irregular shape of the effective color measurement area to collect color values ​​at multiple points in the effective color measurement area marked on the corrected image. An outlier judgment rule matching the material characteristics of the sample to be tested is adopted to remove outliers from all collected color value data, retain valid color value samples, and calculate the mean of the valid color value samples to obtain the original average color value of the sample to be tested.

8. The method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in claim 2, characterized in that, The parameter adjustment rules include: To address image acquisition defects, the adjustment of acquisition parameters should include at least one of the following: exposure parameters, white balance parameters, and anti-reflection filter parameters. To address color measurement area deviation, the adjustment of acquisition parameters should include at least one of the following: focus parameters, framing range parameters, and area recognition sensitivity.

9. A system for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis, used to implement the steps of the method for colorimetric defect correction and error compensation of irregularly shaped samples based on image analysis as described in any one of claims 1-8, characterized in that, include: The image acquisition module is used to acquire the original image of the sample to be tested, and to preprocess the original image to obtain the image to be tested; The image recognition module is used to match the image to be tested with a pre-constructed color measurement defect standard database, and to identify the defect features and defect locations of the image to be tested using a preset image analysis algorithm. The defect features include image acquisition defects and color measurement area deviations. The image correction module is used to match the corresponding defect correction strategy in the colorimetric defect standard database based on defect features and defect locations, and to correct defects in the image to be tested according to the defect correction strategy and defect locations, so as to obtain a corrected image with effective colorimetric areas marked. The color value acquisition module is used to adjust the acquisition parameters of the colorimeter according to the defect characteristics. The colorimeter with the acquisition parameters adjusted is used to acquire color values ​​of the effective color measurement area of ​​the corrected image, and the acquired color values ​​are averaged to obtain the original average color value. The color compensation module is used to extract the core features of the corrected image, including morphological features, material features, and color features. The core features are associated with the original average color value to match the corresponding color compensation algorithm in the color measurement defect standard database. The color compensation algorithm is then used to perform color compensation on the original average color value to obtain the target color value of the sample to be tested.