Blocky material self-adaptive segmentation, counting and barycenter positioning method and system

By combining adaptive color perception and multi-scale morphological processing with edge confidence and concave point analysis, the problem of inaccurate segmentation caused by changes in illumination and posture in the detection of blocky materials is solved, achieving high robustness and high accuracy in counting and center of gravity positioning.

CN122289358APending Publication Date: 2026-06-26HANGZHOU HUICUI INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU HUICUI INTELLIGENT TECH CO LTD
Filing Date
2026-05-22
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing technologies struggle to adapt to changes in lighting, shape, and orientation when detecting uniformly colored blocky materials, leading to inaccurate segmentation, counting errors, and imprecise center of gravity positioning. They also lack robustness and accuracy, especially in complex industrial environments.

Method used

By employing adaptive color perception processing, multi-scale morphological processing, edge confidence-guided region growth and filling algorithm, two-level concave point analysis model, and posture adaptive confirmation strategy, combined with local and global statistical characteristics, an accurate foreground region is generated, and the material's own shape concavity and adhesion concavity are distinguished. The object's posture is dynamically verified, and the physical center of gravity is calculated.

Benefits of technology

It achieves stable segmentation and accurate counting under different lighting and posture conditions, reduces false detection rate and false detection rate, improves detection accuracy and center of gravity positioning accuracy, and is suitable for complex scenes with stable color but varied shape and posture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289358A_ABST
    Figure CN122289358A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of computer vision technology and discloses a method and system for adaptive segmentation, counting, and centroid localization of blocky materials. The method involves adaptive color perception processing of an original image containing multiple blocky materials, combining pixel color similarity and local and global statistical characteristics of the image to obtain an initial foreground region; multi-scale morphological processing is implemented to remove noise and repair regions; edge information is introduced and combined with a region growing strategy to fill internal holes in the foreground while maintaining the outer boundaries of the actual materials, resulting in a precisely segmented foreground region; contour and concavity feature analysis distinguishes between material-specific concavities and material adhesion concavities, segmenting only in cases of adhesion; adaptive posture confirmation is performed on the effective materials, and the centroid position of each blocky material is calculated, outputting the number of materials and the corresponding centroid localization results. This invention can achieve stable segmentation, accurate counting, and reliable centroid localization of blocky materials under complex backgrounds and multi-material contact conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, specifically to a method and system for adaptive segmentation, counting, and center-of-gravity positioning of block materials. Background Technology

[0002] In many fields such as industrial automation, logistics sorting, agricultural product processing, and food packaging, there is a frequent need for online detection, counting, and positioning of large quantities of randomly stacked block materials. These block materials typically have the following characteristics: 1) Relatively stable color and surface optical properties, meaning that within the same batch or under the same conditions, their color, texture, and reflective properties are basically consistent, which is an important physical basis for visual differentiation; 2) Uncertainty in shape and posture, with materials possibly scattered on conveyor belts, trays, or containers at any angle or in any posture (e.g., flat, sideways, tilted, partially overlapping); 3) Individual materials may have contact or slight adhesion, but remain essentially physically separated. Typical applications include pre-packaging inspection of chocolate blocks, biscuit sorting, counting of small industrial parts, and online quality inspection of tablet blister packs.

[0003] Traditional detection methods primarily rely on mechanical contact sensors, photoelectric counters, or manual visual inspection. These methods are inefficient, susceptible to material posture leading to missed or incorrect counts, and cannot provide precise positional information of the material in two-dimensional or three-dimensional space. With the development of machine vision technology, image processing-based non-contact detection solutions have become mainstream. The core objective of these solutions is to accurately segment each individual block to be detected in a complex background, thereby achieving individual counting and positioning of the geometric center (center of gravity). Among these, the positioning of the center of gravity is crucial for subsequent robot grasping, precise arrangement, or quality assessment (such as center of gravity offset detection).

[0004] Currently, the most similar implementation scheme for detecting color-uniform blocks is mainly based on the classic framework of color segmentation and connected component analysis, combined with some morphological processing and contour analysis techniques. Its basic workflow can be summarized as follows: Image acquisition and preprocessing: Using an industrial camera (usually a CCD or CMOS camera), images of the area to be inspected are acquired under stable lighting conditions (such as dome lighting, backlighting, or coaxial lighting). Preprocessing steps typically include Gaussian filtering to suppress noise, and possible color space conversion (e.g., from RGB to HSV or Lab) to enhance the stability of color features.

