Intelligent grid segmentation and clipping method

By constructing a two-dimensional mesh topology and using an adaptive compensation method, the problem of insufficient geometric structure verification in color card detection is solved, achieving efficient and accurate identification and compensation of color card images, and improving the robustness and versatility of color card detection.

CN123118672APending Publication Date: 2026-11-17GUANGDONG WEIPU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611417336.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-14
Publication Date
2026-11-17

Smart Images

  • Figure CN123118672A_ABST
    Figure CN123118672A_ABST
Patent Text Reader

Abstract

This application discloses an intelligent grid segmentation and cropping method, relating to the field of visual image processing technology. The method includes: acquiring a color card image to be processed and segmenting it to obtain candidate regions of color blocks; constructing a two-dimensional grid topology relationship based on the centroid coordinates of each region and determining the grid baseline; distinguishing between perspective distortion and segmentation anomalies by combining grid position deviation, distance between adjacent regions, and contour shape deviation; for grid gaps, calculating the expected contour based on the boundary rules of adjacent regions and the grid baseline, determining and compensating for segmentation defects; for segmentation anomaly regions, determining segmentation defects based on the deviation between the color mean and the reference value; determining the cropping baseline coordinates based on the compensated contour and the corrected region; intelligently cropping the color card image using multiple thresholds; taking the cropping result where the number of qualified color blocks reaches a preset threshold as the final result; and outputting standardized color block regions. This invention is adaptable to the color card detection needs of different resolutions and different scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual image processing technology, specifically to an intelligent grid segmentation and cropping method. Background Technology

[0002] In automated color swatch identification scenarios in industries such as textiles, printing, and paint tinting, color swatch inspection is crucial. Color swatches typically consist of multiple regularly arranged color blocks used for color comparison and quality control; their accuracy directly impacts the efficiency of product quality management.

[0003] Existing technologies employ deep learning-based semantic segmentation models for region detection in color chart images. However, factors such as shooting angle, lighting variations, and background interference can lead to false positives or false negatives in the segmentation results. Existing technologies primarily rely on model confidence scores for filtering, lacking verification of the regularity of the detection results at the geometric structure level. This makes it difficult to effectively identify non-color block regions or abnormal segmentation regions. When color charts suffer from uneven color block sizes due to perspective distortion or missing color blocks due to partial occlusion, it is difficult to distinguish whether these situations are due to normal geometric changes caused by the shooting angle or regional defects caused by segmentation anomalies. It is also impossible to adaptively compensate for different types of anomalies. After detecting irregular regions, the main processing methods are direct removal or manual review. This can lead to adverse situations such as the accidental deletion of valid color blocks and the inability to complete missing color blocks, resulting in low color chart recognition integrity.

[0004] Therefore, it is necessary to design an intelligent mesh segmentation and pruning method that can verify the geometric consistency of the detection results and adaptively compensate for missing regions. Summary of the Invention

[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: an intelligent grid segmentation and clipping method, the method comprising the following steps:

[0006] The color chart image to be processed is acquired and segmented to obtain several candidate color block regions. A two-dimensional grid topology is constructed based on the centroid coordinates of each candidate color block region, the grid baseline is determined, and the grid position deviation of each candidate color block region is calculated.

[0007] Based on the relationship between the grid position deviation and the spacing between adjacent color block candidate regions, the contour shape deviation of each color block candidate region and its position offset in the grid topology are jointly evaluated to distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies.

[0008] For non-color block regions with missing positions in the grid topology, based on the boundary rules of adjacent color block candidate regions and the extension relationship of the grid baseline, the expected contour features of the missing positions are calculated, it is determined whether there is a segmentation gap, and contour compensation is performed on the regions determined to be segmentation gaps.

[0009] For candidate color blocks that are determined to be segmented abnormally, the boundary of the abnormal region is adaptively corrected based on the contour features of adjacent candidate color block regions in the grid topology relationship to generate a corrected color block region. The cropping reference coordinates are determined based on the corrected color block region and the region constructed by the contour compensation. The color card image is intelligently cropped using multiple thresholds. The cropping result with the number of qualified color blocks reaching a preset threshold is taken as the final result, and the standardized color block region is output.

[0010] Based on the above technical solution, the grid baseline is determined, and the grid position deviation of each color block candidate area is calculated, including:

[0011] The candidate adjacency relationship is determined for the candidate color block regions according to the centroid coordinates. Based on the centroid displacement between adjacent candidate color block regions in the same row and column, the row displacement relationship and column displacement relationship are generated respectively. The stable grid relationship is determined according to the continuity between the row displacement relationship and the column displacement relationship.

[0012] The candidate regions of color blocks that satisfy the stable grid relationship are determined as grid reference regions, and the adjacency relationship between the grid reference regions constitutes the two-dimensional grid topology relationship.

[0013] A mesh skeleton is constructed based on the row and column displacement relationships corresponding to the mesh reference region. A row baseline is generated by linear fitting of the row displacement relationship in the mesh skeleton, and a column baseline is generated by linear fitting of the column displacement relationship in the mesh skeleton. The row baseline and the column baseline constitute the mesh baseline.

[0014] Based on the grid skeleton, the position of each candidate color block region is predicted along the row and column directions respectively to obtain the predicted grid position corresponding to each candidate color block region. The offset distance between the actual centroid coordinates of each candidate color block region and the predicted grid position is calculated, and the offset distance constitutes the grid position deviation.

[0015] Based on the above technical solution, the distinction between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies includes:

[0016] Based on the grid topology, the center distance between each color block candidate region and its adjacent color block candidate regions is extracted. The adjacent distance sequence in the same row and the same column is calculated. The first-order difference of the adjacent distance sequence is used to obtain the distance change gradient. When the distance change gradient is monotonic, a perspective deformation mark is generated.

[0017] Extract the contour boundaries of each candidate region of color blocks, detect the pairs of break points on the contour boundaries and calculate the gap distance. When the gap distance is less than a preset threshold, virtually connect the pairs of break points to form a corrected contour. Use the ratio of the area of ​​the corrected contour to the area of ​​the corrected convex hull as the contour integrity. Mark the candidate regions of color blocks with contour integrity lower than the benchmark value as abnormal shape regions.

[0018] Determine whether the candidate color block region marked as the shape abnormality region also has the perspective distortion mark. If it has the perspective distortion mark and the grid position deviation conforms to the extension direction of the spacing change gradient, it is determined to be a geometric change caused by perspective distortion; otherwise, it is determined to be a regional defect caused by segmentation abnormality.

[0019] Based on the above technical solution, and based on the boundary rules of adjacent color block candidate regions and the extension relationship of the grid baseline, the expected contour features of the missing position are calculated, including:

[0020] Traverse each grid node in the grid topology relationship, identify grid nodes that lack corresponding color block candidate areas as empty nodes, and determine the empty positions corresponding to the empty nodes;

[0021] Extract the adjacent color block candidate regions in the row and column directions of the missing position, obtain the boundary contours of the adjacent color block candidate regions facing the missing position, extract the boundary direction vector and boundary length of the boundary contours, and use the boundary direction vector and boundary length as boundary rules;

[0022] Based on the grid baseline, determine the row baseline and column baseline corresponding to the missing position, extend along the row baseline and column baseline to the missing position to form a predicted bounding box, and adjust each side of the predicted bounding box in combination with the boundary rules;

[0023] The edges of the adjusted predicted bounding box and the boundary contours of the adjacent color block candidate regions are extended to the vacancy position to form overlapping regions. The fitting deviation between each extended boundary and the grid baseline is calculated within the overlapping region. The extended boundary with the smallest fitting deviation is selected and combined to generate the expected contour feature of the vacancy position.

[0024] Based on the above technical solution, it is determined whether there are missing segments, and contour compensation is performed on the regions determined to have missing segments, including:

[0025] Pixel features are extracted from the region corresponding to the expected contour features of the missing position in the original image, the color mean within the region is calculated, and a mapping relationship between the centroid coordinates and the color mean is established based on the grid reference region.

[0026] Based on the centroid coordinates of the missing position, the corresponding reference color value is queried in the mapping relationship. The average color value in the region is compared with the reference color value. When the color difference between the average color value in the region and the reference color value meets the color block characteristics, it is determined to be a segmentation missing.

[0027] Contour compensation is performed to construct the regions identified as having missing segments.

[0028] According to the above technical solution, contour compensation is performed on the regions determined to be missing segments, including:

[0029] Obtain the boundary coordinates of the expected contour feature, perform edge detection within the boundary coordinate range, identify the actual edge points within the region, and match the actual edge points with the boundary coordinates of the expected contour feature;

[0030] When the offset distance between the actual edge point and the boundary coordinate is less than a preset range, the actual edge point is retained. When the actual edge point is missing, the boundary coordinate is used as a substitute. The retained actual edge point and the substitute boundary coordinate are sequentially connected to form a compensation contour, and the area corresponding to the compensation contour is added to the color block candidate area set.

[0031] According to the above technical solution, the boundary of the abnormal region is adaptively corrected based on the contour features of adjacent color block candidate regions in the grid topology relationship to generate the corrected color block region, including:

[0032] Extract candidate regions of color blocks that are determined to be regional defects caused by segmentation anomalies, obtain the adjacent candidate regions of color blocks in the mesh topology, extract the contour boundaries of the adjacent candidate regions and calculate the curvature distribution features;

[0033] Calculate the centroid displacement vector between the candidate color block region and each of the adjacent candidate color block regions. Based on the consistency between the centroid displacement vector and the spacing change gradient, perform perspective correction on the curvature distribution feature to obtain the corrected reference curvature distribution and generate reference contour features.

[0034] Abnormal curvature points on the contour boundary of the candidate color block region are detected. When the curvature value of the abnormal curvature point deviates from the reference contour feature, the abnormal curvature point and its neighborhood are marked as a boundary segment to be corrected. The pixel gradient information corresponding to the boundary segment to be corrected in the original image is extracted. Candidate boundary points are searched along the pixel gradient direction. The candidate boundary point that matches the curvature of the reference contour feature is selected to replace the boundary segment to be corrected, forming a corrected contour. The region corresponding to the corrected contour is used as the corrected color block region.

[0035] According to the above technical solution, the color card image is intelligently cropped using multiple thresholds. The cropping result where the number of qualified color blocks reaches a preset threshold is taken as the final result, and a standardized color block region is output, including:

[0036] The corrected color block region and the region corresponding to the compensated contour are merged into the color block candidate region set. Each color block candidate region in the color block candidate region set is traversed, and the coordinates of the circumscribed rectangle vertices of each color block candidate region are extracted.

[0037] The coordinates of the vertices of each bounding rectangle are sorted in the row and column directions respectively. The minimum and maximum ordinates in the row direction and the minimum and maximum abscissas in the column direction are selected. The minimum, maximum, minimum, and maximum ordinates are projected onto the corresponding grid reference lines respectively. An adaptive envelope boundary is constructed based on the projected coordinates. The initial clipping reference coordinates are determined based on the adaptive envelope boundary.

[0038] Multiple different detection threshold parameters are set, and the color card image is cropped according to the initial cropping reference coordinates for each detection threshold parameter, and the color block qualification is detected. The number of qualified color blocks in each cropping result is counted.

[0039] The cropping result where the number of qualified color blocks reaches a preset threshold is determined as the final cropping result, and a standardized color block area is output based on the boundary of the final cropping result.

[0040] According to the above technical solution, the standardized color block region is output based on the boundary of the final cropping result, including: obtaining the adaptive envelope boundary corresponding to the final cropping result; calculating the boundary extension distance based on the average side length of the grid reference region; extending each side of the adaptive envelope boundary along the outer side of the boundary extension distance to form an extended cropping boundary box; extracting the coordinates of the four corner points of the cropping boundary box as cropping reference coordinates; cropping the corresponding region in the color chart image according to the cropping reference coordinates; and outputting the standardized color block region.

[0041] A second aspect of this application provides an intelligent grid segmentation and cropping system, the system comprising:

[0042] The topology confirmation module is used to acquire the color card image to be processed, segment it to obtain several candidate color block regions, construct a two-dimensional grid topology relationship based on the centroid coordinates of each candidate color block region, determine the grid baseline, and calculate the grid position deviation of each candidate color block region.

[0043] The offset evaluation module is used to jointly evaluate the contour shape deviation of each color block candidate region and its position offset in the grid topology based on the spacing relationship between the grid position deviation and the adjacent color block candidate regions, and to distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies.

[0044] The contour compensation module is used to calculate the expected contour features of the missing non-color block regions in the mesh topology based on the boundary rules of adjacent color block candidate regions and the extension relationship of the mesh baseline, determine whether there is a segmentation missing, and construct contour compensation for the regions determined to be segmentation missing.

[0045] The correction output module is used to adaptively correct the boundary of the abnormal region based on the contour features of the adjacent color block candidate regions in the grid topology for the color block candidate regions determined to be segmented abnormally, generate the corrected color block region, determine the cropping reference coordinates based on the corrected color block region and the region constructed by the contour compensation, intelligently crop the color card image using multiple thresholds, and take the cropping result with the number of qualified color blocks reaching the preset threshold as the final result, and output the standardized color block region.

[0046] Compared with existing technologies, the beneficial effects achieved by this invention are as follows: This invention performs connectivity analysis and topological relationship construction on candidate color block regions, establishing a gridded spatial positional relationship. It can verify the regularity of detection results from a geometric structure level. Compared with existing technologies that rely solely on model confidence scores for filtering, this invention adds a geometric consistency dimension, forming a "semantic + geometric" dual verification mechanism, effectively improving the accuracy of color block region detection. It extracts the center distance between candidate color block regions and calculates the gradient of distance changes. Combined with contour integrity analysis, it can distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies, solving the problem that existing technologies cannot identify anomaly types. It achieves accurate judgment of different anomaly situations, avoiding misjudging normal perspective distortion as segmentation anomalies and incorrectly removing valid color blocks. For non-color block regions with missing positions in the grid topology, it uses boundary rules of adjacent candidate color block regions and grid baselines... This invention extends the relationship to calculate the expected contour features and determines segmentation defects by establishing a mapping relationship between the centroid coordinates and the color mean. Compared with the existing technology that directly removes irregular areas, this invention can adaptively compensate for missing color block areas, improving the completeness of color card recognition. For candidate color block areas determined to be segmented abnormally, reference contour features are generated after perspective correction based on the contour features of adjacent candidate color block areas, and boundary correction is performed by searching the pixel gradient direction. Compared with the existing technology that uses a manual review processing mode, this invention realizes the automatic correction of abnormal areas, improving the accuracy and processing efficiency of color block contours. Using the average area of ​​the detection result itself as the grid reference area feature, and using relative deviation rather than absolute deviation for geometric consistency judgment, the algorithm is adaptive to the scaling of the color card in the image and different shooting distances. It does not require a preset standard size of color blocks, adapts to the color card detection needs of different resolutions and different scenes, and improves the robustness and versatility of the algorithm. Attached Figure Description

[0047] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0048] Figure 1 This is a flowchart of the steps of the intelligent grid segmentation and cropping method provided according to the embodiments of this application.

