A method for detecting brick and stone parameters of brick-built structure walls based on image recognition
Through the image recognition method, the geometric parameters and distribution characteristics of masonry units are calculated, and the problems of low efficiency and poor accuracy of traditional manual detection are solved, and efficient and accurate detection and evaluation of brick structure walls are achieved.
Patent Information
- Application Number
- CN202510094032.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-01-21
AI Technical Summary
The traditional method of manual inspection of brick wall surface masonry parameters is inefficient and has poor accuracy, making it difficult to meet the high-demand inspection requirements and engineering quality inspection requirements.
Using an image recognition method, by obtaining brick wall images, pre-processing, inputting the SAM model to generate a segmentation mask image, performing binarization, open operation and closed operation, detecting the contour and edge of the masonry unit, calculating parameters such as geometric moment, area, and perimeter. Combining distribution uniformity, irregular shape parameters and divergence, the classification and evaluation of masonry units are realized.
The efficiency and accuracy of masonry parameter detection is improved, the reliability and comprehensiveness of the inspection results are ensured, the masonry areas under complex backgrounds can be identified, artificial errors can be reduced, and a comprehensive analysis of brick structure walls can be achieved.
Smart Images

Figure CN119941701B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wall brick and stone detection, and particularly relates to a method for detecting the parameters of wall bricks and stones in a brick structure based on image recognition. Background Art
[0002] As a traditional building structure form, the brick structure has a wide range of raw material sources and is easy to obtain. The process is simple and does not require formwork and special construction equipment, which enables the brick structure to save a large amount of building structures such as cement, steel, and wood, thereby reducing the project cost. Therefore, the brick structure has been widely used in construction projects.
[0003] The engineering quality inspection of the brick structure is of great significance for ensuring the safety, stability, and long-term service life of brick-structured buildings. It is very necessary to extract the parameters of the brick and stone materials on the surface of the wall in the brick structure. The traditional method for detecting the parameters of the brick and stone on the surface of the brick-structured wall is generally manual inspection. The parameters of the brick and stone are extracted by directly observing visually by hand in combination with auxiliary detection tools. This method not only has low efficiency, but also may cause errors due to human factors or the factors of the detection tools themselves. The parameter extraction accuracy is poor, the detection effect is poor, and it is difficult to meet the accuracy requirements for extracting the parameters of the wall bricks and stones and the high requirements for the engineering quality inspection of the brick structure. Summary of the Invention
[0004] In view of the above problems in the prior art, the present invention provides a method for detecting the parameters of wall bricks and stones in a brick structure based on image recognition, which solves the problems of low efficiency and large errors in manually detecting the parameters of the wall bricks and stones on the surface of the brick structure.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is as follows:
[0006] Provide a method for detecting the parameters of wall bricks and stones in a brick structure based on image recognition, including the steps of:
[0007] S1. Obtain a detection image of the brick wall and preprocess the detection image.
[0008] S2. Input the preprocessed detection image into the SAM model to generate a segmentation mask image identifying the brick and stone area.
[0009] S3. Perform binaryzation, opening operation, and closing operation on the segmentation mask image in sequence, and perform edge detection on the processed segmentation mask image to obtain the contour of the brick and stone unit; read the position data of all pixel points in the processed segmentation mask image to obtain the number of the brick and stone unit and the corresponding pixel point coordinates.
[0010] S4. Calculate the geometric moment, perimeter, and minimum bounding rectangle of each masonry unit based on its contour and pixel coordinates, and obtain the area of the corresponding masonry unit through the geometric moment.
[0011] S5. Calculate the area ratio of each masonry unit to the detected image according to the area of each masonry unit, classify each masonry unit based on the area ratio and the width-to-height ratio of the minimum bounding rectangle, and calculate the masonry distribution uniformity. The masonry distribution uniformity reflects whether the masonry units are evenly distributed in the entire wall structure. By controlling the masonry distribution uniformity, the situation of local over-density or over- sparsity can be avoided, thus ensuring the consistency of the wall.
[0012] S6. Calculate the shape irregularity parameter of each masonry unit according to the perimeter and classification information of each masonry unit, and perform weighted processing on the shape irregularity parameter of each masonry unit to obtain the wall shape irregularity characterization parameter. The shape irregularity parameter reflects the edge complexity and shape regularity of a single masonry unit. It measures the degree to which the masonry unit approaches a circle or a square through the relationship between the perimeter and the area, thereby helping to identify those masonry units whose shapes deviate significantly from the expected standard and indicating manufacturing defects or construction problems. The wall shape irregularity characterization parameter can evaluate the complexity of the internal structure of the wall, which is very important for predicting the mechanical behavior and long-term performance of the wall. A complex shape may lead to stress concentration, affecting the stability and durability of the wall.
[0013] S7. Calculate the masonry aggregation and dispersion degree according to the area, perimeter, and pixel coordinates of each masonry unit. The masonry aggregation and dispersion degree can quantify whether the masonry units tend to aggregate together or are evenly dispersed. By identifying whether there are abnormal aggregation or dispersion phenomena in certain areas, potential construction problems or design defects can be indicated.
[0014] In this solution, each masonry unit is classified by combining the width-to-height ratio of its minimum bounding rectangle and its area ratio. Compared with the method of classifying masonry units only by area ratio, the accuracy of masonry unit classification is improved. By calculating the masonry distribution uniformity, shape irregularity parameter, and aggregation and dispersion degree, the masonry and the wall are quickly detected and evaluated, reflecting the current state of the masonry and the wall, solving the limitations existing in the current traditional artificial detection-based masonry of brick-built structure walls, not only improving the detection efficiency, but also realizing the comprehensive and objective analysis of the feasibility of masonry detection of brick-built structure walls, and ensuring the reliability and authenticity of the masonry detection analysis results of brick-built structure walls.
[0015] Further, the preprocessing of the detected images includes: using the PIL image processing library to unify the image resolutions of all detected images, and performing denoising processing on each detected image through Gaussian filtering. Ensure the consistency of all input images, provide clearer images for subsequent analysis, and thus improve the accuracy of the detection results.
[0016] Further, the th masonry unit is denoted as , and its geometric moments are:
[0017]
[0018] where is the th moment of the th masonry unit, and are both non - negative integers, is a natural number; and are the width and height of the detected image respectively; and are the sets of abscissas and ordinates of the edge pixel points of the th masonry unit respectively, and are the position index variables of the detected image in the width direction and height direction respectively, is the gray value of the pixel point with coordinates . Geometric moments are used to describe the mathematical features of an object's shape, and can extract the precise position and morphological information of the masonry unit from the segmentation mask image, providing basic data for further size measurement and classification. Among them, the 0 - th moment is used to obtain the area of the masonry unit, the 1 - st moment is used to calculate the centroid coordinates of the masonry unit, and the 2 - nd moment is used to describe the direction and shape characteristics of the masonry unit, such as the directions of the major axis and minor axis.
[0019] Further, 's area ratio is:
[0020]
[0021] where is the area ratio of , is the area of , and , ; and are the width and height of the detected image respectively.
[0022] Further, the method for obtaining the minimum bounding rectangle of includes:
[0023] S4.1. Obtain the convex hull of all the pixel points in and get all the convex hull points of the convex hull. Rotate all the edges of the convex hull to the coordinate axes in sequence, and obtain the rotated coordinates of all the convex hull points on the convex hull during each rotation;
[0024] S4.2. Obtain the four corner points of the convex hull during each rotation through the coordinate extreme values of the rotated coordinates of all the convex hull points during each rotation, and obtain a circumscribed rectangle;
[0025] S4.3. Calculate the areas of all the circumscribed rectangles obtained during the rotation process, and use the circumscribed rectangle with the smallest area as the minimum circumscribed rectangle of;
[0026] S4.4. The aspect ratio of the width to the height of the minimum circumscribed rectangle of is:
[0027]
[0028] Among them, is the aspect ratio of the width to the height of the minimum circumscribed rectangle, that is, the aspect ratio of the width to the height of , is the width value of the minimum circumscribed rectangle, is the height value of the minimum circumscribed rectangle.
[0029] Furthermore, the method for obtaining the convex hull of includes:
[0030] S4.11. Pair up all the points in to construct lines, where, is the combination number, is the number of points in;
[0031] S4.12. Judge in sequence whether all the remaining points on each line are all on the same side of the line. If so, the line is used as one side of the convex hull; otherwise, no action is taken.
[0032] S4.13. Connect the heads and tails of all the lines used as one side of the convex hull in sequence to obtain the convex hull of.
[0033] Furthermore, the calculation method for the uniformity of brick distribution is:
[0034] ,
[0035] Among them, is the uniformity of brick and stone distribution; is the total number of brick and stone categories in all brick and stone units, is the ratio of the total number of brick and stone units in the category of brick and stone. When the MUI value is closer to 1, it indicates that the distribution of brick and stone types in the detected image is uniform. On the contrary, the lower the degree of uniform distribution;
[0036] Furthermore, the expression for calculating the shape irregularity parameter of each brick and stone unit is:
[0037] ,
[0038] where, is the shape irregularity parameter of the th brick and stone unit in the category of brick and stone; is the th brick and stone unit in the category of brick and stone; is the th brick and stone unit in the category of brick and stone; is the number of the category of brick and stone; is the total number of brick and stone categories in all brick and stone units; and are both natural numbers.
[0039] Furthermore, the expression for calculating the shape irregularity characterization parameter of the wall is:
[0040]
[0041] where, is the shape irregularity characterization parameter of the wall; is the th brick and stone unit in the category of brick and stone; is the th brick and stone unit in the category of brick and stone.
[0042] Furthermore, the calculation method for calculating the aggregation and dispersion degree of brick and stone is:
[0043] ,
[0044] where, is the brick and stone aggregation degree; is the area of the th masonry unit in the type of masonry; is the perimeter of the th masonry unit in the type of masonry; and are the width and height of the detected image respectively.
[0045] The present invention discloses a method for detecting masonry parameters of a brick - built structure wall based on image recognition, and its beneficial effects are as follows:
[0046] 1. By calculating the masonry distribution uniformity, shape irregularity parameter and dispersion degree, the present invention quickly detects and evaluates the masonry and the wall, reflects the current state of the masonry and the wall, solves the limitations existing in the current traditional brick - built structure wall based on manual detection, not only improves the detection efficiency, but also realizes the comprehensive and objective analysis of the feasibility of masonry detection in brick - built structure walls, and ensures the reliability and authenticity of the detection and analysis results of the masonry in brick - built structure walls.
[0047] 2. The present invention has high recognition accuracy and recognition efficiency. Compared with the traditional method of manually detecting brick - built structure walls, the present invention can identify the brick - built wall area under complex backgrounds, accurately extract the masonry parameters of brick - built structures under images of different unit sizes, improve the accuracy of detection data, and avoid errors caused by human factors or environmental factors. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a schematic flow chart of a method for detecting masonry parameters of a brick - built structure wall based on image recognition;
[0049] Figure 2 are multiple detected images;
[0050] Figure 3 is a segmentation mask image;
[0051] Figure 4 is a binarized segmentation mask image;
[0052] Figure 5 is a schematic diagram of the extracted contour edge;
[0053] Figure 6 are the minimum circumscribed rectangles of multiple masonry units. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0054] The specific embodiments of the present invention will be described below to facilitate those skilled in the art to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions and creations using the concept of the present invention are within the scope of protection.
[0055] Reference Figure 1 , this embodiment provides a method for detecting brick and stone parameters of a brick-built structure wall based on image recognition, including the steps:
[0056] S1. Obtain the detection image of the brick-built wall and preprocess the detection image. In this embodiment, a mobile phone camera is directly used to take pictures of the brick wall under natural light conditions. Some of the detection images are for reference Figure 2 . And in this embodiment, the PIL image processing library is used to modify the image resolution of all detection images to obtain brick wall images with the same resolution of 1000*1500, and the image is denoised by Gaussian filtering to reduce the influence of noise.
[0057] S2. Input the preprocessed detection image into the SAM model to generate a segmentation mask image identifying the brick and stone area, for reference Figure 3 .
[0058] S3. Perform binaryzation, opening operation, and closing operation on the segmentation mask image in sequence. Specifically, the foreground and background in the input binary image are clarified. In this embodiment, the foreground of the binary image is marked as 1 for bricks and stones, and the background is marked as 0 for the background. By performing the opening operation, first perform the erosion operation and then the dilation operation to obtain the effect of removing noise in the background. The effect diagram is as Figure 4 shown.
[0059] Step S2 and obtain the contour of the brick and stone unit by performing edge detection on the processed segmentation mask image, as Figure 5 shown, and obtain the number of the brick and stone unit and the corresponding pixel point coordinates by reading the position data of all pixel points in the processed segmentation mask image.
[0060] S4. According to the contour and pixel point coordinates of each brick and stone unit, calculate the geometric moment, perimeter, and minimum bounding rectangle of the corresponding brick and stone unit, and obtain the area of the corresponding brick and stone unit through the geometric moment. The minimum bounding rectangle is as Figure 6 shown.
[0061] In this embodiment, the th brick and stone unit is denoted as , The geometric moment of which is:
[0062]
[0063] Among them, is the th moment of the th masonry unit, and are both non - negative integers, is a natural number; and are the width and height of the detected image respectively; and are the set of abscissa and the set of ordinate of the edge pixel points of the th masonry unit respectively, and are the position index variables of the detected image in the width direction and height direction respectively, is the gray value of the pixel point with coordinates . Geometric moments are used to describe the mathematical features of object shapes and can extract the precise position and morphological information of masonry units from the segmentation mask image, providing basic data for further size measurement and classification. Among them, the 0 - th moment is used to obtain the area of the masonry unit, the 1 - st moment is used to calculate the centroid coordinates of the masonry unit, and the 2 - nd moment is used to describe the direction and shape characteristics of the masonry unit, such as the directions of the major axis and minor axis.
[0064] S5. Calculate the area ratio of each masonry unit to the detected image according to the area of each masonry unit.
[0065] The area ratio of
[0066]
[0067] is: is the area ratio of is the area of , and ; and are the width and height of the detected image respectively.
[0068] Classify each masonry unit through the area ratio of each masonry unit and the width - to - height ratio of the minimum bounding rectangle, and calculate the masonry distribution uniformity. The masonry distribution uniformity reflects whether the masonry units are evenly distributed in the entire wall structure. By controlling the masonry distribution uniformity, the situation of local over - density or over - sparsity can be avoided, thus ensuring the consistency of the wall.
[0069] The expression for calculating the masonry distribution uniformity is:
[0070] ,
[0071] Among them, is the uniformity of brick distribution; is the total number of brick categories in all brick units, is the ratio of the total number of brick units in the category of bricks to the total number of brick units.
[0072] S6. According to the perimeter and classification information of each brick unit, calculate the shape irregularity parameter of each brick unit, and perform weighted processing on the shape irregularity parameter of each brick unit to obtain the wall shape irregularity characterization parameter. The shape irregularity parameter reflects the edge complexity and shape regularity of a single brick unit, and it measures the degree to which the brick unit approaches a circular or square shape through the relationship between the perimeter and the area, thereby helping to identify those brick units whose shapes deviate significantly from the expected standard and indicating manufacturing defects or construction problems. The wall shape irregularity characterization parameter can evaluate the complexity of the internal structure of the wall, which is very important for predicting the mechanical behavior and long-term performance of the wall. A complex shape may lead to stress concentration, affecting the stability and durability of the wall.
[0073] In this embodiment, the expression for calculating the shape irregularity parameter of the th brick unit in the category of bricks is:
[0074] ,
[0075] Among them, is the shape irregularity parameter of the th brick unit in the category of bricks; is the area of the th brick unit in the category of bricks; is the perimeter of the th brick unit in the category of bricks; is the number of the category of bricks; is the total number of brick units; is the total number of brick categories in all brick units; and are both natural numbers.
[0076] In this embodiment, the expression for calculating the wall shape irregularity characterization parameter is:
[0077]
[0078] Among them, is the characterization parameter of the irregular wall shape; is the th irregularity parameter of the th brick unit in the th type of brick and stone;
[0079] S7. Calculate the degree of aggregation and dispersion of bricks and stones based on the area, perimeter, and pixel coordinates of each brick and stone unit. The degree of aggregation and dispersion of bricks and stones can quantify whether this type of brick and stone unit tends to aggregate together or disperse evenly. By identifying whether there are abnormal aggregation or dispersion phenomena in certain areas, potential construction problems or design defects can be indicated.
[0080] In this embodiment, the expression for calculating the degree of aggregation and dispersion of bricks and stones is:
[0081] ,
[0082] Among them, is the degree of brick aggregation; is the th area of the th brick unit in the th type of brick and stone; is the perimeter of the th brick unit in the th type of brick and stone;
[0083] As a further solution of this embodiment, the method for obtaining the minimum circumscribed rectangle of includes:
[0084] S4.1. Obtain the convex hull of all pixel points enclosing and get all the convex hull points of the convex hull. Rotate all the edges of the convex hull to the coordinate axes in turn, and obtain the rotated coordinates of all the convex hull points on the convex hull each time during the rotation process.
[0085] The method for obtaining the convex hull of includes:
[0086] S4.11. Pair up all the points in to construct lines, , where, is the combination number, is the number of midpoints.
[0087] S4.12. Sequentially determine whether all the remaining points on each straight line are all on the same side of the straight line. If so, the straight line is used as one side of the convex hull; otherwise, no action is taken.
[0088] S4.13. Connect the straight lines that are used as one side of the convex hull end to end in sequence to obtain the convex hull.
[0089] S4.2. Obtain the four corner points of the convex hull during each rotation process and get a circumscribed rectangle through the coordinate extreme values of the rotation coordinates of all the convex hull points during each rotation process.
[0090] S4.3. Calculate the areas of all the circumscribed rectangles obtained during the rotation process, and use the circumscribed rectangle with the smallest area among them as the smallest circumscribed rectangle.
[0091] S4.4. Calculate the width and height of the smallest circumscribed rectangle, which are the width and height of the irregular-shaped masonry. Calculate the aspect ratio:
[0092]
[0093] where is the aspect ratio of the smallest circumscribed rectangle of is the width value of the smallest circumscribed rectangle of is the height value of the smallest circumscribed rectangle.
[0094] In summary, the beneficial effects of this solution are as follows:
[0095] This solution classifies each masonry unit by combining the aspect ratio of the smallest circumscribed rectangle of each masonry unit and its area proportion. Compared with the method of classifying masonry units only by area proportion, the accuracy of masonry unit classification is improved. By calculating the masonry distribution uniformity, shape irregularity parameter, and degree of aggregation and dispersion, the masonry and the wall are quickly detected and evaluated, reflecting the current state of the masonry and the wall, solving the limitations existing in the traditional manual inspection-based masonry of brick-built structures. It not only improves the detection efficiency but also realizes the comprehensive and objective analysis of the feasibility of brick-built structure wall masonry detection, ensuring the reliability and authenticity of the detection and analysis results of brick-built structure wall masonry.
[0096] Although the specific embodiments of the invention have been described in detail in conjunction with the accompanying drawings, it should not be construed as a limitation on the scope of protection of this patent. Within the scope described in the claims, various modifications and variations that can be made by those skilled in the art without creative efforts still fall within the scope of protection of this patent.
Claims
1. A method for detecting masonry parameters of a brick structure wall based on image recognition, characterized in that, Including the steps: S1. Obtain the detection image of the brick wall and preprocess the detection image; S2. Input the preprocessed detection image into the SAM model to generate a segmentation mask image that identifies the masonry area; S3. Perform binarization, opening operation, and closing operation on the segmentation mask image in sequence, and perform edge detection on the processed segmentation mask image to obtain the contour of the masonry unit; read the position data of all pixel points in the processed segmentation mask image to obtain the number of the masonry unit and the corresponding pixel coordinates; S4. According to the contour and pixel coordinates of each masonry unit, calculate the geometric moment, perimeter, and minimum bounding rectangle of the corresponding masonry unit, and obtain the area of the corresponding masonry unit through the geometric moment; S5. According to the area of each masonry unit, calculate the area ratio of each masonry unit to the detection image, classify each masonry unit according to the area ratio of each masonry unit and the width-height ratio of the minimum bounding rectangle, and calculate the masonry distribution uniformity; S6. According to the perimeter and classification information of each masonry unit, calculate the shape irregularity parameter of each masonry unit, and perform weighted processing on the shape irregularity parameter of each masonry unit to obtain the wall shape irregularity characterization parameter; S7. According to the area, perimeter, and pixel coordinates of each masonry unit, calculate the masonry aggregation and dispersion degree.
2. The detection method according to claim 1, wherein Preprocessing the detection image includes: using the PIL image processing library to unify the image resolution of all detection images, and performing denoising processing on each detection image through Gaussian filtering.
3. The detection method according to claim 1, characterized in that, The th masonry unit is denoted as , and its geometric moment is: Among them, is the th moment of the th masonry unit, and are both non-negative integers, is a natural number; and are the width and height of the detected image respectively; and are the sets of abscissas and ordinates of the edge pixel points of the th masonry unit respectively, and are the position index variables of the detected image in the width direction and height direction respectively, is the gray value of the pixel point with coordinates 4. The detection method according to claim 3, wherein The area proportion is: Among them, is the area proportion of, is the area of, and , ; and are the width and height of the detection image respectively.
5. The detection method according to claim 3, characterized in that Obtain The method for obtaining the minimum circumscribed rectangle includes: S4.
1. Obtain the convex hull of all the pixel points in and get all the convex hull points of the convex hull. Rotate all the edges of the convex hull to the coordinate axes in sequence, and obtain the rotated coordinates of all the convex hull points on the convex hull once during each rotation process. S4.
2. Obtain the four corner points of the convex hull in each rotation process and obtain a bounding rectangle through the coordinate extreme values of the rotation coordinates of all convex hull points in each rotation process; S4.
3. Calculate the areas of all the circumscribed rectangles obtained during the rotation process, and use the circumscribed rectangle with the smallest area as the minimum circumscribed rectangle; S4.4, The aspect ratio of the minimum circumscribed rectangle of: Among them, is the aspect ratio of the minimum bounding rectangle, is the width value of the minimum bounding rectangle, is the height value of the minimum bounding rectangle.
6. The detection method according to claim 5, characterized in that Obtain The convex hull method includes: S4.
11. Pair up all the points in to construct straight lines, , where is the combination number, is the number of points in the middle; S4.
12. Determine in sequence whether all the remaining points on each straight line are all on the same side of the straight line. If so, the straight line is used as one side of the convex hull; otherwise, no action is taken. S4.
13. Connect the straight lines that are all on one side of the convex hull end to end in sequence to obtain the convex hull.
7. According to the detection method described in claim 1, the calculation method of the masonry distribution uniformity is: , Among them, is the uniformity of the distribution of bricks and stones; is the total number of brick and stone categories among all brick and stone units, is the ratio of the total number of brick and stone units in the category of bricks and stones to the total number of brick and stone units, where is a natural number.
8. The detection method according to claim 1, wherein The expression for calculating the shape irregularity parameter of each masonry unit is: , Among them, is the shape irregularity parameter of the th masonry unit in the th type of masonry; is the area of the th masonry unit in the th type of masonry; is the perimeter of the th masonry unit in the th type of masonry; is the number of the th type of masonry; is the total number of masonry units; is the total number of masonry categories among all masonry units; and are both natural numbers.
9. The detection method according to claim 1, wherein The expression for calculating the wall shape irregularity characterization parameter is: Among them, is the characterization parameter of the irregular wall shape; is the irregularity parameter of the th masonry unit in the th type of masonry; is the area of the th masonry unit in the th type of masonry; is the number of the th type of masonry, and is the total number of masonry types among all masonry units.
10. The detection method according to claim 1, characterized in that The expression for calculating the masonry aggregation and dispersion degree of each type of masonry unit is: , Among them, is the masonry aggregation degree; is the th area of the th masonry unit in the th type of masonry; and are the width and height of the detected image respectively; is the number of the th type of masonry, is the total number of masonry categories among all masonry units.
Citation Information
Patent Citations
Traditional village building roof damage identification and damage rate calculation method
CN117523405A
Building engineering quality intelligent evaluation management system and method
CN118154363A