[0005] Threshold-based color segmentation: Based on the known colors of the target blocks, a threshold range is set on appropriate color channels (such as the H and S channels in HSV) to binarize the image. Let the original image have pixels... The color vector at that location is After conversion to HSV space, it becomes Color segmentation is achieved through a threshold discrimination function: ;in, For the generated binary image, and These are the upper and lower thresholds for hue and saturation, respectively, usually obtained through experimental calibration. This yields a binary image. The white area (255) is the candidate target area, and the black background (0) is the target area.

[0006] Morphological post-processing: To eliminate small noise points, holes, and internal voids caused by surface reflection or color unevenness in the segmented image, morphological opening operations (erosion followed by dilation) and closing operations (dilation followed by erosion) are typically performed. Let the structuring element be... Corrosion and expansion operations are defined as follows:

[0007] .

[0008] Opening operation is Used to eliminate small objects and burrs; the closing operation is... It is used to fill small holes and connect adjacent areas.

[0009] Connectivity Analysis and Labeling: Connectivity analysis is performed on the processed binary image. The 8-connectivity criterion is typically used (for foreground pixels). The algorithm traverses the image, assigning a unique label to each connected white pixel region. Thus, the labeled image is obtained. Each connected component is considered a potential block-like entity.

[0010] Feature extraction and filtering: Calculate a series of geometric and grayscale features for each labeled connected component, such as area. ,perimeter Circumscribed rectangle, roundness, etc. Area is one of the most critical screening features, used to exclude excessively small areas caused by noise or excessively large areas caused by excessive adhesion. For the first... Connected components Its pixel area The calculation is as follows: By setting an area threshold and Initial screening identified connected components that fit within the size range of individual blocks: .

[0011] Center of gravity calculation and counting: For the first one that passed the screening A connected region, whose centroid coordinates We obtain the following by calculating the first moment (area moment) of all pixel coordinates within this region: .

[0012] Ultimately, the number of connected components that meet the area threshold condition. This represents the number of detected blocks, and the centroid coordinates of each connected component are the output results.

[0013] To address the issue of slight adhesion between bulk materials, existing techniques incorporate an adhesion segmentation sub-step after feature extraction. Common methods include: Contour segmentation based on concave point analysis: Extract the outer contour of a connected component and find concave points on the contour. If two concave points are paired and satisfy certain geometric relationships (such as distance and angle), then draw a dividing line between the pair of concave points to split a connected component into two.

[0014] The watershed algorithm based on distance transform involves performing a distance transform on a binary image to obtain a distance map from each foreground pixel to its nearest background pixel. Then, local maxima in the distance map are used as seed points, and the watershed algorithm is applied to simulate a water immersion process, dividing the image into regions based on the terrain (distance values). This method is effective for irregularly shaped adhesions.

[0015] Although the aforementioned color segmentation and connected component analysis-based techniques can work under ideal conditions, their inherent shortcomings become particularly apparent in practical industrial applications, especially when dealing with objects whose shape and orientation are unstable. These shortcomings severely affect the system's robustness, accuracy, and versatility. Specific drawbacks are as follows: (1) Inherent incompatibility between light sensitivity and color segmentation threshold setting: Existing solutions are highly dependent on preset fixed color thresholds. In actual production, even with a stable light source, subtle changes in ambient light, light source aging, camera white balance drift, and differences in reflection caused by changes in the orientation of object surfaces can all cause fluctuations in the actual color value of the target object in the image. A fixed threshold cannot adapt to these dynamic changes, easily leading to oversegmentation (mistaking background or shadows for the target) or undersegmentation (losing part of the target area), severely affecting the accuracy of subsequent analysis. Furthermore, the threshold requires frequent manual recalibration, increasing maintenance costs.

[0016] (2) Insufficient ability to handle internal cavities and edge depressions caused by changes in shape and posture: Due to the irregular shape and arbitrary posture of the block, this leads to two serious problems: Internal voids: When the surface of a block is uneven or has pits, and the angle of illumination happens to cast shadows on the pits, voids will be created in the target area after color segmentation. While existing morphological closing operations can fill small holes, for larger, irregular internal voids, simple closing operations may over-smooth the edges, alter the shape of the object, or even incorrectly connect two separate objects.

[0017] Edge depressions misidentified as adhesion points: Natural depressions in the shape of a block (not caused by adhesion) will form indentations on its contour. Existing adhesion segmentation algorithms (such as methods based on indentation analysis) are prone to misidentifying these intrinsic indentations as adhesion points, resulting in incorrect forced segmentation of a single object, counting one object as two or more, causing counting errors.