[0049] Figure 2 This is a schematic diagram of the module composition of the intelligent grid segmentation and cropping system provided according to the embodiments of this application. Detailed Implementation

[0050] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0051] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0053] Please see Figure 1 The present invention provides a technical solution: an intelligent grid segmentation and clipping method, comprising:

[0054] The color chart image to be processed is acquired and segmented to obtain several candidate color block regions. A two-dimensional grid topology is constructed based on the centroid coordinates of each candidate color block region, the grid baseline is determined, and the grid position deviation of each candidate color block region is calculated.

[0055] Based on the relationship between the grid position deviation and the spacing between adjacent color block candidate regions, the contour shape deviation of each color block candidate region and its position offset in the grid topology are jointly evaluated to distinguish the geometric changes caused by perspective distortion and the regional defects caused by segmentation anomalies.

[0056] For non-color block regions with missing positions in the grid topology, the expected contour features of the missing positions are calculated based on the boundary rules of adjacent color block candidate regions and the extension relationship of the grid baseline. It is then determined whether there is any segmentation missing, and contour compensation is performed on the regions determined to be segmentation missing.

[0057] For candidate color blocks that are identified as segmentation anomalies, the boundary of the anomaly region is adaptively corrected based on the contour features of adjacent candidate color block regions in the grid topology relationship, generating a corrected color block region. The cropping reference coordinates are determined based on the corrected color block region and the region constructed by contour compensation. The color card image is intelligently cropped using multiple thresholds. The cropping result with the number of qualified color blocks reaching the preset threshold is taken as the final result, and the standardized color block region is output.

[0058] In some preferred embodiments, a grid baseline is determined, and the grid position deviation of each color patch candidate region is calculated, including:

[0059] For several candidate color block regions, the candidate adjacency relationship is determined according to the centroid coordinates. Based on the centroid displacement between adjacent candidate color block regions in the same row and column, the row displacement relationship and column displacement relationship are generated respectively. The stable grid relationship is determined according to the continuity between the row displacement relationship and the column displacement relationship.

[0060] Candidate regions of color blocks that satisfy stable grid relationships are determined as grid reference regions, and the adjacency relationships between grid reference regions constitute two-dimensional grid topology relationships.

[0061] A mesh skeleton is constructed based on the row and column displacement relationships corresponding to the mesh reference region. The row displacement relationship in the mesh skeleton is linearly fitted to generate the row reference line, and the column displacement relationship in the mesh skeleton is linearly fitted to generate the column reference line. The row reference line and the column reference line constitute the mesh reference line.

[0062] Based on the grid skeleton, the position of each candidate color block is predicted along the row and column directions respectively, and the predicted grid position corresponding to each candidate color block is obtained. The offset distance between the actual centroid coordinates of each candidate color block and the predicted grid position is calculated, and the offset distance constitutes the grid position deviation.

[0063] For example, the centroid coordinates of several candidate color blocks are obtained, and the candidate adjacency relationships between each candidate color block are determined based on the relative positions of the centroid coordinates in the row and column directions. For adjacent candidate color blocks in the same row, the displacement vector of their centroid coordinates in the row direction is calculated to form a row displacement relationship; for adjacent candidate color blocks in the same column, the displacement vector of their centroid coordinates in the column direction is calculated to form a column displacement relationship. Since the color blocks in the standard color chart are arranged in a regular grid, the spacing between adjacent color blocks should remain continuously changing. Therefore, a continuity analysis is performed on the row and column displacement relationships, and adjacent relationships with a displacement vector change rate lower than a set threshold are extracted as stable grid relationships. This threshold is set to 0.15-0.25, preferably 0.2. This threshold is used to measure the consistency of the spacing between adjacent color blocks. The smaller the value, the stricter the requirement for grid regularity. When the displacement vector change rate is lower than this threshold, it indicates that the spacing between adjacent color blocks changes gently, which conforms to the arrangement characteristics of the standard color chart.