[0018] (3) The area threshold-based screening method fails when the object's posture changes: When the block's posture changes from flat to sideways or tilted, its projected area on the image is reduced. Significant changes will occur. A fixed area threshold range. It cannot cover all possible projected areas of the same object in different orientations. The area is largest when the object is laid flat, but may decrease sharply when it is on its side. This results in: an object on its side having a smaller area than... However, it may be missed during detection; or the projected area may exceed the limit due to the stacking of multiple objects. It is mistakenly considered as a single entity. Current technology lacks modeling of the dynamic relationship between the three-dimensional pose of an object and its two-dimensional projected area.

[0019] (4) The calculation of the centroid is greatly affected by the segmentation accuracy and is not the physical centroid: The centroid calculated by the existing scheme is based on the pixel geometric center of the connected components of the binary image. When the segmentation is inaccurate (such as the presence of holes or missing edges), the geometric center will deviate significantly from the true physical centroid of the object. In addition, for objects with non-uniform materials or varying thickness, the pixel geometric center and the mass centroid (physical centroid) may themselves deviate, and the latter is often the parameter that is more concerned about in applications such as robot grasping.

[0020] Therefore, existing technologies require a new scheme for detecting, counting, and locating the center of gravity of block objects to overcome the above problems and improve the accuracy of block object detection, counting, and center of gravity location. Summary of the Invention

[0021] In view of the above-mentioned shortcomings mentioned in the background art, the purpose of this invention is to provide a method and system for adaptive segmentation, counting and center of gravity positioning of block materials, so as to improve the accuracy of block detection, counting and center of gravity positioning.

[0022] Specifically, a first aspect of the present invention provides a method for adaptive segmentation, counting, and center-of-gravity positioning of blocky materials, the method comprising: Step S1: Perform adaptive color perception processing on the original image containing multiple block materials. Based on the similarity between pixel color and target material color, and combined with the local and global statistical characteristics of the image, generate foreground and background segmentation results to obtain the initial foreground region of the block materials. Step S2: Perform multi-scale morphological processing on the initial foreground region. Remove noise and repair the region by using structural features at different scales to generate a foreground region with enhanced connectivity. Step S3: In the connected foreground region, edge information is introduced and combined with a region growth strategy to fill the voids inside the foreground caused by changes in lighting or material posture, while preserving the real outer boundary of the material, thereby obtaining a precisely segmented foreground region. Step S4: For the precisely segmented foreground region, extract the contour features of the candidate materials, and distinguish between the material's own shape depressions and the adhesion depressions formed by the contact between materials through depression feature analysis. Only when the material is determined to be an adhesion depression will the corresponding region be segmented. Step S5: Perform attitude adaptive confirmation on each segmented candidate material region, and based on the confirmed valid individuals, calculate the center of gravity position of each block material, and output the number of block materials and the corresponding center of gravity positioning results.

[0023] As an example, step S1 specifically includes: analyzing the color information of each pixel in the original image, constructing a color similarity representation based on the similarity relationship between the pixel color and the target material color, and processing the color similarity representation by combining local statistical information within the pixel neighborhood and the overall statistical information of the original image, and generating a segmentation result of the foreground and background based on the processing result to obtain the initial foreground region of the block material.

[0024] As an example, step S2 specifically includes: selecting structural elements of various scales, performing morphological processing on the initial foreground region respectively, and combining the results obtained from the morphological processing at different scales to remove noise and repair the region in the initial foreground region, thereby generating a foreground region with enhanced connectivity.

[0025] As an example, step S3 specifically includes: performing edge detection processing in the connected foreground region to obtain corresponding edge information, constraining the boundary of the foreground region based on the edge information, performing region growing processing inside the foreground region under the constraint conditions, and filling the voids inside the foreground caused by changes in lighting or material posture to obtain a precisely segmented foreground region.

[0026] As an example, step S4 specifically includes: extracting the contour information of candidate materials based on the precisely segmented foreground region, detecting the depression positions in the contour, and distinguishing between material-shaped depressions and adhesion depressions formed by contact between materials by combining the geometric features corresponding to the depressions and the contour structure relationship, and segmenting the corresponding region when it is determined to be an adhesion depression.

[0027] As an example, step S5, which involves adaptively confirming the attitude of each segmented candidate material region, includes: extracting shape features from each segmented candidate material region and matching the shape features with a preset multi-pose material model to complete the adaptive confirmation of the attitude of the candidate material region.