[0064] Candidate color patch regions that satisfy stable grid relationships are identified as grid reference regions. The spatial adjacency of these grid reference regions constitutes the two-dimensional grid topology. Each grid reference region represents a set of geometrically stable and regularly arranged color patches in the color chart, and its topological relationship reflects the overall grid structure of the color chart. A grid skeleton is constructed based on the row and column displacement relationships corresponding to the grid reference regions. This skeleton consists of multiple displacement vectors connecting the centroids of adjacent grid reference regions, embodying the basic geometric framework of the color chart.

[0065] Linear fitting is performed on the row displacement relationships in the mesh skeleton to obtain several row baselines. Each row baseline corresponds to the centroid line connecting the color patches in a row of the color chart. Similarly, linear fitting is performed on the column displacement relationships in the mesh skeleton to obtain several column baselines. Each column baseline corresponds to the centroid line connecting the color patches in a column of the color chart. The row and column baselines together constitute the mesh baseline, which describes the overall mesh skeleton structure of the color chart. Using linear fitting instead of directly connecting the centroids reduces the impact of individual color patch positional shifts on the overall mesh structure determination, thus improving the stability of the mesh baseline.

[0066] The position of each candidate color patch is predicted along the row and column directions of the grid skeleton. Specifically, for each candidate color patch, its row and column indices in the grid topology are first determined. The predicted grid position of the candidate color patch is determined based on the coordinates of the intersection of the row baseline corresponding to the row index and the column baseline corresponding to the column index. This predicted grid position represents the centroid coordinates where the color patch should be located under the ideal grid structure. The Euclidean distance between the actual centroid coordinates of each candidate color patch and its corresponding predicted grid position is calculated; this distance is the grid position deviation. The grid position deviation reflects the degree of offset of the candidate color patch relative to the ideal grid position. When the grid position deviation exceeds a set threshold, it indicates that the candidate color patch may have segmentation anomalies or positioning errors. This threshold is determined based on the average side length of the grid reference area, set to 0.3-0.5 times the average side length, preferably 0.4 times. This setting allows the threshold to adapt to the size of the color card in the image, allowing for larger position deviations for larger color cards and requiring higher positioning accuracy for smaller color cards.

[0067] Through the above processing, a color block position evaluation system based on the grid baseline was established, which can identify abnormal color block candidate regions whose positions deviate from the grid structure, providing a geometric basis for subsequent segmentation anomaly judgment and region correction.

[0068] In some preferred embodiments, distinguishing between geometrical changes caused by perspective distortion and regional defects caused by segmentation anomalies includes:

[0069] Based on the grid topology, the center distance between each color block candidate region and its adjacent color block candidate regions is extracted. The adjacent distance sequence in the same row and the same column is calculated. The first difference of the adjacent distance sequence is used to obtain the distance change gradient. When the distance change gradient is monotonic, perspective deformation mark is generated.

[0070] Extract the contour boundaries of each candidate region of color blocks, detect the break point pairs on the contour boundaries and calculate the gap distance. When the gap distance is less than a preset threshold, virtually connect the break point pairs to form a corrected contour. Use the ratio of the area of ​​the corrected contour to the area of ​​the corrected convex hull as the contour integrity. Mark the candidate regions of color blocks with contour integrity lower than the benchmark value as abnormal shape regions.

[0071] Determine whether the candidate color block region marked as a shape abnormality area also has a perspective distortion mark. If it has a perspective distortion mark and the mesh position deviation conforms to the extension direction of the spacing change gradient, it is determined to be a geometric change caused by perspective distortion; otherwise, it is determined to be a regional defect caused by segmentation abnormality.

[0072] For example, based on the established grid topology, the center-to-center distance between each candidate color patch and its adjacent candidate color patches is extracted. For adjacent candidate color patches within the same row, the Euclidean distance between their centroid coordinates is extracted from left to right, forming an intra-row adjacent distance sequence; for adjacent candidate color patches within the same column, the Euclidean distance between their centroid coordinates is extracted from top to bottom, forming an intra-column adjacent distance sequence. First-order differencing is performed on both the intra-row and intra-column adjacent distance sequences to obtain the distance variation gradient. The first-order differencing is obtained by calculating the difference between adjacent elements in the adjacent distance sequence, reflecting the changing trend of the color patch spacing. When the color card experiences perspective distortion due to the shooting angle, due to the geometric characteristics of perspective projection, the spacing of color patches farther from the lens will gradually decrease or increase, causing the spacing variation gradient to exhibit a monotonically increasing or monotonically decreasing characteristic. To determine whether the spacing variation gradient exhibits monotonicity, if more than 70% of the consecutive data points in the intra-row or intra-column spacing variation gradient maintain the same sign, a perspective distortion marker is generated for the candidate color patch in that row or column. The 70% threshold is used to determine the degree of monotonicity continuity. The setting range is 60%-80%, preferably 70%. If the value is too low, local fluctuations will be misjudged as perspective distortion. If the value is too high, the true perspective distortion with slight spacing jitter may be missed.

[0073] The contour boundaries of each candidate color block region are extracted, and a contour tracking algorithm is used to obtain the pixel sequence of the contour boundaries. Breakpoint pairs on the contour boundaries are detected. A breakpoint pair is a location where the distance between adjacent pixels on the contour boundary exceeds the normal pixel spacing of a continuous contour, indicating a gap in the contour. The gap distance between each breakpoint pair is calculated. When the gap distance is less than a preset threshold, it indicates that the break is due to a small-scale discontinuity caused by inaccurate edge processing of the color block by the segmentation model, rather than a shape defect in the color block itself. Therefore, a virtual connection is made for the breakpoint pair, using a straight line segment to connect the two endpoints of the breakpoint pair to form a corrected contour. This gap distance threshold is set to 5-15 pixels, preferably 10 pixels. This threshold is used to distinguish between repairable contour breaks and real shape defects. Breaks with too small a gap can be corrected through virtual connection, while gaps with too large a gap indicate a substantial shape anomaly in the region. The area of ​​the corrected contour and the area of ​​the corresponding convex hull are calculated. The ratio of the corrected contour area to the corrected convex hull area is used as the contour integrity, reflecting the regularity of the color block shape. A standard rectangular color block has an outline integrity score close to 1. When there are depressions, gaps, or irregular protrusions at the edges of the color block, the outline integrity score will be significantly reduced. The baseline value for outline integrity score is set to 0.85-0.92, preferably 0.90. This baseline value is used to determine whether the shape of the color block is regular. When the outline integrity score is lower than this baseline value, the candidate area of ​​the color block is marked as a shape abnormality area.

[0074] The system determines whether candidate color blocks marked as shape anomalies also possess perspective distortion markers. If a candidate color block possesses a perspective distortion marker, it indicates that the spacing between color blocks in its row or column exhibits perspective distortion characteristics. Further checks are conducted to ensure that the grid position deviation direction of the candidate color block matches the extension direction of the spacing variation gradient. The extension direction of the spacing variation gradient is determined by analyzing the spacing change trend of the row or column. If the spacing decreases, the extension direction points towards the direction of decreasing spacing; if the spacing increases, the extension direction points towards the direction of increasing spacing. The system calculates the offset vector of the actual centroid coordinates of the candidate color block relative to the predicted grid position. The angle between this offset vector and the extension direction of the spacing variation gradient is determined. When the angle is <30°, the grid position deviation is considered to conform to the extension direction of the spacing variation gradient, and the shape anomaly is determined to be a geometric change caused by perspective distortion. This 30° angle threshold is used to determine the consistency of the offset direction, with a setting range of 20-40°, preferably 30°. This threshold ensures that only when the color block position offset is highly consistent with the perspective distortion direction is it considered a normal perspective change, avoiding misjudging actual segmentation anomalies as perspective distortion. If the candidate area of ​​the color block does not have a perspective distortion mark, or although it has a perspective distortion mark, the direction of the grid position deviation is inconsistent with the direction of the gradient extension of the spacing change, then the shape abnormality is determined to be a regional defect caused by the segmentation abnormality, and the region needs to undergo subsequent contour correction processing.

[0075] By using the joint judgment mechanism based on the monotonicity of the spacing gradient and the integrity of the contour, the perspective distortion and segmentation anomaly can be accurately distinguished. This avoids misjudging normal perspective geometric changes as segmentation errors and incorrectly removing valid color blocks. At the same time, it can accurately identify the segmentation anomaly areas that really need to be corrected, providing a reliable basis for subsequent adaptive compensation and contour correction.

[0076] In some preferred embodiments, based on the boundary rules of adjacent color block candidate regions and the extension relationship of grid baselines, the expected contour features of the missing positions are calculated, including:

[0077] Traverse each grid node in the grid topology, identify grid nodes that lack corresponding color block candidate areas as empty nodes, and determine the empty positions corresponding to the empty nodes.

[0078] Extract the adjacent color block candidate regions in the row and column directions of the missing position, obtain the boundary contours of the adjacent color block candidate regions facing the missing position, extract the boundary direction vector and boundary length of the boundary contours, and use the boundary direction vector and boundary length as boundary rules;

[0079] Based on the grid baseline, determine the row baseline and column baseline corresponding to the missing position. Extend along the row baseline and column baseline to the missing position to form the predicted bounding box. Adjust each side of the predicted bounding box in combination with the boundary rules.