[0028] A second aspect of the present invention provides an adaptive segmentation, counting, and center-of-gravity positioning system for blocky materials, the system comprising: An adaptive color perception and foreground segmentation module is used to perform adaptive color perception processing on an original image containing multiple block-shaped materials. Based on the similarity between pixel colors and target material colors, and combined with the local and global statistical characteristics of the image, it generates foreground and background segmentation results to obtain the initial foreground region of the block-shaped materials. A multi-scale morphological processing module is used to perform multi-scale morphological processing on the initial foreground region. Through structural features at different scales, it removes noise and repairs regions in the foreground region to generate a foreground region with enhanced connectivity. A hole-filling and edge-constraining processing module is used to introduce edge information into the foreground region with enhanced connectivity and combine it with a region growing strategy to further refine the foreground region. The module fills in the internal voids of the foreground caused by changes in lighting or material posture, while preserving the true outer boundary of the material, thus obtaining a precisely segmented foreground region. The concavity analysis and adhesion segmentation module extracts the contour features of candidate materials for the precisely segmented foreground region, distinguishes between concavities in the material's own shape and adhesion concavities formed by contact between materials through concavity feature analysis, and segments the corresponding region only when it is determined to be an adhesion concavity. The posture adaptive confirmation and center of gravity positioning module performs posture adaptive confirmation on each segmented candidate material region, and calculates the center of gravity position of each block material based on the confirmed valid individuals, outputting the number of block materials and the corresponding center of gravity positioning results.

[0029] A third aspect of the invention also provides a medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.

[0030] A fourth aspect of the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any of the preceding claims.

[0031] Compared with the prior art, the present invention has the following significant advantages: 1. By introducing local normalization and color similarity mapping, and combining it with Otsu's adaptive thresholding method, this invention effectively overcomes the sensitivity of fixed threshold segmentation to changes in illumination. Even under different batches and illumination conditions, it can achieve stable and accurate foreground target extraction, reducing over-segmentation and under-segmentation, and lowering the system maintenance frequency.

[0032] 2. The proposed multi-scale morphology combined with edge confidence-guided region growing and filling algorithm can intelligently identify and fill internal holes caused by shadows, while strictly protecting the boundaries of high-confidence real objects. This avoids edge blurring or shape distortion that may be caused by traditional closing operations, laying the foundation for subsequent accurate geometric analysis.

[0033] 3. The core innovative two-level concave point analysis model effectively distinguishes between concave points formed by the object's own shape and adhesive concave points formed by contact between objects by comprehensively evaluating multi-dimensional features such as concave point depth ratio, color consistency within the chord region, and support of the outer contour. This fundamentally solves the problem of over-segmentation caused by misjudging intrinsic concave points in existing technologies, significantly improving the accuracy of counting, especially when dealing with irregularly shaped blocks.

[0034] 4. A dynamic model matching strategy is adopted, which matches the region shape descriptor with a multi-pose reference model library and uses the dynamic area range corresponding to the matched pose for verification, replacing a single fixed area threshold. This enables the system to automatically adapt to the projection changes of the same object under different placement poses, significantly reducing the false negative and false positive rates caused by pose.

[0035] 5. Where possible, utilize 3D information or grayscale-thickness models for center of gravity estimation. The resulting center of gravity coordinates are closer to the object's true physical center of gravity than simply the geometric average of pixels. This has greater practical value for advanced applications such as robot grasping and balance detection.

[0036] The improvements in each of the above steps work together to form a robust, accurate, and adaptive complete detection chain. This invention is particularly suitable for complex industrial scenarios where colors are stable but shapes and postures are variable, and adhesion and shadows may exist. While ensuring a high detection rate, it has an extremely low false detection rate and superior positioning accuracy. Attached Figure Description

[0037] Figure 1 This is a flowchart illustrating an adaptive segmentation, counting, and center-of-gravity positioning method for block materials disclosed in an embodiment of the present invention.

[0038] Figure 2 This is a schematic diagram of the structure of an adaptive segmentation, counting, and center of gravity positioning system for block materials disclosed in an embodiment of the present invention. Detailed Implementation

[0039] 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.

[0040] Please see Figure 1 This invention provides an adaptive segmentation, counting, and centroid localization method for blocky materials. The method includes the following steps: Step S1, performing adaptive color perception processing on an original image containing multiple blocky materials. Based on the similarity relationship between pixel colors and target material colors, and combined with the local and global statistical characteristics of the image, foreground and background segmentation results are generated to obtain the initial foreground region of the blocky materials. This step aims to achieve stable and accurate foreground extraction of blocky materials, overcoming the sensitivity of a fixed color threshold to changes in illumination. Specifically, the implementation includes: First, processing the input RGB image... Instead of directly converting to the HSV color space, a color similarity map is calculated. Used to quantize the color of each pixel relative to the target reference color. The degree of similarity. The target reference color can be manually selected from the initial frame or learned automatically.

[0041] To mitigate the effects of uneven illumination, local illumination compensation is introduced. A local neighborhood is defined. (For example, a 5x5 window), calculate the mean color of the pixels within that neighborhood. and standard deviation vector For the current pixel color Perform local standardization: ;in, To prevent division by zero for small constants. For the target reference color. Standardization is also performed based on global image statistics (or using statistics from the training set). Understandably, the standardized vectors suppress the effects of uneven illumination to some extent.

[0042] Next, calculate the lighting-robust color similarity. A variant of Mahalanobis distance is used, taking into account color angle similarity:

[0043] ; in, This is an estimate of the global color covariance matrix, or it can be simplified by using a diagonal matrix. The final similarity score combines distance and angle. ;in, , It is about adjusting the weight parameters. . The closer the value is to 1, the closer the pixel color is to the target material.

[0044] get After the graph, instead of setting a fixed threshold, an adaptive thresholding method is used: Calculate The histogram of the entire image was used to automatically find the optimal threshold using Otsu's method. ,Will Figure 2 Value-based foreground mask : .

[0045] This method enables the segmentation threshold to be automatically adjusted according to the overall color distribution of the current image, achieving strong robustness to changes in illumination, thereby obtaining the initial foreground region of the blocky material.

[0046] Step S2 involves performing multi-scale morphological processing on the initial foreground region. This involves removing noise and insulating the foreground region using structural features at different scales, generating a foreground region with enhanced connectivity. The initially segmented region... It may contain noise and voids. This step uses multi-scale morphology to enhance the connectivity of the foreground region.

[0047] Specifically, define a set of structural elements ,in Representative scale, Minimum (e.g., 3×3). Maximum (e.g., 9×9).

[0048] First, multi-scale opening operations are performed to remove noise of different magnitudes: , .

[0049] Take the intersection of these results as the final denoising result: Understandably, the intersection operation preserves stable regions that are considered foreground at all scales, effectively filtering out isolated noise points of varying scales.

[0050] Next, multi-scale closing operations are performed to fill holes and cracks of different scales: .

[0051] Take the union of these results as the initial repair result: Understandably, the union operation ensures that any holes that a structuring element of any scale can fill are filled, resulting in a foreground region with enhanced connectivity.

[0052] Step S3: In the enhanced connectivity foreground region, edge information is introduced and combined with a region growing strategy to fill the internal holes in the foreground caused by changes in lighting or material posture, while preserving the real outer boundary of the material, thus obtaining a precisely segmented foreground region. To further handle large-area holes caused by shadows and protect the boundaries of real objects, this step uses an edge-guided region growing and filling algorithm, as follows: (1) Edge extraction and confidence calculation: for Apply Canny edge detection to obtain the set of edge pixels. For each edge pixel Calculate its marginal confidence. : ;in, For gradient magnitude, This is the value of the pixel in the color similarity map. High-confidence edges are considered as true object boundaries.

[0053] (2) Seed point selection and region growth: All non-edge foreground pixels are used as initial seed points. Simultaneously, the boundaries of closed holes within the holes are identified, and the points with the lowest edge confidence on these boundaries are used as filling seed points.

[0054] (3) Growth and Filling: Starting from all seed points, in Region growing is performed within the complement of the set. The growing rule is: new pixel Satisfies: 4-connected to the current region; its color similarity Above the lower threshold (e.g., 0.3); does not cross the high confidence margin (i.e.) (edge ​​point).

[0055] Growth continues until no more new pixels can be added, resulting in a filled binary image. This achieves precise filling of voids and protection of real boundaries.

[0056] Step S4: For the precisely segmented foreground region, extract the contour features of the candidate materials. Distinguish between material-specific depressions and adhesion depressions formed by contact between materials through depression feature analysis. Segmentation is only performed on the corresponding regions identified as adhesion depressions. In this step, when... Each connected component in Extract its outermost contour The intrinsic depressions and adhesion depressions are distinguished by a two-level depression analysis model.