[0080] The edges of the adjusted predicted bounding box and the boundary contours of the adjacent color block candidate regions are extended to the empty positions to form overlapping areas. The fitting deviation between each extended boundary and the grid baseline is calculated within the overlapping areas. The extended boundary with the smallest fitting deviation is selected and combined to generate the expected contour features of the empty positions.

[0081] For example, the process iterates through each grid node in the established grid topology, checking if each node has a corresponding candidate color patch region. Grid nodes are determined by the intersection of grid baselines; ideally, each grid node should correspond to one candidate color patch region. Grid nodes lacking corresponding candidate color patch regions are identified as missing nodes, and their projection positions in the color chart image are the missing locations. Missing nodes are typically caused by the segmentation model missing a color patch at that location or by the color patch at that location being too close to the background color, leading to segmentation failure. Identifying missing nodes allows for the location of color patches that need compensation.

[0082] Extract candidate regions of adjacent color blocks in the row and column directions for the missing position. Based on the grid topology, the adjacent nodes of the missing node in the row direction correspond to the candidate regions of adjacent color blocks to the left and right, and the adjacent nodes in the column direction correspond to the candidate regions of adjacent color blocks to the top and bottom. Obtain the boundary contours of each candidate region of adjacent color blocks facing the missing position. For the candidate region of adjacent color blocks to the left, extract its right boundary contour; for the candidate region of adjacent color blocks to the right, extract its left boundary contour; for the candidate region of adjacent color blocks to the top, extract its bottom boundary contour; and for the candidate region of adjacent color blocks to the bottom, extract its top boundary contour. Extract the boundary direction vector of each boundary contour. This direction vector is obtained by linearly fitting the pixel sequence of the boundary contour, reflecting the extension direction of the boundary. Calculate the boundary length of each boundary contour, which is equal to the distance between the start and end points of the boundary contour. Use the boundary direction vector and boundary length as boundary rules. The boundary rules describe the geometric relationship between adjacent color blocks and the missing position, providing a reference for predicting the contour of the missing color block.

[0083] The row and column baselines corresponding to the missing locations are determined based on the grid baselines. The intersection of the row baseline corresponding to the row index and the column baseline corresponding to the column index of the missing node in the grid topology is the theoretical location of the missing node. Extending left and right along the row baselines, the extension distance is determined based on the average width of the adjacent candidate color blocks within that row, set to 0.4-0.6 times the average width, preferably 0.5 times. This extension distance is used to determine the left and right boundaries of the predicted bounding box in the row direction; setting it to half the average width ensures that the width of the predicted bounding box is consistent with that of adjacent color blocks. Extending up and down along the column baselines, the extension distance is determined based on the average height of the adjacent candidate color blocks within that column, set to 0.4-0.6 times the average height, preferably 0.5 times. This extension distance is used to determine the upper and lower boundaries of the predicted bounding box in the column direction. The rectangular area formed by the above extensions is the predicted bounding box, which provides a preliminary estimate of the location and size of the missing color block.

[0084] The edges of the predicted bounding box are adjusted using boundary rules. For the left boundary of the predicted bounding box, the right boundary contour of the adjacent candidate color block region on the left is checked. If the angle between the boundary direction vector of this contour and the column baseline is less than 15°, the boundary is considered to be approximately perpendicular to the row direction. The left boundary of the predicted bounding box is then adjusted to align with this contour by shifting the left boundary to the right until its x-coordinate is equal to the right endpoint of the right boundary contour of the adjacent color block on the left. This 15° angle threshold is used to determine whether the boundary is consistent with the grid direction. The setting range is 10°-20°, preferably 15°. An angle that is too small will result in overly strict requirements on the boundary direction, missing effective adjustment opportunities. An angle that is too large may misjudge a slanted boundary as a regular boundary. Similar processing is performed on the right, top, and bottom boundaries of the predicted bounding box, adjusting them according to the corresponding boundary contours of the adjacent candidate color block regions on the right, top, and bottom sides.

[0085] The edges of the adjusted predicted bounding box and the boundary contours of adjacent color block candidate regions are extended to the empty positions to form overlapping regions. For the left boundary, the left boundary of the predicted bounding box is extended to the right by 0.2 times the width of the predicted bounding box, and the right boundary contour of the adjacent color block on the left is extended to the right by the same distance. The two extended boundaries form overlapping regions in the row direction. This 0.2 times extension ratio is used to ensure that the extended boundaries can cover the effective range of the empty positions. The range is set to 0.15-0.25, preferably 0.2. If the extension distance is too small, the overlapping region will be insufficient for effective comparison, and if the extension distance is too large, too many irrelevant regions will be introduced, affecting the accuracy of the judgment. Similar extension processing is performed on the right boundary, top boundary, and bottom boundary, forming corresponding overlapping regions in the column direction. In each overlapping region, the fitting deviation between each extended boundary and the corresponding grid baseline is calculated. The fitting deviation is obtained by calculating the root mean square value of the vertical distance from each pixel on the extended boundary to the grid baseline. This deviation value reflects the degree of consistency between the extended boundary and the ideal grid structure. The extension boundary with the smallest fitting deviation is selected, which best follows the direction of the grid baseline. The extension boundaries with the smallest fitting deviation in the four directions are combined to form a quadrilateral profile that surrounds the missing position. This quadrilateral profile is the expected profile feature of the missing position.

[0086] By using the outline estimation method based on boundary rules and grid baseline extension, the geometric information of adjacent color blocks and grid structure constraints can be used to accurately predict the outline features of color blocks at missing positions, providing a reliable reference standard for subsequent determination of whether there are segmentation defects at this position and for outline compensation.

[0087] In some preferred embodiments, determining whether segmentation is missing and constructing contour compensation for regions determined to have missing segments includes:

[0088] Pixel features are extracted from the region corresponding to the expected contour features of the missing position in the original image, the color mean within the region is calculated, and a mapping relationship between the centroid coordinates and the color mean is established based on the grid reference region.

[0089] Based on the centroid coordinates of the missing position, the corresponding reference color value is queried in the mapping relationship. The average color value in the region is compared with the reference color value. When the color difference between the average color value in the region and the reference color value meets the color block characteristics, it is determined to be a segmentation missing.

[0090] For regions identified as having segmentation defects, the boundary coordinates of the expected contour features are obtained. Edge detection is performed within the boundary coordinate range to identify the actual edge points within the region. The actual edge points are then matched with the boundary coordinates of the expected contour features.

[0091] When the offset distance between the actual edge point and the boundary coordinate is less than the preset range, the actual edge point is retained. When the actual edge point is missing, the boundary coordinate is used as a substitute. The retained actual edge point and the substitute boundary coordinate are sequentially connected to form a compensation contour, and the area corresponding to the compensation contour is added to the color block candidate area set.

[0092] For example, pixel features are extracted from the region corresponding to the expected contour features of the missing position in the original color chart image. The color values ​​of all pixels within this region are obtained, and the arithmetic mean of these color values ​​across the red, green, and blue channels is calculated to obtain the color mean of the region. This color mean represents the overall color feature of the region. When a color patch exists in the region but is not detected by the segmentation model, its color mean should match the color features of other color patches in the color chart. A mapping relationship between the centroid coordinates and the color mean is established based on the identified grid reference regions. For each grid reference region, its centroid coordinates and the corresponding region's color mean are extracted, and a two-dimensional mapping function is constructed using spatial interpolation. This mapping function, based on the characteristic that color patches in the color chart typically exhibit spatial gradation, can predict the expected color value of a color patch at a given location based on its spatial position.

[0093] The reference color value is retrieved from the mapping relationship based on the centroid coordinates of the missing location. Substituting the centroid coordinates of the missing node into the mapping function yields the reference color value at that location. This reference color value represents the color that the color block at that location should have, calculated based on the color distribution patterns of the surrounding color blocks. The color difference is calculated by comparing the mean color value within the region with the reference color value. The color difference is calculated using Euclidean distance in the CIE Lab color space. The mean color value and the reference color value are converted from the RGB color space to the Lab color space, and the square root of the sum of the squares of the differences between the three components of the two colors in the Lab space is calculated to obtain the color difference value ΔE. When the color difference value is less than a preset color difference threshold, the color characteristics of the region are considered to meet the characteristics of a color block, and the missing location is determined to have a segmentation deficiency. The color difference threshold is set to 15-25, preferably 20. This threshold is used to determine whether the color of the region is consistent with the color of the expected color block. If the color difference value is less than the threshold, it means that the region does contain color blocks that should be detected but were missed by the segmentation model. If the threshold is too small, the color matching requirements will be too strict and the real color blocks will be missed. If the threshold is too large, the background region may be misjudged as a color block.

[0094] For regions identified as having segmentation defects, the boundary coordinates of the expected contour features are obtained. These boundary coordinates include a sequence of discrete pixel coordinates on the four sides of the expected contour. Edge detection is performed on the original color chart image within the boundary coordinate range. A gradient operator is used to calculate the gray-level gradient magnitude of each pixel within this region. Pixels with gradient magnitudes exceeding the edge detection threshold are identified as actual edge points. This edge detection threshold is set to the 75th-85th percentile of the gray-level gradient magnitude distribution, preferably the 80th percentile. This threshold is used to filter significant edge points; setting it to a high percentile of the distribution filters out weak edges caused by noise, retaining strong edges corresponding to the true boundaries of the color blocks. The actual edge points reflect the actual boundary positions of the color blocks within the region. However, due to factors such as uneven lighting and insufficient contrast between the color blocks and the background, the actual edge points may be incomplete or offset.