[0057] Level 1: Candidate concave point detection. Approximating the contour using polygons. , thus obtaining the vertex sequence Calculate each vertex Local curvature : ;in, This represents the cross product (scalar) of two-dimensional vectors. If ( If so, then determine Candidate concave points are obtained, resulting in a set of candidate concave points. , .

[0058] Level 2: Concave type identification. For each pair of candidate concave points... Calculate the following features: Concave depth ratio :set up and The chord length between the contours is Calculate separately and to the string vertical distance and Define the depth ratio of the concave points. : .

[0059] The depressions formed by adhesions are usually shallow and wide, that is... Smaller; while the intrinsic indentation of the object itself may be deeper and narrower, i.e., larger. Set a threshold. .

[0060] Intrachordal consistency In a binary graph In the middle, consider using the string A rectangular area along the diagonal Calculate the color similarity of the foreground pixels within the rectangular region. average and variance For adhesion pits, the area within the chord is typically the background or the gap between two objects. The values ​​are low and may have high variance (due to the mixing of background and object edges). For intrinsic concave points, the in-chord region is still part of the object, and its... The values ​​should be high and relatively uniform. Define an intrachordal region consistency measure: ,in These are the weighting coefficients.

[0061] extrachordal support In the outline Take from above, respectively front and back The contour points form a local arc segment. Similarly, .analyze and The direction of the curves. For adhesion, the outer contour arcs of the two concave points are usually roughly parallel, jointly supporting a narrow connecting bridge. Calculate the angle between the average direction vectors of the outer contour arcs of the two concave points. .like When the temperature is close to 0 degrees, the support is strong.

[0062] The decision rule is: establish a discriminant function. : .in As weight, The empirical thresholds for each feature.

[0063] like Then determine Adhesive dimples need to be aligned with the string. Divide the space by drawing a dividing line near the midpoint. If If it is a concave point, it is determined to be an intrinsic concave point and is retained.

[0064] like If the points are determined to be a pair of adherent concave points, draw a dividing line near the midpoint of the chord; if It was determined to be an intrinsic concave point and was retained.

[0065] Step S5: Perform attitude adaptive confirmation on each segmented candidate material region, and based on the confirmed valid individuals, calculate the center of gravity position of each block material, and output the number of block materials and the corresponding center of gravity positioning results.

[0066] In this step, after adhesion and segmentation, a series of final segmented regions are obtained. To address area fluctuations caused by changes in posture, a single fixed area threshold is abandoned.

[0067] First, for each region Calculate multi-scale shape descriptor vectors , including area ,perimeter Hu moment invariant, compactness The aspect ratio of the minimum bounding rectangle .

[0068] Then, a reference model library for the target object is pre-defined or learned, containing ideal shape descriptor vectors for typical poses. and corresponding projected area range This library contains ideal shape descriptor vectors for the block in several typical postures (such as lying flat, standing on its side, or tilted at a certain angle). And the corresponding projected area range for each posture. These parameters can be obtained through CAD model projection or statistical analysis of collected sample images.

[0069] During online matching, for each region to be confirmed Calculate its descriptor With all reference models The similarity (e.g., using cosine similarity or Mahalanobis distance) is used to find the best-matching model. : .

[0070] Inspection area area Does it fall within the projected area range corresponding to the matching model? If satisfied, then confirm. A shape is considered a valid block-shaped individual object. If it doesn't meet the criteria (e.g., its area is too large), it may indicate oversegmentation (an object being mistakenly divided into multiple parts) or stacking. In such cases, color and texture information can be combined for further judgment or to trigger more complex 3D analysis. This strategy of first matching the shape and then dynamically verifying the area greatly enhances adaptability to changes in pose.

[0071] For areas confirmed as valid individuals This requires calculating its physical center of gravity. Assume the block is made of uniform material, and its thickness may vary in the direction perpendicular to the imaging plane (Z-axis), but its 3D shape model is known (or its surface point cloud is obtained through depth mapping using binocular vision, structured light, etc.). ).

[0072] Assuming the camera is calibrated, pixel coordinates It can be obtained through the camera intrinsic parameter matrix and depth value Back projection onto three-dimensional space points For monocular systems, if the object is placed flat and the equation of the supporting plane is known, it can also be approximated.

[0073] Method 1 (based on uniform density and 3D geometry): If a precise 3D model or point cloud is known, the physical centroid... This can be obtained by calculating the average value of all three-dimensional points: .

[0074] in, This is the number of points in the point cloud that belong to the object. The final output is its projection onto the image plane. .

[0075] Method 2 (Based on 2D Image Grayscale and Prior Thickness Model): If only a monocular grayscale / color image is available, but the relationship between object thickness and its surface brightness or color is known (e.g., thicker parts have poorer light transmission and appear darker, or the sprayed color is darker), a grayscale-thickness mapping model is established. This function can be obtained through calibration. Therefore, the pixel... The mass of the infinitesimal element at that point can be considered to be equal to the estimated thickness. Proportional. Therefore, the coordinates of the physical center of gravity on the image plane are... It can be estimated as follows: .

[0076] The centroid obtained by this method takes into account the thickness distribution and is closer to the physical centroid than a simple pixel geometric center. If the thickness is uniform, it degenerates into a geometric center.

[0077] Finally, the total number of detected blocky objects is output. And a list of the centroid coordinates of each block. .

[0078] Please see Figure 2 This invention also provides an adaptive segmentation, counting, and centroid localization system 200 for block materials. The system includes: an adaptive color perception and foreground segmentation module 201, used to perform adaptive color perception processing on an original image containing multiple block materials, generating foreground and background segmentation results based on the similarity between pixel colors and target material colors, combined with the local and global statistical characteristics of the image, to obtain an initial foreground region for the block materials; a multi-scale morphological processing module 202, used to perform multi-scale morphological processing on the initial foreground region, removing noise and repairing regions in the foreground region through structural features at different scales, generating a foreground region with enhanced connectivity; and a hole filling and edge constraint processing module 203, used to... In the scene area, edge information is introduced and combined with a region growing strategy to fill the internal voids in the foreground caused by changes in lighting or material posture, while preserving the real outer boundary of the material to obtain a precisely segmented foreground area; the depression analysis and adhesion segmentation module 204 is used to extract the contour features of candidate materials for the precisely segmented foreground area, and to distinguish between the depressions of the material's own shape and the adhesion depressions formed by the contact between materials through depression feature analysis, and to segment the corresponding area only when it is determined to be an adhesion depression; the posture adaptive confirmation and center of gravity positioning module 205 is used to perform posture adaptive confirmation on each candidate material area after segmentation, and to calculate the center of gravity position of each block material based on the confirmed valid individuals, and output the number of block materials and the corresponding center of gravity positioning results.

[0079] As an example, the adaptive color perception and foreground segmentation module 201 is specifically used to: analyze the color information of each pixel in the original image, construct a color similarity representation based on the similarity relationship between the pixel color and the target material color, and process the color similarity representation by combining local statistical information within the pixel neighborhood and the overall statistical information of the original image, and generate a segmentation result of the foreground and background based on the processing result to obtain the initial foreground region of the block material.

[0080] As an example, the multi-scale morphological processing module 202 is specifically used to: select structural elements of various scales, perform morphological processing on the initial foreground region respectively, and combine the results obtained from the morphological processing at different scales to remove noise and repair the region in the initial foreground region, thereby generating a foreground region with enhanced connectivity.

[0081] As an example, the void filling and edge constraint processing module 203 is specifically used to: perform edge detection processing in a foreground region with enhanced connectivity to obtain corresponding edge information, constrain the boundary of the foreground region based on the edge information, perform region growth processing inside the foreground region under the constraint conditions, and fill the voids inside the foreground region caused by changes in lighting or material posture to obtain a precisely segmented foreground region.

[0082] As an example, the depression analysis and adhesion segmentation module 204 is specifically used to: extract the contour information of candidate materials based on the precisely segmented foreground region, detect the depression positions in the contour, and distinguish between the depressions of the material's own shape and the adhesion depressions formed by the contact between the materials by combining the geometric features and contour structure relationships corresponding to the depressions, and segment the corresponding region when it is determined to be an adhesion depression.

[0083] As an example, the attitude adaptive confirmation and center of gravity localization module 205 is specifically used to: extract shape features from each segmented candidate material region, and match the shape features with a preset multi-pose material model to complete the attitude adaptive confirmation of the candidate material region.

[0084] This invention also provides a medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.

[0085] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the preceding claims.

[0086] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for adaptive segmentation, counting, and center of gravity positioning of blocky materials, characterized in that, The method includes the following steps: Step S1, performing adaptive color perception processing on the original image containing multiple block materials, generating foreground and background segmentation results based on the similarity relationship between pixel color and target material color, combined with the local and global statistical characteristics of the image, so as to obtain the initial foreground region of the block materials. Step S2: Perform multi-scale morphological processing on the initial foreground region. Noise removal and region repair are performed on the foreground region using structural features at different scales to generate a foreground region with enhanced connectivity. Step S3: In the foreground region with enhanced connectivity, edge information is introduced and combined with a region growing strategy to fill the internal voids caused by changes in lighting or material posture, while preserving the true outer boundary of the material, resulting in a precisely segmented foreground region. Step S4: For the precisely segmented foreground region, the contour features of candidate materials are extracted. Depression feature analysis distinguishes between material shape depressions and adhesion depressions formed by contact between materials, and segmenting is only performed on regions identified as adhesion depressions. Step S5: The posture of each segmented candidate material region is adaptively confirmed. Based on the confirmed valid individuals, the center of gravity position of each block material is calculated, and the number of block materials and the corresponding center of gravity positioning results are output.