[0095] The actual edge points are matched with the boundary coordinates of the expected contour features. For each boundary coordinate point on the expected contour, the nearest actual edge point is searched around it, and the offset distance between them is calculated. When the offset distance is less than a preset range, the actual edge point is considered to correspond to the boundary coordinate point of the expected contour, and the actual edge point is retained as a valid boundary point of the compensation contour. The preset range is set to 0.08-0.12 times the average side length of the grid reference area, preferably 0.1 times. This range is used to determine whether the actual edge point is near the expected contour. If the range is too small, valid actual edge points will be excluded due to slight offsets; if the range is too large, irrelevant edge points far from the expected contour may be incorrectly included. When no actual edge point meeting the offset distance requirement is found around a boundary coordinate point of an expected contour, it indicates that the boundary of the color block at that location is not obvious or missing in the image. In this case, the boundary coordinate point itself is used as a substitute point to ensure the integrity of the compensation contour.

[0096] The retained actual edge points and alternative boundary coordinate points are connected according to their positional order on the expected contour to form a closed compensation contour. This compensation contour comprehensively utilizes the geometric constraints of the expected contour and the actual edge information in the image, ensuring that the contour conforms to the grid rules while maximizing the fit to the actual color block boundaries. The region corresponding to the compensation contour is added to the color block candidate region set as a compensation color block candidate region. This region participates in the subsequent determination of cropping reference coordinates and the standardized color block region output, realizing automatic compensation for segmented missing color blocks and improving the integrity of color card recognition.

[0097] The segmentation missing determination and contour compensation method based on color mapping verification and edge point matching described above can accurately identify the color block regions missed by the segmentation model, and construct a reasonable compensation contour by combining the expected contour and the actual edge information, which effectively solves the problem of incomplete recognition caused by missed color block detection.

[0098] In some preferred embodiments, the boundaries of the abnormal regions are adaptively corrected based on the contour features of adjacent color block candidate regions in the mesh topology to generate corrected color block regions, including:

[0099] Extract candidate regions of color blocks that are determined to be regional defects caused by segmentation anomalies, obtain the adjacent candidate regions of color blocks in the mesh topology, extract the contour boundaries of the adjacent candidate regions and calculate the curvature distribution characteristics;

[0100] Calculate the centroid displacement vector between the candidate color block region and each adjacent candidate color block region. Based on the consistency between the centroid displacement vector and the spacing change gradient, perform perspective correction on the curvature distribution features to obtain the corrected reference curvature distribution and generate reference contour features.

[0101] Abnormal curvature points on the contour boundary of the candidate color block region are detected. When the curvature value of the abnormal curvature point deviates from the reference contour feature, the abnormal curvature point and its neighborhood are marked as the boundary segment to be corrected. The pixel gradient information corresponding to the boundary segment to be corrected in the original image is extracted. Candidate boundary points are searched along the pixel gradient direction. The candidate boundary point that matches the curvature of the reference contour feature is selected to replace the boundary segment to be corrected, forming a corrected contour. The region corresponding to the corrected contour is used as the corrected color block region.

[0102] For example, candidate regions of color blocks identified as having defects caused by segmentation anomalies are extracted. These regions have already been marked as having abnormal shapes and not conforming to perspective distortion features in the aforementioned processing, requiring boundary correction to restore their true contours. Adjacent candidate regions of color blocks in the row and column directions are obtained based on the mesh topology. The contour features of these adjacent regions can provide a reference for correcting the abnormal regions. The contour boundaries of each adjacent candidate region are extracted, and the curvature value of each pixel on the contour boundary is calculated. The curvature value is obtained by calculating the curvature of the arc formed by the three pixels before and after the pixel, reflecting the degree of curvature of the contour at that point. Statistical analysis is performed on the curvature values ​​along the entire contour boundary to calculate the mean, variance, and distribution range of the curvature, forming a curvature distribution feature. This curvature distribution feature describes the geometric shape of the contours of adjacent color blocks. The contour curvature of a standard rectangular color block should be close to zero on the straight edges and show abrupt changes at the corners.

[0103] The centroid displacement vector between the candidate region of the color patch to be corrected and each of its adjacent candidate regions is calculated. This displacement vector points from the centroid coordinates of the region to be corrected to the centroid coordinates of each adjacent region. Perspective correction is performed on the curvature distribution characteristics based on the consistency between the centroid displacement vector and the aforementioned spacing change gradient. When perspective distortion exists on the color chart, color patches farther from the lens will undergo geometric deformation due to perspective projection, resulting in a difference in their contour curvature distribution compared to closer color patches. By analyzing the relationship between the centroid displacement vector and the spacing change gradient, the perspective relationship between the region to be corrected and its adjacent regions is determined, and perspective correction coefficients are established. The perspective correction coefficient is determined based on the angle between the centroid displacement vector direction and the gradient direction of the spacing change. When the angle is <20°, the correction coefficient is set to 0.9-1.0; when the angle is between 20° and 40°, the correction coefficient is set to 0.8-0.9; and when the angle is >40°, the correction coefficient is set to 0.7-0.8. This correction coefficient is used to adjust the curvature distribution characteristics of adjacent color blocks to adapt to the influence of perspective distortion, so that the corrected reference curvature can accurately reflect the contour characteristics that the area to be corrected should have under the current perspective conditions. The curvature distribution characteristics of each adjacent color block are multiplied by the corresponding perspective correction coefficient to obtain the corrected reference curvature distribution. A weighted average is then performed on the corrected reference curvature distributions of multiple adjacent areas. The weights are determined based on the centroid distance between the adjacent areas and the area to be corrected; the closer the distance, the greater the weight, thus generating a comprehensive reference contour feature.

[0104] Abnormal curvature points on the contour boundary of the candidate region of the color block to be corrected are detected. Each pixel on the contour boundary is traversed, and the curvature value of each pixel is calculated and compared with the reference curvature value at the corresponding position in the reference contour features. The corresponding position is determined by searching for a reference curvature value with the same relative position ratio in the reference contour features based on the relative position ratio of the pixel on the contour boundary. When the absolute value of the difference between the curvature value of a pixel and the reference curvature value exceeds the curvature deviation threshold, the pixel is marked as an abnormal curvature point. This curvature deviation threshold is set to 1.5-2.5 times the reference curvature value, preferably 2.0 times. This threshold is used to identify points on the contour that significantly deviate from the normal shape. If the threshold is too small, normal curvature fluctuations may be misjudged as abnormal; if the threshold is too large, real contour defects may be missed. The abnormal curvature point and its neighborhood of 5 pixels before and after it are marked as the boundary segment to be corrected. This neighborhood range ensures that the correction process can cover the affected contour portion around the abnormal point.

[0105] Extract the pixel gradient information corresponding to the boundary segment to be corrected in the original color chart image. Calculate the gray-level gradient vector of each pixel in the image area covered by the boundary segment to be corrected. The direction of this gradient vector points to the direction of the most drastic gray-level change, usually perpendicular to the actual color block boundary. Search for candidate boundary points both inwards and outwards along the gradient direction of each pixel. The search distance is set to 0.05-0.15 times the average side length of the grid reference area, preferably 0.1 times. This search distance is used to limit the search range of candidate boundary points. If the range is too small, it may not be possible to find the actual boundary; if the range is too large, it will introduce too many irrelevant points and increase computational complexity. Detect local maxima of gradient magnitude along the search path as candidate boundary points. These maxima correspond to edge positions in the image, representing the boundary between the color block and the background or adjacent color blocks.

[0106] Candidate boundary points matching the curvature of the reference contour feature are selected to replace the boundary segments to be corrected. For each candidate boundary point, the local contour curvature formed by connecting it with adjacent candidate boundary points is calculated. This local contour curvature is compared with the reference curvature value at the corresponding position in the reference contour feature to calculate the curvature matching degree. The curvature matching degree is obtained by calculating the reciprocal of the difference between the local contour curvature and the reference curvature value; the smaller the difference, the higher the matching degree. The candidate boundary point sequence with the highest curvature matching degree is selected. This sequence makes the corrected contour curvature closest to the reference contour feature. The boundary segments to be corrected on the original contour boundary are replaced with the selected candidate boundary point sequence to form the corrected contour. This corrected contour comprehensively utilizes the geometric constraints of adjacent color blocks and the actual edge information in the image, conforming to grid rules and fitting the real boundary. The region corresponding to the corrected contour is used as the corrected color block region, replacing the original abnormal color block candidate region.

[0107] By constructing reference contours based on perspective correction and using gradient-guided boundary search correction methods, we can accurately correct contour defects caused by segmentation anomalies. By utilizing the geometric features of adjacent color blocks and image edge information, we can restore the true boundaries of color blocks, thereby improving the accuracy and robustness of color block region detection.

[0108] In some preferred embodiments, the color chart image is intelligently cropped using multiple thresholds. The cropping result where the number of qualified color blocks reaches a preset threshold is taken as the final result, and a standardized color block region is output, including:

[0109] The corrected color block region and the region corresponding to the compensated contour are merged into the color block candidate region set. Each color block candidate region in the color block candidate region set is traversed, and the vertex coordinates of the bounding rectangle of each color block candidate region are extracted.

[0110] Sort the coordinates of the vertices of each bounding rectangle in the row and column directions respectively, select the minimum and maximum ordinates in the row direction, and select the minimum and maximum abscissas in the column direction. Project the minimum, maximum, minimum, and maximum ordinates onto the corresponding grid baselines respectively, and construct an adaptive envelope boundary based on the projected coordinates.

[0111] Multiple different detection threshold parameters are set, and the color card image is cropped according to the initial cropping reference coordinates for each detection threshold parameter, and the color block qualification is detected. The number of qualified color blocks in each cropping result is counted.

[0112] The cropping result with the number of qualified color blocks reaching a preset threshold is determined as the final cropping result. The boundary extension distance is calculated based on the average side length of the grid reference area. The boundary extension distance is extended along the outer edge of each side of the adaptive envelope boundary to form an extended cropping boundary box. The coordinates of the four corner points of the cropping boundary box are extracted as cropping reference coordinates. The corresponding area is cropped in the color card image according to the cropping reference coordinates, and the standardized color block area is output.

[0113] For example, the previously generated corrected color patch regions and the regions corresponding to the compensated contours are merged into a color patch candidate region set. This set now includes the initially detected color patch candidate regions, the color patch regions after boundary correction, and the color patch regions added through contour compensation, forming a complete color patch region set. Each color patch candidate region in the set is traversed, and its bounding rectangle is extracted for each color patch candidate region. This bounding rectangle is the smallest rectangle that can completely enclose the contour of the color patch candidate region and whose edges are parallel to the image coordinate axes. The coordinates of the four vertices of each bounding rectangle are extracted, including the top-left vertex, top-right vertex, bottom-right vertex, and bottom-left vertex. These vertex coordinates define the spatial extent of each color patch candidate region in the image.

[0114] The coordinates of all vertices of the bounding rectangle are sorted along both the row and column directions. In the row direction, the y-coordinates of all vertices are extracted and sorted in ascending order. The minimum y-coordinate is selected as the upper boundary of all color-block regions in the row direction, and the maximum y-coordinate is selected as the lower boundary. In the column direction, the x-coordinates of all vertices are extracted and sorted in ascending order. The minimum x-coordinate is selected as the left boundary of all color-block regions in the column direction, and the maximum x-coordinate is selected as the right boundary. These four extreme coordinates preliminarily determine the range of the rectangular region containing all color-blocks, but this range may be deviated from due to the abnormal positions of individual color-blocks.

[0115] The minimum ordinate, maximum ordinate, minimum abscissa, and maximum abscissa are projected onto their respective grid baselines. The constraints of the grid baselines are used to eliminate the influence of individual abnormal color blocks on the clipping boundary. For the minimum ordinate, the row baseline containing this ordinate value is determined. If the distance between this ordinate value and the nearest row baseline is less than 0.3 times the average height of the grid baseline area, the minimum ordinate is adjusted to the ordinate value of that row baseline. This 0.3-times distance threshold is used to determine whether extreme coordinates should be aligned to the grid baseline. Alignment when extreme coordinates are close to the grid baseline ensures that the clipping boundary is consistent with the grid structure. The threshold setting range is 0.2-0.4 times, preferably 0.3 times. Similar projection processing is performed on the maximum ordinate, minimum abscissa, and maximum abscissa. An adaptive envelope boundary is constructed based on the projected coordinates, and this envelope boundary serves as the initial clipping reference frame.

[0116] Multiple different detection threshold parameters are set, and multiple sets of parameters are configured for key judgment steps in the color block segmentation process. Specifically, these include: edge detection threshold, used for setting high and low thresholds in Canny edge detection, with a setting range of 30-70 for low threshold and 80-180 for high threshold, affecting the completeness of color block contour extraction; binarization threshold, used for image grayscale segmentation, with a setting range of 100-180, affecting the separation effect of color blocks from the background; morphological filter kernel size, used for the size of the structuring element in morphological opening and closing operations, with a setting range of 3×3 to 7×7 pixels, affecting noise suppression and contour smoothness; and color block area threshold, used to determine whether the detected connected region is a valid color block, with a setting range of 0.4-1.5 times the average area of ​​the grid reference region, affecting the distinction between small color blocks and noise points. For each set of detection threshold parameters, a complete color block detection process is executed. The color card image is cropped according to the initial cropping reference coordinates determined by the adaptive envelope boundary to obtain a preliminary cropped image. The preliminary cropped image is then subjected to color block qualification detection. This detection is based on a comprehensive judgment of the color block's area integrity, shape regularity, and positional consistency. Specifically, the ratio of the detected color block area to the average area of ​​the grid reference region is calculated. If the ratio is within the range of 0.7-1.3, the area is considered qualified. The aspect ratio of the color block's bounding rectangle is calculated. If the aspect ratio is close to the aspect ratio of the grid reference region and the deviation is less than 0.2, the shape is considered qualified. The positional deviation between the color block's centroid and the corresponding grid node is calculated. If the deviation is less than 0.25 times the grid spacing, the position is considered qualified. Color blocks that simultaneously meet the three criteria of area, shape, and position are counted as qualified color blocks. The number of qualified color blocks in each cropping result is counted, and the number of qualified color blocks corresponding to different combinations of threshold parameters is recorded.

[0117] The cutting result is determined when the number of qualified color blocks reaches a preset threshold. The preset threshold is set according to the total number of standard color blocks of the color card, preferably 0.85-0.95 times the total number of standard color blocks. For example, for a color card containing 24 standard color blocks, the preset threshold is set to 20-22.

[0118] When multiple threshold parameter combinations all reach the preset number threshold, the cropping result with the largest number of qualified color blocks is selected; when different threshold parameter combinations have the same number of qualified color blocks, the result with the higher edge detection threshold is selected first to reduce the impact of noise interference.

[0119] Obtain the adaptive envelope boundary corresponding to the final clipping result. Calculate the boundary extension distance based on the average side length of the grid reference region. Obtain the width and height of all grid reference regions, calculate the arithmetic mean of the width and the arithmetic mean of the height, and take the arithmetic mean of both as the average side length. Set the boundary extension distance to 0.1-0.2 times the average side length, preferably 0.15 times. This extension distance is used to preserve appropriate edge areas around the color blocks during clipping. Extend each edge of the adaptive envelope boundary along the outer edge by the boundary extension distance. Specifically, shift the upper boundary upwards by the boundary extension distance, shift the lower boundary downwards by the boundary extension distance, shift the left boundary to the left by the boundary extension distance, and shift the right boundary to the right by the boundary extension distance, forming the expanded clipping boundary box.

[0120] The coordinates of the four corner points of the cropping bounding box are extracted as the cropping reference coordinates, including the coordinates of the top-left, top-right, bottom-right, and bottom-left corners. Based on these reference coordinates, a corresponding rectangular region is cropped from the original color chart image. Image cropping operations are then performed to extract all pixels within this rectangular area, generating the cropped image. This cropped image contains only the valid color patch areas of the color chart and their necessary edges, removing background interference and irrelevant areas from the original image. The cropped image is then output as a standardized color patch region. This standardized color patch region has uniform boundary rules and complete color patch content, making it suitable for subsequent color analysis, quality inspection, and other applications.

[0121] Through the above-mentioned multi-threshold detection verification and adaptive cropping strategy, robust processing of color card images of different quality is achieved. The output standardized color block region not only retains all effective color block information, but also eliminates background interference, providing high-quality input data for the automated recognition and analysis of color cards.

[0122] Specifically, this paper provides an application example of the intelligent grid segmentation and cropping method based on the present invention in pet hair color card recognition.

[0123] In the pet grooming industry, pet hair color charts are used to record and compare changes in a pet's coat color, assisting groomers in color mixing and health monitoring. Pet hair color charts typically contain multiple regularly arranged hair sample color blocks, each representing the coat color of a specific area or period. This application example uses the intelligent grid segmentation and cropping method of this invention to automatically identify and standardize the captured pet hair color chart images.

[0124] The user photographed a pet fur color chart containing 12 color blocks arranged in 3 rows and 4 columns, each approximately 25mm x 25mm in size. Due to the handheld shooting angle of about 15 degrees, the color chart exhibits slight perspective distortion in the image, with the distance between the far-end color blocks being approximately 120 pixels and the distance between the near-end color blocks being approximately 145 pixels. Additionally, because some fur samples are similar in color to the white background, the segmentation model missed detecting the lighter-colored fur color block in the upper right corner.

[0125] Step 1: Determining the grid baseline and calculating the positional deviation

[0126] Centroid coordinates were extracted from the 11 candidate color patches output by the segmentation model. Candidate adjacency relationships were determined based on the relative positions of the centroids in the row and column directions. The centroid spacing between adjacent color patches within the same row was calculated. In the first row, the spacing from left to right was 145 pixels, 143 pixels, and 142 pixels, respectively. First-order differencing of this spacing sequence yielded gradients of -2 pixels and -1 pixels. The spacing change rates were calculated to be 1.4% and 0.7%, both below the set 20% threshold, indicating that the color patches in this row satisfy a stable grid relationship. Similar processing was performed on the remaining rows and columns, identifying 9 grid reference regions. The adjacency relationships of these regions constitute a two-dimensional grid topology.

[0127] A mesh skeleton is constructed based on the row and column displacement relationships of the grid reference region. Linear fitting is performed on the centroid connections of each row to generate three row reference lines, and linear fitting is performed on the centroid connections of each column to generate four column reference lines. The position of each color block candidate region is predicted based on the mesh skeleton. The predicted mesh position coordinates for the upper right corner vacancy are (850, 220).

[0128] Step 2: Differentiating between perspective distortion and segmentation anomalies

[0129] The centroid spacing of adjacent color blocks within each row is extracted. The spacing in the first row decreases from 145 pixels to 142 pixels, the spacing in the second row decreases from 138 pixels to 135 pixels, and the spacing in the third row decreases from 132 pixels to 129 pixels. The spacing gradient exhibits a monotonically decreasing characteristic within each row, and the gradient direction consistently points to the right side of the image, generating perspective distortion markers.