2. The method for adaptive segmentation, counting, and center of gravity positioning of block materials according to claim 1, characterized in that: Step S1 specifically includes: analyzing the color information of each pixel in the original image, constructing a color similarity representation based on the similarity relationship between the pixel color and the target material color, and processing the color similarity representation by combining local statistical information within the pixel neighborhood and the overall statistical information of the original image, and generating a segmentation result of the foreground and background based on the processing result to obtain the initial foreground region of the block material.

3. The method for adaptive segmentation, counting, and center of gravity positioning of block materials according to claim 2, characterized in that: Step S2 specifically includes: selecting structural elements of various scales, performing morphological processing on the initial foreground region respectively, and combining the results obtained from the morphological processing at different scales to remove noise and repair the region in the initial foreground region, thereby generating a foreground region with enhanced connectivity.

4. The method for adaptive segmentation, counting, and center of gravity positioning of block materials according to claim 3, characterized in that: Step S3 specifically includes: performing edge detection processing in the connected foreground region to obtain corresponding edge information, constraining the boundary of the foreground region based on the edge information, performing region growing processing inside the foreground region under the constraint conditions, and filling the voids inside the foreground caused by changes in lighting or material posture to obtain a precisely segmented foreground region.

5. The method for adaptive segmentation, counting, and center of gravity positioning of block materials according to claim 4, characterized in that: Step S4 specifically includes: extracting the contour information of candidate materials based on the precisely segmented foreground region, detecting the depression positions in the contour, and distinguishing between material-shaped depressions and adhesion depressions formed by contact between materials by combining the geometric features corresponding to the depressions and the contour structure relationship. When an adhesion depression is determined, the corresponding region is segmented.

6. The method for adaptive segmentation, counting, and center of gravity positioning of block materials according to claim 5, characterized in that: In step S5, the attitude adaptive confirmation of each segmented candidate material region is performed, including: extracting shape features from each segmented candidate material region and matching the shape features with a preset multi-pose material model to complete the attitude adaptive confirmation of the candidate material region.

7. A system for adaptive segmentation, counting, and center of gravity positioning of block materials, characterized in that: The system includes: an adaptive color perception and foreground segmentation module, used to perform adaptive color perception processing on an original image containing multiple block-shaped materials, generating foreground and background segmentation results based on the similarity between pixel colors and target material colors, combined with the local and global statistical characteristics of the image, to obtain the initial foreground region of the block-shaped materials; a multi-scale morphological processing module, used to perform multi-scale morphological processing on the initial foreground region, removing noise and repairing regions in the foreground region through structural features at different scales, generating a foreground region with enhanced connectivity; and a hole filling and edge constraint processing module, used to introduce edge information and combine it with a region growing strategy in the foreground region with enhanced connectivity. The system briefly describes several steps: First, it fills the internal voids in the foreground caused by changes in lighting or material posture, while preserving the true outer boundaries of the material, resulting in a precisely segmented foreground region. Second, it uses a depression analysis and adhesion segmentation module to extract the contour features of candidate materials within the precisely segmented foreground region. It distinguishes between depressions in the material's own shape and adhesion depressions formed by contact between materials through depression feature analysis, segmenting the corresponding region only when it is determined to be an adhesion depression. Third, it uses a posture adaptive confirmation and center of gravity positioning module to perform posture adaptive confirmation on each segmented candidate material region. Based on the confirmed valid individuals, it calculates the center of gravity position of each block material, outputting the number of block materials and the corresponding center of gravity positioning results.

8. The adaptive segmentation, counting, and center-of-gravity positioning system for blocky materials according to claim 7, characterized in that: The adaptive color perception and foreground segmentation module is specifically used to: analyze the color information of each pixel in the original image, construct a color similarity representation based on the similarity relationship between the pixel color and the target material color, process the color similarity representation by combining local statistical information within the pixel neighborhood and the overall statistical information of the original image, and generate the foreground and background segmentation results based on the processing results to obtain the initial foreground region of the block material.

9. A medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.