[0130] An outline integrity analysis was performed on the first color block in the second row. The outline boundary of this color block had three pairs of breakpoints with gaps of 8 pixels, 6 pixels, and 9 pixels, respectively, all less than the threshold of 10 pixels. These pairs of breakpoints were virtually connected to form a corrected outline. The area of ​​the corrected outline was calculated to be 58,200 square pixels, the area of ​​the corrected convex hull was 59,800 square pixels, and the outline integrity score was 0.973, higher than the baseline value of 0.90. Therefore, the shape of this color block was determined to be normal.

[0131] Step 3: Contour prediction and segmentation of missing areas to determine deficiencies

[0132] By traversing the mesh topology, a missing candidate color block region was identified at the top right corner (first row, fourth column), thus determining it as a missing node. The left-hand adjacent color block in the row direction and the lower-hand adjacent color block in the column direction were extracted from this missing location. The right boundary outline length of the left-hand adjacent color block is 148 pixels, and the angle between its boundary direction vector and the column baseline is 12°, indicating the boundary is approximately vertical. The upper boundary outline length of the lower-hand adjacent color block is 142 pixels, and the angle between its boundary direction vector and the row baseline is 8°, indicating the boundary is approximately horizontal.

[0133] Based on the intersection coordinates (850, 220) of the first row baseline and the fourth column baseline as the theoretical position of the missing node, the predicted bounding box is formed by extending 0.5 times the average width (70 pixels) to the left and right along the row baseline and extending 0.5 times the average height (72 pixels) up and down along the column baseline. Combining the boundary rules of adjacent color blocks, the left boundary of the predicted bounding box is adjusted to align with the right boundary of the adjacent color block on the left, and the coordinates are adjusted to the horizontal coordinate 780.

[0134] The edges of the adjusted predicted bounding box are extended to the missing position by 0.2 times the average width, or 28 pixels, to form an overlapping area. The fitting deviation between each extended boundary and the grid baseline is calculated, and the combination of extended boundaries with the smallest fitting deviation is selected to generate the expected contour feature of the missing position. This contour is a rectangular area with coordinates ranging from 780 to 920 on the horizontal axis and 148 to 292 on the vertical axis.

[0135] Pixels corresponding to the expected contour region are extracted from the original image, and the mean color value within the region is calculated to be RGB(245, 242, 238). A mapping relationship between the centroid coordinates and the mean color value is established based on 9 grid reference regions. The reference color value RGB(248, 244, 240) is obtained by querying the centroid coordinates (850, 220) of the missing position. The color difference ΔE between the two in the Lab color space is calculated to be 3.2, which is less than the color difference threshold of 20, indicating that there is a segmentation defect at the missing position.

[0136] Step 4: Contour compensation for missing color blocks

[0137] Edge detection was performed on the original image within the expected contour boundary coordinate range. The Sobel gradient operator was used to calculate the gradient magnitude, and the edge detection threshold was set to the 80th percentile value of the gradient magnitude distribution, 42, identifying 126 actual edge points. These actual edge points were matched with the boundary coordinates of the expected contour. For the 52 coordinate points on the upper boundary of the expected contour, 38 points had corresponding actual edge points within a 6-pixel radius, and these 38 actual edge points were retained. The remaining 14 expected contour coordinate points did not have corresponding actual edge points, and these 14 boundary coordinate points themselves were used as replacement points.

[0138] The retained actual edge points and the alternative boundary coordinate points are connected in a clockwise order to form a closed compensation contour. The area enclosed by this compensation contour is 60,500 square pixels, which is close to the average area of ​​the grid reference area of ​​60,200 square pixels. The area corresponding to this compensation contour is added to the color block candidate area set, and the total number of color block candidate areas is updated to 12.

[0139] Step 5: Intelligent cropping and standardized output

[0140] Five different combinations of detection threshold parameters were set, including edge detection thresholds of (50, 120), (40, 100), (60, 140), (45, 110), and (55, 130), binarization thresholds of 120, 140, 160, 130, and 150, morphological filter kernel sizes of 3×3, 5×5, 5×5, 3×3, and 7×7 pixels, and color block area thresholds of 0.6, 0.8, 1.0, 0.7, and 0.9 times the average area of ​​the grid reference region.

[0141] Iterate through the set containing 12 candidate color blocks and extract the coordinates of the vertices of the bounding rectangle for each color block. Sort the y-coordinates of all bounding rectangle vertices, with the minimum y-coordinate being 148 pixels and the maximum being 728 pixels; sort the x-coordinates, with the minimum x-coordinate being 215 pixels and the maximum being 920 pixels.

[0142] Project the minimum ordinate of 148 onto the nearest first-row baseline, whose ordinate is 145. The distance between the two is 3 pixels, which is less than 0.3 times the average height of 144 pixels, or 43 pixels. Adjust the minimum ordinate to 145. Perform similar projection processing on other extreme coordinates to construct an adaptive envelope boundary. The upper boundary ordinate is 145, the lower boundary ordinate is 730, the left boundary x-coordinate is 215, and the right boundary x-coordinate is 920. This envelope boundary determines the initial clipping reference coordinates as (215, 145), (920, 145), (920, 730), and (215, 730).

[0143] Five sets of detection threshold parameters were used to perform color block compliance checks on the image within the initial cropping reference coordinate range. The ratio of each color block area to the average area of ​​the grid reference region (20160 pixels) was calculated; a ratio between 0.7 and 1.3 was considered acceptable for area. The deviation of the aspect ratio of the bounding rectangle of each color block from the aspect ratio of the grid reference region (1.2) was calculated; a deviation less than 0.2 was considered acceptable for shape. The positional deviation of the centroid of each color block from its corresponding grid node was calculated; a deviation less than 0.25 times the grid spacing of 145 pixels (36 pixels) was considered acceptable for position. The number of acceptable color blocks under each threshold parameter combination was counted: 9 acceptable color blocks were detected in group 1, 11 in group 2, 12 in group 3, 10 in group 4, and 11 in group 5.

[0144] Based on the standard color chart having a total of 12 color patches, a preset threshold of 11 patches was set. Both groups 3 and 5 met the preset threshold, so the cropping result of group 3, with the largest number of qualified color patches, was selected as the final cropping result. The average side length of the grid reference area was calculated to be 142 pixels, and the boundary extension distance was set to 0.15 times the average side length, or 21 pixels. The adaptive envelope boundary corresponding to the final cropping result was obtained, and each side of the adaptive envelope boundary was extended outward by 21 pixels to form a cropping bounding box. The upper boundary was adjusted to a ordinate of 124, the lower boundary to a ordinate of 751, the left boundary to a horizontal coordinate of 194, and the right boundary to a horizontal coordinate of 941. The coordinates of the four corner points of the cropping bounding box (194, 124), (941, 124), (941, 751), and (194, 751) were extracted as the cropping reference coordinates. This rectangular area was then cropped from the original color chart image, outputting a standardized pet fur color chart image with a size of 747×627 pixels.

[0145] This standardized image contains 12 complete hair color patches, eliminating background interference. It can be directly used for applications such as hair color database storage, comparative analysis of hair colors at different times, and automatic matching of dyeing formulas, realizing the digital management of pet hair color cards.

[0146] Please see Figure 2 Similar to the embodiments described above, this application also provides an intelligent grid segmentation and cropping system, comprising:

[0147] The topology confirmation module is used to acquire the color card image to be processed, segment it to obtain several candidate color block regions, construct a two-dimensional grid topology relationship based on the centroid coordinates of each candidate color block region, determine the grid baseline, and calculate the grid position deviation of each candidate color block region.

[0148] The offset evaluation module is used to jointly evaluate the contour shape deviation of each color block candidate region and its position offset in the mesh topology based on the mesh position deviation and the spacing relationship between adjacent color block candidate regions, and to distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies.

[0149] The contour compensation module is used to calculate the expected contour features of the missing positions in non-color block regions with missing locations in the mesh topology, based on the boundary rules of adjacent color block candidate regions and the extension relationship of the mesh baseline, to determine whether there is a segmentation missing, and to construct the contour compensation for the regions determined to be segmentation missing.

[0150] The correction output module is used to adaptively correct the boundary of the abnormal region based on the contour features of the adjacent candidate regions in the grid topology for candidate regions of color blocks that are determined to be segmented abnormally, and generate the corrected color block region. The cropping reference coordinates are determined based on the corrected color block region and the region constructed by contour compensation. The color card image is intelligently cropped using multiple thresholds. The cropping result with the number of qualified color blocks reaching the preset threshold is taken as the final result, and the standardized color block region is output.

[0151] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0152] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0153] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0154] Finally, it should be noted that the above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An intelligent grid segmentation and cropping method, characterized in that: The method includes the following steps: The color chart image to be processed is acquired and segmented to obtain several candidate color block regions. A two-dimensional grid topology is constructed based on the centroid coordinates of each candidate color block region, the grid baseline is determined, and the grid position deviation of each candidate color block region is calculated. Based on the relationship between the grid position deviation and the spacing between adjacent color block candidate regions, the contour shape deviation of each color block candidate region and its position offset in the grid topology are jointly evaluated to distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies. For non-color block regions with missing positions in the grid topology, based on the boundary rules of adjacent color block candidate regions and the extension relationship of the grid baseline, the expected contour features of the missing positions are calculated, it is determined whether there is a segmentation gap, and contour compensation is performed on the regions determined to be segmentation gaps. For candidate color blocks that are determined to be segmented abnormally, the boundary of the abnormal region is adaptively corrected based on the contour features of adjacent candidate color block regions in the grid topology relationship to generate a corrected color block region. The cropping reference coordinates are determined based on the corrected color block region and the region constructed by the contour compensation. The color card image is intelligently cropped using multiple thresholds. The cropping result with the number of qualified color blocks reaching a preset threshold is taken as the final result, and the standardized color block region is output.

2. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: Determine the grid baseline and calculate the grid position deviation for each candidate color patch region, including: The candidate adjacency relationship is determined for the candidate color block regions according to the centroid coordinates. Based on the centroid displacement between adjacent candidate color block regions in the same row and column, the row displacement relationship and column displacement relationship are generated respectively. The stable grid relationship is determined according to the continuity between the row displacement relationship and the column displacement relationship. The candidate regions of color blocks that satisfy the stable grid relationship are determined as grid reference regions, and the adjacency relationship between the grid reference regions constitutes the two-dimensional grid topology relationship. A mesh skeleton is constructed based on the row and column displacement relationships corresponding to the mesh reference region. A row baseline is generated by linear fitting of the row displacement relationship in the mesh skeleton, and a column baseline is generated by linear fitting of the column displacement relationship in the mesh skeleton. The row baseline and the column baseline constitute the mesh baseline. Based on the grid skeleton, the position of each candidate color block region is predicted along the row and column directions respectively to obtain the predicted grid position corresponding to each candidate color block region. The offset distance between the actual centroid coordinates of each candidate color block region and the predicted grid position is calculated, and the offset distance constitutes the grid position deviation.

3. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: Distinguishing between geometrical changes caused by perspective distortion and regional defects caused by segmentation anomalies includes: Based on the grid topology, the center distance between each color block candidate region and its adjacent color block candidate regions is extracted. The adjacent distance sequence in the same row and the same column is calculated. The first-order difference of the adjacent distance sequence is used to obtain the distance change gradient. When the distance change gradient is monotonic, a perspective deformation mark is generated. Extract the contour boundaries of each candidate region of color blocks, detect the pairs of break points on the contour boundaries and calculate the gap distance. When the gap distance is less than a preset threshold, virtually connect the pairs of break points to form a corrected contour. Use the ratio of the area of ​​the corrected contour to the area of ​​the corrected convex hull as the contour integrity. Mark the candidate regions of color blocks with contour integrity lower than the benchmark value as abnormal shape regions. Determine whether the candidate color block region marked as the shape abnormality region also has the perspective distortion mark. If it has the perspective distortion mark and the grid position deviation conforms to the extension direction of the spacing change gradient, it is determined to be a geometric change caused by perspective distortion; otherwise, it is determined to be a regional defect caused by segmentation abnormality.

4. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: Based on the boundary rules of adjacent color block candidate regions and the extension relationship of the grid baseline, the expected contour features of the missing positions are calculated, including: Traverse each grid node in the grid topology relationship, identify grid nodes that lack corresponding color block candidate areas as empty nodes, and determine the empty positions corresponding to the empty nodes; Extract the adjacent color block candidate regions in the row and column directions of the missing position, obtain the boundary contours of the adjacent color block candidate regions facing the missing position, extract the boundary direction vector and boundary length of the boundary contours, and use the boundary direction vector and boundary length as boundary rules; Based on the grid baseline, determine the row baseline and column baseline corresponding to the missing position, extend along the row baseline and column baseline to the missing position to form a predicted bounding box, and adjust each side of the predicted bounding box in combination with the boundary rules; The edges of the adjusted predicted bounding box and the boundary contours of the adjacent color block candidate regions are extended to the vacancy position to form overlapping regions. The fitting deviation between each extended boundary and the grid baseline is calculated within the overlapping region. The extended boundary with the smallest fitting deviation is selected and combined to generate the expected contour feature of the vacancy position.

5. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: Determine if there are missing segments, and construct contours for regions identified as having missing segments, including: Pixel features are extracted from the region corresponding to the expected contour features of the missing position in the original image, the color mean within the region is calculated, and a mapping relationship between the centroid coordinates and the color mean is established based on the grid reference region. Based on the centroid coordinates of the missing position, the corresponding reference color value is queried in the mapping relationship. The average color value in the region is compared with the reference color value. When the color difference between the average color value in the region and the reference color value meets the color block characteristics, it is determined to be a segmentation missing. Contour compensation is performed to construct the regions identified as having missing segments.

6. The intelligent grid segmentation and trimming method according to claim 5, characterized in that: Contour compensation is performed on the regions identified as having missing segments, including: Obtain the boundary coordinates of the expected contour feature, perform edge detection within the boundary coordinate range, identify the actual edge points within the region, and match the actual edge points with the boundary coordinates of the expected contour feature; When the offset distance between the actual edge point and the boundary coordinate is less than a preset range, the actual edge point is retained. When the actual edge point is missing, the boundary coordinate is used as a substitute. The retained actual edge point and the substitute boundary coordinate are sequentially connected to form a compensation contour, and the area corresponding to the compensation contour is added to the color block candidate area set.

7. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: Based on the contour features of adjacent color block candidate regions in the aforementioned grid topology, the boundaries of abnormal regions are adaptively corrected to generate corrected color block regions, including: Extract candidate regions of color blocks that are determined to be regional defects caused by segmentation anomalies, obtain the adjacent candidate regions of color blocks in the mesh topology, extract the contour boundaries of the adjacent candidate regions and calculate the curvature distribution features; Calculate the centroid displacement vector between the candidate color block region and each of the adjacent candidate color block regions. Based on the consistency between the centroid displacement vector and the spacing change gradient, perform perspective correction on the curvature distribution feature to obtain the corrected reference curvature distribution and generate reference contour features. Abnormal curvature points on the contour boundary of the candidate color block region are detected. When the curvature value of the abnormal curvature point deviates from the reference contour feature, the abnormal curvature point and its neighborhood are marked as a boundary segment to be corrected. The pixel gradient information corresponding to the boundary segment to be corrected in the original image is extracted. Candidate boundary points are searched along the pixel gradient direction. The candidate boundary point that matches the curvature of the reference contour feature is selected to replace the boundary segment to be corrected, forming a corrected contour. The region corresponding to the corrected contour is used as the corrected color block region.

8. The intelligent grid segmentation and trimming method according to claim 1, characterized in that: The color chart image is intelligently cropped using multiple thresholds. The cropping result where the number of qualified color blocks reaches a preset threshold is taken as the final result, and a standardized color block region is output, including: The corrected color block region and the region corresponding to the compensated contour are merged into the color block candidate region set. Each color block candidate region in the color block candidate region set is traversed, and the coordinates of the circumscribed rectangle vertices of each color block candidate region are extracted. The coordinates of the vertices of each bounding rectangle are sorted in the row and column directions respectively. The minimum and maximum ordinates in the row direction and the minimum and maximum abscissas in the column direction are selected. The minimum, maximum, minimum, and maximum ordinates are projected onto the corresponding grid reference lines respectively. An adaptive envelope boundary is constructed based on the projected coordinates. The initial clipping reference coordinates are determined based on the adaptive envelope boundary. Multiple different detection threshold parameters are set, and the color card image is cropped according to the initial cropping reference coordinates for each detection threshold parameter, and the color block qualification is detected. The number of qualified color blocks in each cropping result is counted. The cropping result where the number of qualified color blocks reaches a preset threshold is determined as the final cropping result, and a standardized color block area is output based on the boundary of the final cropping result.

9. The intelligent grid segmentation and trimming method according to claim 8, characterized in that: Based on the boundaries of the final cropping result, output standardized color block regions, including: Obtain the adaptive envelope boundary corresponding to the final cropping result, calculate the boundary extension distance based on the average side length of the grid reference region, extend each edge of the adaptive envelope boundary outward by the boundary extension distance to form an extended cropping boundary box, extract the coordinates of the four corner points of the cropping boundary box as the cropping reference coordinates, and crop the corresponding area in the color chart image according to the cropping reference coordinates to output the standardized color block area.

10. An intelligent grid segmentation and clipping system, using the intelligent grid segmentation and clipping method as described in any one of claims 1-9, characterized in that, Includes the following modules: The topology confirmation module is used to acquire the color card image to be processed, segment it to obtain several candidate color block regions, construct a two-dimensional grid topology relationship based on the centroid coordinates of each candidate color block region, determine the grid baseline, and calculate the grid position deviation of each candidate color block region. The offset evaluation module is used to jointly evaluate the contour shape deviation of each color block candidate region and its position offset in the grid topology based on the spacing relationship between the grid position deviation and the adjacent color block candidate regions, and to distinguish between geometric changes caused by perspective distortion and regional defects caused by segmentation anomalies. The contour compensation module is used to calculate the expected contour features of the missing non-color block regions in the mesh topology based on the boundary rules of adjacent color block candidate regions and the extension relationship of the mesh baseline, determine whether there is a segmentation missing, and construct contour compensation for the regions determined to be segmentation missing. The correction output module is used to adaptively correct the boundary of the abnormal region based on the contour features of the adjacent color block candidate regions in the grid topology for the color block candidate regions determined to be segmented abnormally, generate the corrected color block region, determine the cropping reference coordinates based on the corrected color block region and the region constructed by the contour compensation, intelligently crop the color card image using multiple thresholds, and take the cropping result with the number of qualified color blocks reaching the preset threshold as the final result, and output the standardized color block region.