Method and device for judging concave and convex angles of house type image based on region growing algorithm

Through a method based on regional growth algorithm, combined with Hough linear detection and convolution kernel processing, the problem of difficulty in segmenting concave angles and convex angles in the floor plan is solved, accurate and rapid judgment is achieved, and the cost of manual participation and analysis is reduced.

CN119672053AActive Publication Date: 2025-03-21SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411586544.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-03-21
Estimated Expiration
2044-11-08

AI Technical Summary

Technical Problem

The prior art is difficult to accurately and quickly divide concave angles and convex angles in complex floor plans, especially when there are large differences in noise information and design styles.

Method used

Using a method based on regional growth algorithm, the accurate judgment of the concave and convex angles of the floor plan is achieved through Hough linear detection, convolution kernel processing and rectangular geometric attribute analysis.

Benefits of technology

This method can efficiently process most types of floor plan contours, accurately divide the concave and convex angles, reduce manual participation, and reduce analysis time cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672053A_ABST
    Figure CN119672053A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for judging concave and convex angles of a house type image based on a region growing algorithm. The method comprises the following steps of: performing reconstruction filling on an outer contour mask image by utilizing Hough straight line detection; calculating a maximum inscribed rectangle coordinate of the reconstructed mask, and extracting horizontal and vertical straight line information of the reconstructed mask by utilizing Hough straight line detection; taking the current maximum inscribed rectangle as an initial main body area and an initial detection area, scanning a discrimination block between the periphery of the detection area and the nearest straight line anticlockwise circularly from the position right above the detection area, and if the discrimination block meets the convex angle condition, recording the coordinate of the area and expanding the detection area; and if the judgment block meets the concave angle condition, recording supplementary angle coordinates of the judgment block and expanding the main body area and the detection area until no nearest straight line exists around the detection area. According to the method, based on the region growing algorithm, the periphery is scanned from the current region to search for the judgment blocks meeting the conditions, the main body is expanded, and the concave-convex angles of the house type image can be accurately and rapidly extracted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and in particular relates to a method and device for determining concave and convex angles of a floor plan based on a region growing algorithm. Background Art

[0002] In a floor plan, the outer contour usually refers to the overall frame structure of the house, including walls, room boundaries, windows, etc., while the inner contour refers to the various parts inside the floor plan, such as bathrooms, bedrooms, kitchens, etc. Although most of the outer and inner contours in the floor plan have obvious structural characteristics, the differences in design styles of different floor plans, differences in image quality from different data sources, and possible noise information (such as annotations, symbols, etc.) in the floor plan all pose challenges to the automatic segmentation task. Traditional floor plan processing methods rely on manual annotation and simple image processing technology, which is difficult to meet large-scale and high-precision requirements. In recent years, the rapid development of deep learning-based image segmentation models in the field of computer vision has provided a more accurate and efficient solution for the automatic segmentation of the outer and inner contours of floor plans.

[0003] In a floor plan, a convex or concave corner refers to a block around the main body of the house that satisfies the convex or concave conditions, which usually appears in balconies, corners, wall corners and other locations. Due to the different needs and business scenarios of different companies, the needs for convex or concave angle discrimination algorithms may also vary. Conventional angle discrimination methods usually rely on geometric analysis, but in complex floor plans, simple geometric discrimination may not be sufficient to cope with diverse image presentation forms. The present invention specifically designs a method for determining concave and convex angles in floor plans for certain specific conditions, which can accurately and quickly segment concave and convex angles in floor plans. Summary of the invention

[0004] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a method and device for determining the concave and convex angles of floor plans based on a region growing algorithm. The invention is based on a region growing algorithm to obtain concave and convex angles of floor plans that meet the requirements. This method is the first method in this direction that solves practical needs based on image processing. It can process most types of floor plan contours and accurately and efficiently segment the concave and convex angles.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] In a first aspect, the present invention provides a method for determining concave and convex angles of a floor plan based on a region growing algorithm, comprising the following steps:

[0007] (1) Obtain a contour mask with smooth edge lines, perform Hough line detection on the input rough outer contour mask, retain the vertical and horizontal straight lines, and retain the line segments on the contour, remove the outward straight line parts, and then fill the area surrounded by the straight lines. Then use a specific convolution kernel to perform image processing to remove the small burrs in the mask image, and obtain a reconstructed contour image with smooth edges;

[0008] (2) Calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, calculate the maximum inscribed rectangle of the reconstructed contour, use Hough line detection to extract the vertical and horizontal line segments of the reconstructed contour, and sort the vertical and horizontal line segments from left to right and from top to bottom respectively;

[0009] (3) Starting from the top of the current detection area, scan the detection area in a counterclockwise direction. Specifically, find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, and find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block. If there are multiple judgment blocks with a pixel value of 255 in the exploration area, they are sorted from large to small according to their length, and then the concave and convex angles are judged in order; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as the main body, and the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as convex corners and saved, and the detection area is extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area;

[0010] (4) By analyzing and utilizing the geometric properties of the rectangle, the coordinates of the four vertices of the final main body are finally obtained to obtain an accurate coordinate of the center point of the main body of the floor plan;

[0011] (5) Generate two binary images of the same size as the reconstructed contour image and with all values ​​​​zero. Draw the convex corner contour and the missing corner contour on the two binary images respectively. Design vertical induction convolution kernel and horizontal induction convolution kernel for the task of merging similar convex corner blocks and missing corner blocks. Use custom convolution kernels to perform two convolution operations on the two binary images to merge adjacent blocks, then extract the blocks in the binary images, and finally merge the convex corner and missing corner contour information.

[0012] As a preferred technical solution, in step (1), a reconstructed contour image with smooth edges is obtained, specifically:

[0013] (1-1) Perform canny edge detection on the input rough outer contour mask image to obtain a binary image of the contour edge, and then perform Hough line detection on the binary image to obtain r and θ of all straight lines in the contour. r and θ represent the length and arc of the straight line in polar coordinates, respectively. According to the angles of all straight lines Filter out horizontal and vertical straight lines;

[0014] (1-2) Calculate the endpoint coordinates of all horizontal and vertical lines based on r and θ of the line;

[0015] (1-3) extract the horizontal lines and sort them in ascending order according to the starting ordinate, and extract the vertical lines and sort them in ascending order according to the starting abscissa; limit the starting abscissa and the ending abscissa of the horizontal lines to be between the starting abscissas of the first and last vertical lines, and limit the starting ordinate and the ending ordinate of the vertical lines to be between the starting ordinates of the first and last horizontal lines;

[0016] (1-4) All vertical and horizontal lines in the grid divide each line segment into segments and determine whether it is a line segment within the boundary. Specifically, the two endpoints and the midpoint of the line segment are determined to be within the boundary. If there is a non-zero pixel value on the A×B rectangle centered on the two endpoints, that is, there is a pixel belonging to the contour, the line segment is retained; if there is a non-zero pixel value on the rectangle centered on one of the endpoints and the midpoint, the line segment is retained; finally, all the line segments that are within the boundary are retained;

[0017] (1-5) Draw the retained line segment on a binary image whose size is equal to that of the rough contour image and whose values ​​are all 0, that is, the position of the line segment is assigned a value of 255; use the contour detection algorithm of OpenCV to extract the outer contour of the binary image, and then use the contour filling algorithm of OpenCV to draw the extracted outer contour on the binary image to obtain the reconstructed contour;

[0018] (1-6) Use the custom convolution operation of OpenCV to eliminate the protruding small burrs and obtain an accurate reconstructed contour. Specifically, use the vertical denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the vertical restoration convolution kernel for convolution operation; use the horizontal denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the horizontal restoration convolution kernel for convolution operation;

[0019] (1-7) Using the OpenCV library, the precise reconstructed contour is binarized, and some non-255 and non-0 pixels caused by the convolution operation are classified into two categories.

[0020] As a preferred technical solution, in step (2), the maximum inscribed rectangle of the reconstructed contour is calculated as follows:

[0021] (2-1) Considering that the boundary of some reconstructed contour images fits the boundary of the contour and makes the edge unrecognizable, we first use the constant edge expansion method of OpenCV to expand the boundary with a pixel value of 0;

[0022] (2-2) Based on the OpenCV method, the canny edge detection algorithm is first used to extract the edge map of the reconstructed contour, and then the Hough line detection is used to extract the straight lines of the reconstructed contour;

[0023] (2-3) Traverse all vertical and horizontal line segments, calculate the coordinates of the intersection, and then determine whether there is a pixel point with a pixel value of 255 in the preset rectangle centered on the intersection. If there are multiple pixels, return the coordinates of the point with a pixel value of 255 that is closest to the intersection;

[0024] (2-4) Calculate the rectangular areas of all intersection points and contour points with each other as diagonal points and sort them from large to small. Next, start with the rectangle with the largest area and determine whether the conditions are met one by one. Specifically, let the minimum and maximum x values ​​of the current two intersection points be x min and x max , traverse the reconstructed contour on y1 and y2 lines from x min to x max Is there a pixel point with a value of 0 on the straight line between the two intersection points? That is, determine whether the upper and lower sides of the rectangle formed by the two intersection points are inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle. Let the minimum and maximum y values ​​of the current two intersection points be y min and max , traverse the reconstructed contour on x0 and x2 lines from y min to y max Whether there is a pixel point with a value of 0 on the straight line between the two intersection points, that is, whether the left and right sides of the rectangle formed by the two intersection points are both inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle; if there is no pixel point with a value of 0 on the four sides of the rectangle, the current rectangle is the maximum inscribed rectangle of the reconstructed contour; if there are pixel points with a value of 0 on the four sides of the rectangle, the current rectangle is not the maximum inscribed rectangle of the reconstructed contour, and the above operation steps are performed on the next rectangle;

[0025] (2-5) Since constant edge expansion is used in (2-1), the coordinates of the two intersection points corresponding to the maximum inscribed rectangle are finally obtained by subtracting the expanded constant value; the maximum inscribed rectangle is stored as [x1, y1, x2, y2], which is a list of coordinates of the two diagonal points; the maximum inscribed rectangle is used as the initial subject and the initial detection area, and the storage format is the same.

[0026] As a preferred technical solution, in step (3), the setting conditions for discriminating the concave and convex angles are as follows:

[0027] When the current search direction is above the main body, when the width of the discriminant block is greater than or equal to one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; when the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block is a convex corner;

[0028] When the current search direction is the left side of the subject, when the height of the discriminant block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block belongs to the subject, and the area in the exploration area excluding the discriminant block is a concave corner; when the height of the discriminant block is less than one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block is a convex corner;

[0029] When the current search direction is below the main body, when the width of the discriminant block is greater than or equal to one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; when the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block is a convex corner;

[0030] When the current search direction is the right side of the main body, when the height of the discrimination block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block belongs to the main body, and the area in the exploration area excluding the discrimination block is a concave corner; when the height of the discrimination block is less than one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block is a convex corner.

[0031] As a preferred technical solution, in step (3), the detection area is scanned cyclically in a counterclockwise direction, specifically:

[0032] (3-1) Construct a direction list, with the initial direction facing upward, and then traverse the direction list in order, that is, traverse around the body in a counterclockwise direction;

[0033] (3-2) Find the line segment closest to the detection area in the current direction, specifically: if the current direction is upward, traverse the horizontal line segment sequence in order, and when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of being translated downward by a set value and falling on the upper side or below the detection area, then the previous line segment of the current line segment in the line segment sequence is the closest straight line; if the current direction is left, when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of being translated right by a set value and falling on the left side or right side of the detection area, then the previous line segment of the current line segment in the line segment sequence is the closest straight line; if the current direction is downward, when the first line segment is found to satisfy the requirement of being translated upward by a set value and falling below the lower side of the detection area, then the current line segment is the closest straight line; if the current direction is right, when the first line segment is found to satisfy the requirement of being translated right by a set value and falling to the right of the right side of the detection area, then the current line segment is the closest straight line;

[0034] (3-3) Then, the nearest line segment found in the current direction and the current subject are used to calculate the rectangle between the subject and the line segment as the exploration area for this time. Then, the pixel-by-pixel XOR method of the OpenCV library is used to obtain a single or multiple rectangles with a pixel value of 255 in the exploration area, i.e., the judgment block;

[0035] (3-4) Design several convolution kernels to deal with the burr situation encountered in the discrimination block of the four directions. The shape of the convolution kernel is the same as that in step (1-6); when facing upward and downward, use the vertical denoising convolution kernel for convolution operation, then use the binarization of opencv, and finally use the vertical restoration convolution kernel for convolution operation; when facing left and right, use the horizontal denoising convolution kernel for convolution operation, then use the binarization of opencv, and finally use the horizontal restoration convolution kernel for convolution operation;

[0036] (3-5) After obtaining the refined single or multiple discriminant blocks, first sort the discriminant blocks; when facing upward and downward, sort them from large to small according to the width of the discriminant blocks; when facing left and right, sort them from large to small according to the height of the discriminant blocks;

[0037] (3-6) Traverse the sorted discriminant block sequence. When the discriminant block meets the setting conditions of the concave corner, use the queue method to build the discriminant block queue. After subtracting the first discriminant block from the exploration area, there will be one or two remaining areas. Then, according to the coordinate information, determine which remaining area the subsequent discriminant block belongs to. Then, use the corresponding remaining area to subtract the subsequent discriminant block until the discriminant block queue is empty. The remaining area is the missing corner. Extend the main body and the detection area along the current direction to the position of the nearest line segment. When the discriminant block meets the setting conditions of the convex corner, all the discriminant blocks are convex corners, and extend the detection area along the current direction to the position of the nearest line segment.

[0038] (3-7) Repeat step (3-6) until it is determined according to step (3-2) that there is no closest straight line in the four directions.

[0039] As a preferred technical solution, in step (4), the coordinates of the center point of the main body are calculated as follows:

[0040] (4-1) Calculate the coordinates of the center point of the subject according to the final subject coordinate information;

[0041]

[0042] Among them, [x lt ,y lt ] is the coordinate point of the upper left corner of the subject, [x rb ,y rb ] is the coordinate point of the lower right corner of the subject.

[0043] As a preferred technical solution, in step (5), whether the convex corners or concave corners are merged satisfies one of the following conditions:

[0044] The concave corner blocks or convex corner blocks are connected;

[0045] The distance between the concave corner blocks or convex corner blocks differs by a set threshold;

[0046] The method uses a custom convolution kernel to perform two convolution operations on two binary images to merge adjacent blocks, specifically:

[0047] (5-1) Generate two binary images with the same size as the rough contour image and all pixel values ​​are 0;

[0048] (5-2) Use the OpenCV library method to draw the convex corner contour and the concave corner contour into two binary images respectively, and fill the pixels inside the contour with 255;

[0049] (5-3) Using the preset horizontal fusion convolution kernel and vertical fusion convolution kernel for the horizontal and vertical relationships, the concave corner blocks or convex corner blocks that meet the set conditions are fused using the custom convolution kernel convolution operation of the opencv library;

[0050] (5-4) After obtaining the fused binary image, the binarization function of the opencv library is used to classify some pixels whose pixel values ​​are not 255 or 0 due to the convolution operation and convert them into grayscale images. Finally, the contour extraction function is used to extract the concave and convex corner information after the fusion.

[0051] In a second aspect, the present invention provides a system for determining concave and convex angles of a floor plan based on a region growing algorithm, comprising a contour reconstruction module, an initial dynamic region positioning module, a concave and convex angle determination module, a main body center calculation module, and a concave and convex angle fusion module;

[0052] The contour reconstruction module is used to obtain a contour mask image with smooth edge lines, perform Hough line detection on the input rough outer contour mask image, retain the vertical and horizontal straight lines, and retain the line segment part on the contour, remove the outward straight line part, and then fill the area surrounded by the straight line, and then use a specific convolution kernel to perform image processing to remove small burrs in the mask image to obtain a reconstructed contour image with smooth edges;

[0053] The initial dynamic area positioning module is used to calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, and calculate the maximum inscribed rectangle of the reconstructed contour, extract the vertical and horizontal line segments of the reconstructed contour by Hough line detection, and sort the vertical line segments and the horizontal line segments from left to right and from top to bottom respectively;

[0054] The concave-convex angle determination module is used to start from the top of the current detection area and cyclically scan the detection area in a counterclockwise direction, specifically: find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block, if there are multiple judgment blocks with a pixel value of 255 in the exploration area, sort them from large to small according to their length, and then perform concave-convex angle determination in sequence; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as the main body, the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as convex corners and saved, and the detection area and the main body are extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area;

[0055] The main body center calculation module is used to obtain an accurate main body center point coordinate of the floor plan according to the coordinates of the four vertices of the main body by analyzing and utilizing the geometric properties of the rectangle;

[0056] The convex and concave corner fusion module is used to generate two binary images with the same size as the reconstructed contour image and all values ​​​​are 0, and the convex corner contour and the missing corner contour are drawn on the two binary images respectively. A vertical induction convolution kernel and a horizontal induction convolution kernel are designed for the task of merging similar convex corner blocks and missing corner blocks. A custom convolution kernel is used to perform two convolution operations on the two binary images to merge adjacent blocks, and then the blocks in the binary images are extracted, and finally the convex corner and missing corner contour information are merged.

[0057] In a third aspect, the present invention provides an electronic device, the electronic device comprising:

[0058] at least one processor; and,

[0059] a memory communicatively connected to the at least one processor; wherein,

[0060] The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the method for determining concave and convex angles of floor plan based on region growing algorithm.

[0061] In a fourth aspect, the present invention provides a computer-readable storage medium storing a program, which, when executed by a processor, implements the method for determining concave and convex angles of a floor plan based on a region growing algorithm as described in any one of claims 1 to 7.

[0062] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0063] (1) The present invention provides a method and device for determining the concave and convex angles of a floor plan based on a region growing algorithm. The present invention is based on a region growing algorithm to obtain concave and convex angles of a floor plan that meet the requirements. This method is the first method in this direction that solves practical needs based on image processing. It can process the contours of most types of floor plans and accurately and efficiently segment the concave and convex angles.

[0064] (2) The present invention is the first algorithm for distinguishing concave and convex angles in this direction. It has low maintenance costs and is easy to iterate. The same system can easily use multiple algorithms and combine them with deep learning models.

[0065] (3) The present invention provides a method and device for determining the concave and convex angles of a floor plan based on a region growing algorithm, which can significantly reduce manual involvement and shorten the time for floor plan analysis. Since the algorithm can process multiple floor plans in batches, the human and time costs required by users in the design and evaluation stages will be significantly reduced, thereby speeding up the project advancement.

[0066] (4) The present invention can be customized according to the needs of different users. For example, different users have different requirements for the details of the floor plan, and the criteria for judging the concave and convex angles are also different. By designing flexible parameter configuration, the system can easily adapt to different floor plan analysis needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0068] Figure 1 The present invention is a flowchart of a method for determining concave and convex angles of a floor plan based on a region growing algorithm according to an embodiment of the present invention.

[0069] FIG. 2( a ) and FIG. 2( b ) are the original image of the floor plan and the outer contour mask image according to an embodiment of the present invention.

[0070] FIG. 2( c ) is a contour image after optimization based on the reconstruction of the outer contour mask image according to an embodiment of the present invention.

[0071] Figure 3 This is a diagram showing the effect of optimizing the boundary lines in the contour reconstruction module according to an embodiment of the present invention.

[0072] FIG. 4( a ) is a diagram showing the first closest line segment of the initial subject that matches upwards in an embodiment of the present invention.

[0073] FIG. 4( b ) is the first closest line segment that matches downwardly the initial subject in an embodiment of the present invention.

[0074] Figure 5 It is a binary image of the decision blocks in the exploration area of ​​the downward matching of the current initial subject in the embodiment of the present invention.

[0075] Figure 6 This is a diagram of the concave and convex angle discrimination result of an embodiment of the present invention (blue is a concave angle, and orange is a convex angle).

[0076] Figure 7 The present invention is a schematic diagram of the structure of a system for determining concave and convex angles of a house plan based on a region growing algorithm according to an embodiment of the present invention.

[0077] Figure 8 It is a schematic structural diagram of the electronic device of the present invention. DETAILED DESCRIPTION

[0078] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0079] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0080] like Figure 1 As shown, the method for determining the concave and convex angles of a floor plan based on a region growing algorithm in this embodiment includes the following steps:

[0081] (1) Obtain a contour mask with smooth edge lines, perform Hough line detection on the input rough outer contour mask, retain the vertical and horizontal straight lines, and retain the line segments on the contour, remove the outward straight line parts, and then fill the area surrounded by the straight lines. Then use a specific convolution kernel to perform image processing to remove the small burrs in the mask image, and obtain a reconstructed contour image with smooth edges, such as Figure 2(a)-Figure 2(c) shown.

[0082] Furthermore, the contour reconstruction module uses Hough line detection and OpenCV methods as follows:

[0083] (1-1) Perform canny edge detection on the input rough outer contour mask image to obtain a binary image of the contour edge, and then perform Hough line detection on the binary image to obtain r and θ of all straight lines in the contour, that is, the length and arc of the straight line in polar coordinates. According to the angles of all straight lines Filter out horizontal and vertical straight lines;

[0084] (1-2) According to the r and θ of the straight line, the coordinates of the endpoints of all horizontal and vertical lines are calculated and expressed as [x1, y1, x2, y2], that is, the x, y coordinates of the starting point of the straight line and the x, y coordinates of the end point:

[0085] Horizontal straight line:

[0086] Vertical Line:

[0087] Wherein image_width and image_height represent the height and width of the rough contour image, respectively, and a is a fixed value greater than the height and width of all rough contour images in the data set. In this embodiment, a is set to 4000;

[0088] (1-3) Extract the horizontal lines and sort them in ascending order by y1 (vertical coordinate of the starting point), and extract the vertical lines and sort them in ascending order by x1 (horizontal coordinate of the starting point); limit the x1 (horizontal coordinate of the starting point) and x2 (horizontal coordinate of the end point) of the horizontal lines to be between the x1 (horizontal coordinate of the starting point) of the first and last vertical lines, and limit the y1 (vertical coordinate of the starting point) and y2 (vertical coordinate of the end point) of the vertical lines to be between the y1 (vertical coordinate of the starting point) of the first and last horizontal lines;

[0089] (1-4) All vertical and horizontal lines in the grid are divided into each line segment to determine whether it is a line segment within the boundary. Specifically, the two endpoints and the midpoint of the line segment are determined to be within the boundary. If there is a non-zero pixel value on the A×B rectangle centered on the two endpoints, that is, there is a pixel belonging to the contour, the line segment is retained. In this embodiment, A and B are both 14; if there is a non-zero pixel value on the rectangle centered on one of the endpoints and the midpoint, the line segment is retained; finally, all the line segments that are within the boundary are retained, such as Figure 3 As shown;

[0090] (1-5) Draw the retained line segment on a binary image whose size is equal to that of the rough contour image and whose values ​​are all 0, that is, the position of the line segment is assigned a value of 255; use the contour detection algorithm of OpenCV to extract the outer contour of the binary image, and then use the contour filling algorithm of OpenCV to draw the extracted outer contour on the binary image to obtain the reconstructed contour;

[0091] (1-6) The reconstructed contour obtained above will have some tiny burrs. In order to remove the burrs, we designed a contour refinement convolution kernel and used the custom convolution operation of OpenCV to eliminate the protruding tiny burrs and obtain an accurate reconstructed contour. Specifically, we use the vertical denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the vertical restoration convolution kernel for convolution operation; use the horizontal denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the horizontal restoration convolution kernel for convolution operation;

[0092] Vertical denoising convolution kernel Vertical restoration convolution kernel

[0093] Horizontal denoising convolution kernel Horizontal Restoration Convolution Kernel

[0094] (1-7) Using the OpenCV library, the precise reconstructed contour is binarized, and some non-255 and non-0 pixels caused by the convolution operation are classified into two categories.

[0095] (2) Calculate the maximum inscribed rectangle of the reconstructed contour as the initial main body and initial detection area of ​​the floor plan, use the OpenCV algorithm to calculate the maximum inscribed rectangle of the reconstructed contour, use the Hough line detection to extract the vertical and horizontal line segments of the reconstructed contour, and sort the vertical and horizontal line segments from left to right and from top to bottom, respectively.

[0096] Furthermore, the maximum inscribed rectangle of the reconstructed contour is calculated using a line intersection loop reconstruction algorithm based on Hough line detection, specifically:

[0097] (2-1) Considering that the edge of the partially reconstructed contour image is aligned with the contour boundary, resulting in the edge being unrecognizable, the constant edge expansion method of OpenCV is first used to expand the boundary with a pixel value of 0. In this embodiment, the expansion length is 10;

[0098] (2-2) Based on the OpenCV method, the canny edge detection algorithm is first used to extract the edge map of the reconstructed contour, and then the Hough line detection is used to extract the straight lines of the reconstructed contour. The method is similar to step (1) to filter out the horizontal and vertical line segments and sort them;

[0099] (2-3) Traverse all vertical and horizontal line segments, calculate the coordinates of the intersection, and then determine whether there is a pixel point with a pixel value of 255 in the 5×5 rectangle centered on the intersection. If there are multiple pixels, return the coordinates of the point with a pixel value of 255 that is closest to the intersection;

[0100] l1 horizontal l2 vertical (|x4-x3|≤1):

[0101] l1 vertical (|x2-x1|≤1)ι2 horizontal:

[0102] ι1 pseudo-horizontal ι2 pseudo-vertical (2≤|x4-x3|≤5):

[0103]

[0104] Where ι1 is the first line segment, represented by [x1, y1, x2, y2], i.e., the coordinates of the two endpoints of the line segment [x1, y1] and [x2, y2] (x1≤x2, y1≤y2), l2 is the second line segment, represented by [x3, y3, x4, y4], i.e., the coordinates of the two endpoints of the line segment [x3, y3] and [x4, y4] (x3≤x4, y3≤y4);

[0105] (2-4) Calculate the rectangular areas of all intersection points and contour points with each other as diagonal points and sort them from large to small. Next, start with the rectangle with the largest area and determine whether the conditions are met one by one. Specifically, let the minimum and maximum x values ​​of the current two intersection points be x min and x max , traverse the reconstructed contour on y1 and y2 lines from x min to x max Is there a pixel point with a value of 0 on the straight line between the two intersection points? That is, determine whether the upper and lower sides of the rectangle formed by the two intersection points are inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle. Let the minimum and maximum y values ​​of the current two intersection points be y min and max , traverse the reconstructed contour on x1 and x2 lines from y min to y max Whether there is a pixel point with a value of 0 on the straight line between the two intersection points, that is, whether the left and right sides of the rectangle formed by the two intersection points are both inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle; if there is no pixel point with a value of 0 on the four sides of the rectangle, the current rectangle is the maximum inscribed rectangle of the reconstructed contour; if there are pixel points with a value of 0 on the four sides of the rectangle, the current rectangle is not the maximum inscribed rectangle of the reconstructed contour, and the above operation steps are performed on the next rectangle;

[0106] (2-5) Since constant edge expansion is used in (2-1), the coordinates of the two intersection points corresponding to the maximum inscribed rectangle are finally obtained by subtracting the expansion constant value. In this embodiment, the expansion length is 10; the maximum inscribed rectangle is stored as [x1, y1, x2, y2], which is a list of coordinates of the two diagonal points; the maximum inscribed rectangle is used as the initial subject and the initial detection area, and the storage format is the same.

[0107] (3) Starting from the top of the current detection area, scan the detection area in a counterclockwise direction. Specifically, find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, i.e., the exploration area, and find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, i.e., the judgment block. If there are multiple judgment blocks with a pixel value of 255 in the exploration area, they are sorted from large to small according to their length, and then the concave and convex corners are judged in order. If the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as the main body, and the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction. If the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as convex corners and saved, and the detection area is extended to the nearest line segment along this direction. Finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area.

[0108] Furthermore, the scanning around the main body and determining the concave and convex angles are specifically as follows:

[0109] (3-1) Construct a direction list, with the initial direction facing upward, and then traverse the direction list in order, that is, traverse around the body in a counterclockwise direction;

[0110] (3-2) Find the line segment closest to the detection area in the current direction, specifically: if the current direction is upward, traverse the horizontal line segment sequence in order, and when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of translating downward by a set value and falling on the upper side or below the detection area, then the previous line segment of the current line segment in the line segment sequence is the nearest straight line; if the current direction is left, when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of translating right by a set value and falling on the left side or right side of the detection area, then the previous line segment of the current line segment in the line segment sequence is the nearest straight line; if the current direction is downward, when the first line segment is found to satisfy the requirement of translating upward by a set value and falling below the lower side of the detection area, then the current line segment is the nearest straight line; if the current direction is right, when the first line segment is found to satisfy the requirement of translating right by a set value and falling to the right of the right side of the detection area, then the current line segment is the nearest straight line; the above-mentioned set value is 5 in this embodiment, such as Figure 4(a)-Figure 4(b) As shown;

[0111] (3-3) Then, the nearest line segment found in the current direction and the current subject are used to calculate the rectangle between the subject and the line segment as the exploration area. Then, the pixel-by-pixel XOR method of the OpenCV library is used to obtain a single or multiple rectangles with a pixel value of 255 in the exploration area, i.e., the discrimination block, such as Figure 5 As shown;

[0112] (3-4) The discriminant block obtained by the pixel-by-pixel XOR method of opencv mentioned above will have some burrs. Therefore, in order to eliminate the burrs in the discriminant block and avoid affecting the discrimination of concave and convex angles, we specially designed several convolution kernels to deal with the burrs encountered in the discriminant blocks of the four directions. The shape of the convolution kernel is the same as that in step (1-6); when facing upward and downward, the vertical denoising convolution kernel is used for convolution operation, and then the binarization of opencv is used, and finally the vertical restoration convolution kernel is used for convolution operation; when facing left and right, the horizontal denoising convolution kernel is used for convolution operation, and then the binarization of opencv is used, and finally the horizontal restoration convolution kernel is used for convolution operation;

[0113] (3-5) After obtaining the refined single or multiple discriminant blocks, first sort the discriminant blocks; when facing upward and downward, sort them from large to small according to the width of the discriminant blocks; when facing left and right, sort them from large to small according to the height of the discriminant blocks;

[0114] (3-6) Traverse the sorted discriminant block sequence. When the discriminant block meets the following setting conditions for concave corners, use the queue method to build a discriminant block queue. After subtracting the first discriminant block from the exploration area, there will be one or two remaining areas. Then, according to the coordinate information, determine which remaining area the subsequent discriminant block belongs to. Then, use the corresponding remaining area to subtract the subsequent discriminant block until the discriminant block queue is empty. The remaining area is the missing corner. Extend the main body and the detection area along the current direction to the position of the nearest line segment. When the discriminant block meets the following setting conditions for convex corners, all discriminant blocks are convex corners. Extend the detection area along the current direction to the position of the nearest line segment, such as Figure 6 ; The setting conditions for distinguishing convex angles (concave angles) refer to satisfying the following conditions:

[0115] When the current search direction is above the main body, when the width of the discriminant block is greater than or equal to one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; when the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block is a convex corner;

[0116] When the current search direction is the left side of the subject, when the height of the discriminant block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block belongs to the subject, and the area in the exploration area excluding the discriminant block is a concave corner; when the height of the discriminant block is less than one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block is a convex corner;

[0117] When the current search direction is below the main body, when the width of the discriminant block is greater than or equal to one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; when the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the outline, the discriminant block is a convex corner;

[0118] When the current search direction is the right side of the main body, when the height of the discrimination block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block belongs to the main body, and the area in the exploration area excluding the discrimination block is a concave corner; when the height of the discrimination block is less than one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block is a convex corner.

[0119] (3-7) Repeat step (3-6) until it is determined according to step (3-2) that there is no closest straight line in the four directions.

[0120] (4) By analyzing and utilizing the geometric properties of the rectangle, an accurate coordinate of the center point of the main body of the floor plan is finally obtained based on the coordinates of the four vertices of the final main body.

[0121] Furthermore, the coordinates of the center point of the subject are calculated as follows:

[0122] (4-1) Based on the final subject coordinate information, we can calculate the coordinates of the center point of the subject;

[0123]

[0124] Among them, [x lt ,y lt ] is the coordinate point of the upper left corner of the subject, [x rb ,y rb ] is the coordinate point of the lower right corner of the subject.

[0125] (5) Using opencv, numpy and other libraries, we generate two binary images with the same size as the reconstructed contour and all values ​​are 0. We draw the convex corner contour and the missing corner contour on the two binary images respectively. We design vertical induction convolution kernel and horizontal induction convolution kernel for the task of merging similar convex corner blocks and missing corner blocks. We use custom convolution kernels to perform two convolution operations on the two binary images to merge adjacent blocks, and then extract the blocks in the binary images, that is, the finally merged convex corner and missing corner contour information.

[0126] Furthermore, all the scattered concave corner blocks and convex corner blocks are merged as follows:

[0127] (5-1) Generate two binary images with the same size as the rough contour image and all pixel values ​​are 0;

[0128] (5-2) Use the method of the OpenCV library to draw the convex corner contour and the concave corner contour into two binary images respectively, and fill the pixels inside the contour with 255;

[0129] (5-3) In order to merge the concave corner blocks or convex corner blocks that meet the above-mentioned set conditions, two fusion convolution kernels are designed in this embodiment for the horizontal relationship and vertical relationship. The concave corner blocks or convex corner blocks that meet the set conditions are fused by using the custom convolution kernel convolution operation of the opencv library;

[0130] Vertically fused convolution kernels Horizontally fused convolution kernels

[0131] (5-4) After obtaining the fused binary image, the binarization function of the opencv library is used to classify some pixels whose pixel values ​​are not 255 or 0 due to the convolution operation and convert them into grayscale images. Finally, the contour extraction function is used to extract the concave and convex corner information after the fusion.

[0132] It should be noted that, for the sake of convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.

[0133] Based on the same idea as the method for determining the concave-convex angle of a house type diagram based on a region growing algorithm in the above-mentioned embodiment, the present invention also provides a system for determining the concave-convex angle of a house type diagram based on a region growing algorithm, which can be used to execute the above-mentioned method for determining the concave-convex angle of a house type diagram based on a region growing algorithm. For ease of explanation, the structural schematic diagram of the embodiment of the system for determining the concave-convex angle of a house type diagram based on a region growing algorithm only shows the parts related to the embodiment of the present invention. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.

[0134] See also Figure 7 In another embodiment of the present application, a system 100 for determining concave and convex angles of a floor plan based on a region growing algorithm is provided, the system comprising a contour reconstruction module 101, an initial dynamic region positioning module 102, a concave and convex angle determination module 103, a main body center calculation module 104 and a concave and convex angle fusion module 105;

[0135] The contour reconstruction module 101 is used to obtain a contour mask image with smooth edge lines, perform Hough line detection on the input rough outer contour mask image, retain the vertical and horizontal straight lines, and retain the line segment part on the contour, remove the outward straight line part, and then fill the area surrounded by the straight line, and then use a specific convolution kernel to perform image processing to remove small burrs in the mask image, so as to obtain a reconstructed contour image with smooth edges;

[0136] The initial dynamic area positioning module 102 is used to calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, and calculate the maximum inscribed rectangle of the reconstructed contour, extract the vertical and horizontal line segments of the reconstructed contour by Hough line detection, and sort the vertical line segments and the horizontal line segments from left to right and from top to bottom respectively;

[0137] The concave-convex angle determination module 103 is used to start from the top of the current detection area and cyclically scan the detection area in a counterclockwise direction, specifically: find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block, if there are multiple judgment blocks with a pixel value of 255 in the exploration area, sort them from large to small according to their length, and then perform concave-convex angle determination in sequence; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as the main body, the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as convex corners and saved, and the detection area and the main body are extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area;

[0138] The main body center calculation module 104 is used to obtain an accurate main body center point coordinate of the floor plan according to the coordinates of the four vertices of the main body by analyzing and utilizing the geometric properties of the rectangle;

[0139] The convex and concave corner fusion module 105 is used to generate two binary images with the same size as the reconstructed contour image and all values ​​are 0, and the convex corner contour and the missing corner contour are drawn on the two binary images respectively. A vertical sensing convolution kernel and a horizontal sensing convolution kernel are designed for the task of merging similar convex corner blocks and missing corner blocks. A custom convolution kernel is used to perform two convolution operations on the two binary images to merge adjacent blocks, and then the blocks in the binary images are extracted, and finally the convex corner and missing corner contour information are merged.

[0140] It should be noted that the system for determining convex and concave angles of floor plans based on region growing algorithm of the present invention corresponds one to one with the method for determining convex and concave angles of floor plans based on region growing algorithm of the present invention. The technical features and beneficial effects described in the embodiment of the method for determining convex and concave angles of floor plans based on region growing algorithm are applicable to the embodiment of the method for determining convex and concave angles of floor plans based on region growing algorithm. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here. This is hereby declared.

[0141] In addition, in the implementation of the system for determining the convex and concave angles of floor plans based on the region growing algorithm in the above-mentioned embodiment, the logical division of each program module is only an example. In actual applications, the above-mentioned functions can be assigned to different program modules as needed, for example, for the configuration requirements of the corresponding hardware or the convenience of software implementation. That is, the internal structure of the system for determining the convex and concave angles of floor plans based on the region growing algorithm can be divided into different program modules to complete all or part of the functions described above.

[0142] See also Figure 8 In one embodiment, an electronic device for implementing a method for determining convex and concave angles of a floor plan based on a region growing algorithm is provided. The electronic device 200 may include a first processor 201, a first memory 202, and a bus, and may also include a computer program stored in the first memory 202 and executable on the first processor 201, such as a floor plan convex and concave angle determination program 203.

[0143] The first memory 202 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the first memory 202 may be an internal storage unit of the electronic device 200, such as a mobile hard disk of the electronic device 200. In other embodiments, the first memory 202 may also be an external storage device of the electronic device 200, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. equipped on the electronic device 200. Further, the first memory 202 may also include both an internal storage unit of the electronic device 200 and an external storage device. The first memory 202 may not only be used to store application software and various types of data installed in the electronic device 200, such as the code of the floor plan concave and convex angle determination program 203, but also be used to temporarily store data that has been output or is to be output.

[0144] In some embodiments, the first processor 201 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The first processor 201 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes various functions and processes data of the electronic device 200 by running or executing programs or modules stored in the first memory 202, and calling data stored in the first memory 202.

[0145] Figure 8 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on the electronic device 200 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0146] The floor plan concave-convex angle determination program 203 stored in the first memory 202 of the electronic device 200 is a combination of multiple instructions. When running in the first processor 201, it can achieve:

[0147] (1) Obtain a contour mask with smooth edge lines, perform Hough line detection on the input rough outer contour mask, retain the vertical and horizontal straight lines, and retain the line segments on the contour, remove the outward straight line parts, and then fill the area surrounded by the straight lines. Then use a specific convolution kernel to perform image processing to remove the small burrs in the mask image, and obtain a reconstructed contour image with smooth edges;

[0148] (2) Calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, calculate the maximum inscribed rectangle of the reconstructed contour, use Hough line detection to extract the vertical and horizontal line segments of the reconstructed contour, and sort the vertical and horizontal line segments from left to right and from top to bottom respectively;

[0149] (3) Starting from the top of the current detection area, scan the detection area in a counterclockwise direction. Specifically, find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, and find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block. If there are multiple judgment blocks with a pixel value of 255 in the exploration area, they are sorted from large to small according to their length, and then the concave and convex angles are judged in order; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as the main body, and the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as convex corners and saved, and the detection area is extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area;

[0150] (4) By analyzing and utilizing the geometric properties of the rectangle, the coordinates of the four vertices of the final main body are finally obtained to obtain an accurate coordinate of the center point of the main body of the floor plan;

[0151] (5) Generate two binary images of the same size as the reconstructed contour image and with all values ​​​​zero. Draw the convex corner contour and the missing corner contour on the two binary images respectively. Design vertical induction convolution kernel and horizontal induction convolution kernel for the task of merging similar convex corner blocks and missing corner blocks. Use custom convolution kernels to perform two convolution operations on the two binary images to merge adjacent blocks, then extract the blocks in the binary images, and finally merge the convex corner and missing corner contour information.

[0152] Furthermore, if the module / unit integrated in the electronic device 200 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0153] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0154] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0155] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A method for determining the concave and convex angles of a floor plan based on a region growing algorithm, characterized in that: The steps include: (1) Obtain a contour mask with smooth edge lines, perform Hough line detection on the input rough outer contour mask, retain the vertical and horizontal straight lines, and retain the line segments on the contour, remove the outward straight line parts, and then fill the area surrounded by the straight lines. Then use a specific convolution kernel to perform image processing to remove the small burrs in the mask image, and obtain a reconstructed contour image with smooth edges; (2) Calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, calculate the maximum inscribed rectangle of the reconstructed contour, use Hough line detection to extract the vertical and horizontal line segments of the reconstructed contour, and sort the vertical and horizontal line segments from left to right and from top to bottom respectively; (3) Starting from the top of the current detection area, scan the detection area in a counterclockwise direction. Specifically, find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, and find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block. If there are multiple judgment blocks with a pixel value of 255 in the exploration area, they are sorted from large to small according to their length, and then the concave and convex angles are judged in order; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as the main body, and the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, all the judgment blocks are regarded as convex corners and saved, and the detection area is extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area; (4) By analyzing and utilizing the geometric properties of the rectangle, the coordinates of the four vertices of the final main body are finally obtained to obtain an accurate coordinate of the center point of the main body of the floor plan; (5) Generate two binary images of the same size as the reconstructed contour image and with all values ​​​​zero. Draw the convex corner contour and the missing corner contour on the two binary images respectively. Design vertical induction convolution kernel and horizontal induction convolution kernel for the task of merging similar convex corner blocks and missing corner blocks. Use custom convolution kernels to perform two convolution operations on the two binary images to merge adjacent blocks, then extract the blocks in the binary images, and finally merge the convex corner and missing corner contour information.

2. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (1), a reconstructed contour image with smooth edges is obtained, specifically: (1-1) Perform canny edge detection on the input rough outer contour mask image to obtain a binary image of the contour edge, and then perform Hough line detection on the binary image to obtain r and θ of all straight lines in the contour. r and θ represent the length and arc of the straight line in polar coordinates, respectively. According to the angles of all straight lines Filter out horizontal and vertical straight lines; (1-2) Calculate the endpoint coordinates of all horizontal and vertical lines based on r and θ of the line; (1-3) extract the horizontal lines and sort them in ascending order according to the starting ordinate, and extract the vertical lines and sort them in ascending order according to the starting abscissa; limit the starting abscissa and the ending abscissa of the horizontal lines to be between the starting abscissas of the first and last vertical lines, and limit the starting ordinate and the ending ordinate of the vertical lines to be between the starting ordinates of the first and last horizontal lines; (1-4) All vertical and horizontal lines in the grid divide each line segment into segments and determine whether it is a line segment within the boundary. Specifically, the two endpoints and the midpoint of the line segment are determined to be within the boundary. If there is a non-zero pixel value on the A×B rectangle centered on the two endpoints, that is, there is a pixel belonging to the contour, the line segment is retained; if there is a non-zero pixel value on the rectangle centered on one of the endpoints and the midpoint, the line segment is retained; finally, all the line segments that are within the boundary are retained; (1-5) Draw the retained line segment on a binary image whose size is equal to that of the rough contour image and whose values ​​are all 0, that is, the position of the line segment is assigned a value of 255; use the contour detection algorithm of OpenCV to extract the outer contour of the binary image, and then use the contour filling algorithm of OpenCV to draw the extracted outer contour on the binary image to obtain the reconstructed contour; (1-6) Use the custom convolution operation of OpenCV to eliminate the protruding small burrs and obtain an accurate reconstructed contour. Specifically, use the vertical denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the vertical restoration convolution kernel for convolution operation; use the horizontal denoising convolution kernel for convolution operation, then perform binarization processing, and finally use the horizontal restoration convolution kernel for convolution operation; (1-7) Using the OpenCV library, the precise reconstructed contour is binarized, and some non-255 and non-0 pixels caused by the convolution operation are classified into two categories.

3. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (2), the maximum inscribed rectangle of the reconstructed contour is calculated as follows: (2-1) Considering that the boundary of some reconstructed contour images fits the boundary of the contour and makes the edge unrecognizable, we first use the constant edge expansion method of OpenCV to expand the boundary with a pixel value of 0; (2-2) Based on the OpenCV method, the canny edge detection algorithm is first used to extract the edge map of the reconstructed contour, and then the Hough line detection is used to extract the straight lines of the reconstructed contour; (2-3) Traverse all vertical and horizontal line segments, calculate the coordinates of the intersection, and then determine whether there is a pixel point with a pixel value of 255 in the preset rectangle centered on the intersection. If there are multiple pixels, return the coordinates of the point with a pixel value of 255 that is closest to the intersection; (2-4) Calculate the rectangular areas of all intersection points and contour points with each other as diagonal points and sort them from large to small. Next, start with the rectangle with the largest area and determine whether the conditions are met one by one. Specifically, let the minimum and maximum x values ​​of the current two intersection points be x min and x max , traverse the reconstructed contour on y1 and y2 lines from x min to x max Is there a pixel point with a value of 0 on the straight line between the two intersection points? That is, determine whether the upper and lower sides of the rectangle formed by the two intersection points are inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle. Let the minimum and maximum y values ​​of the current two intersection points be y min and max , traverse the reconstructed contour on x1 and x2 lines from y min to y max Whether there is a pixel point with a value of 0 on the straight line between the two intersection points, that is, whether the left and right sides of the rectangle formed by the two intersection points are both inside the reconstructed contour. If there is a pixel point with a value of 0, it means that the current rectangle is not the maximum inscribed rectangle; if there is no pixel point with a value of 0 on the four sides of the rectangle, the current rectangle is the maximum inscribed rectangle of the reconstructed contour; if there are pixel points with a value of 0 on the four sides of the rectangle, the current rectangle is not the maximum inscribed rectangle of the reconstructed contour, and the above operation steps are performed on the next rectangle; (2-5) Since constant edge expansion is used in (2-1), the coordinates of the two intersection points corresponding to the maximum inscribed rectangle are finally obtained by subtracting the expanded constant value; the maximum inscribed rectangle is stored as [x1, y1, x2, y2], which is a list of coordinates of the two diagonal points; the maximum inscribed rectangle is used as the initial subject and the initial detection area, and the storage format is the same.

4. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (3), the setting conditions for concave-convex angle discrimination are as follows: When the current search direction is above the main body, when the width of the discriminant block is greater than or equal to one third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; When the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the contour, the discriminant block is a convex corner; When the current search direction is the left side of the subject, when the height of the discriminant block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block belongs to the subject, and the area in the exploration area excluding the discriminant block is a concave corner; when the height of the discriminant block is less than one-third of the height of the minimum circumscribed rectangle of the contour, the discriminant block is a convex corner; When the current search direction is below the main body, when the width of the discriminant block is greater than or equal to one third of the width of the minimum circumscribed rectangle of the outline, the discriminant block belongs to the main body, and the area in the exploration area excluding the discriminant block is a concave corner; When the width of the discriminant block is less than one-third of the width of the minimum circumscribed rectangle of the contour, the discriminant block is a convex corner; When the current search direction is the right side of the main body, when the height of the discrimination block is greater than or equal to one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block belongs to the main body, and the area in the exploration area excluding the discrimination block is a concave corner; when the height of the discrimination block is less than one-third of the height of the minimum circumscribed rectangle of the outline, the discrimination block is a convex corner.

5. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (3), the detection area is scanned in a counterclockwise direction, specifically: (3-1) Construct a direction list, with the initial direction facing upward, and then traverse the direction list in order, that is, traverse around the body in a counterclockwise direction; (3-2) Find the line segment closest to the detection area in the current direction, specifically: if the current direction is upward, traverse the horizontal line segment sequence in order, and when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of being translated downward by a set value and falling on the upper side or below the detection area, then the previous line segment of the current line segment in the line segment sequence is the closest straight line; if the current direction is left, when the first line segment in the first simultaneous non-sequence is found to satisfy the requirement of being translated right by a set value and falling on the left side or right side of the detection area, then the previous line segment of the current line segment in the line segment sequence is the closest straight line; if the current direction is downward, when the first line segment is found to satisfy the requirement of being translated upward by a set value and falling below the lower side of the detection area, then the current line segment is the closest straight line; if the current direction is right, when the first line segment is found to satisfy the requirement of being translated right by a set value and falling to the right of the right side of the detection area, then the current line segment is the closest straight line; (3-3) Then, the nearest line segment found in the current direction and the current subject are used to calculate the rectangle between the subject and the line segment as the exploration area for this time. Then, the pixel-by-pixel XOR method of the OpenCV library is used to obtain a single or multiple rectangles with a pixel value of 255 in the exploration area, i.e., the judgment block; (3-4) Design several convolution kernels to deal with the burr situation encountered in the discrimination block of the four directions. The shape of the convolution kernel is the same as that in step (1-6); when facing upward and downward, use the vertical denoising convolution kernel for convolution operation, then use the binarization of opencv, and finally use the vertical restoration convolution kernel for convolution operation; when facing left and right, use the horizontal denoising convolution kernel for convolution operation, then use the binarization of opencv, and finally use the horizontal restoration convolution kernel for convolution operation; (3-5) After obtaining the refined single or multiple discriminant blocks, first sort the discriminant blocks; when facing upward and downward, sort them from large to small according to the width of the discriminant blocks; when facing left and right, sort them from large to small according to the height of the discriminant blocks; (3-6) Traverse the sorted discriminant block sequence. When the discriminant block meets the setting conditions of the concave corner, use the queue method to build the discriminant block queue. After subtracting the first discriminant block from the exploration area, there will be one or two remaining areas. Then, according to the coordinate information, determine which remaining area the subsequent discriminant block belongs to. Then, use the corresponding remaining area to subtract the subsequent discriminant block until the discriminant block queue is empty. The remaining area is the missing corner. Extend the main body and the detection area along the current direction to the position of the nearest line segment. When the discriminant block meets the setting conditions of the convex corner, all the discriminant blocks are convex corners, and extend the detection area along the current direction to the position of the nearest line segment. (3-7) Repeat step (3-6) until it is determined according to step (3-2) that there is no closest straight line in the four directions.

6. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (4), the coordinates of the center point of the subject are calculated as follows: (4-1) Calculate the coordinates of the center point of the subject according to the final subject coordinate information; Among them, [x lt ,y lt ] is the coordinate point of the upper left corner of the subject, [x rb ,y rb ] is the coordinate point of the lower right corner of the subject.

7. The method for determining the concave and convex angles of a floor plan based on a region growing algorithm according to claim 1, characterized in that: In step (5), whether the convex corners or concave corners are merged is determined by satisfying one of the following conditions: The concave corner blocks or convex corner blocks are connected; The distance between the concave corner blocks or convex corner blocks differs by a set threshold; The method uses a custom convolution kernel to perform two convolution operations on two binary images to merge adjacent blocks, specifically: (5-1) Generate two binary images with the same size as the rough contour image and all pixel values ​​are 0; (5-2) Use the OpenCV library method to draw the convex corner contour and the concave corner contour into two binary images respectively, and fill the pixels inside the contour with 255; (5-3) Using the preset horizontal fusion convolution kernel and vertical fusion convolution kernel for the horizontal and vertical relationships, the concave corner blocks or convex corner blocks that meet the set conditions are fused using the custom convolution kernel convolution operation of the opencv library; (5-4) After obtaining the fused binary image, the binarization function of the opencv library is used to classify some pixels whose pixel values ​​are not 255 or 0 due to the convolution operation and convert them into grayscale images. Finally, the contour extraction function is used to extract the concave and convex corner information after the fusion.

8. A system for determining the concave and convex angles of floor plans based on a region growing algorithm, characterized in that: It includes contour reconstruction module, initial dynamic area positioning module, concave-convex angle determination module, main body center calculation module and concave-convex angle fusion module; The contour reconstruction module is used to obtain a contour mask image with smooth edge lines, perform Hough line detection on the input rough outer contour mask image, retain the vertical and horizontal straight lines, and retain the line segment part on the contour, remove the outward straight line part, and then fill the area surrounded by the straight line, and then use a specific convolution kernel to perform image processing to remove small burrs in the mask image to obtain a reconstructed contour image with smooth edges; The initial dynamic area positioning module is used to calculate the maximum inscribed rectangle of the reconstructed contour image as the initial main body and initial detection area of ​​the floor plan, and calculate the maximum inscribed rectangle of the reconstructed contour, extract the vertical and horizontal line segments of the reconstructed contour by Hough line detection, and sort the vertical line segments and the horizontal line segments from left to right and from top to bottom respectively; The concave-convex angle determination module is used to start from the top of the current detection area and cyclically scan the detection area in a counterclockwise direction, specifically: find the line segment closest to the detection area in the current direction, calculate the rectangle between the detection area and the nearest line segment in this direction, that is, the exploration area, find the rectangle with a pixel value of 255 in the rectangle according to the reconstructed contour, that is, the judgment block, if there are multiple judgment blocks with a pixel value of 255 in the exploration area, sort them from large to small according to their length, and then perform concave-convex angle determination in sequence; if the length of the judgment block is greater than or equal to one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as the main body, the area of ​​the exploration area excluding all the judgment blocks is regarded as a missing corner and saved, and the detection area and the main body are extended to the nearest line segment along this direction; if the length of the judgment block is less than one-third of the side of the minimum circumscribed rectangle in the corresponding direction, then all the judgment blocks are regarded as convex corners and saved, and the detection area and the main body are extended to the nearest line segment along this direction; finally, the traversal is stopped when there is no nearest line segment in the four directions of the detection area; The main body center calculation module is used to obtain an accurate main body center point coordinate of the floor plan according to the coordinates of the four vertices of the final main body by analyzing and utilizing the geometric properties of the rectangle; The convex and concave corner fusion module is used to generate two binary images with the same size as the reconstructed contour image and all values ​​​​are 0, and the convex corner contour and the missing corner contour are drawn on the two binary images respectively. A vertical induction convolution kernel and a horizontal induction convolution kernel are designed for the task of merging similar convex corner blocks and missing corner blocks. A custom convolution kernel is used to perform two convolution operations on the two binary images to merge adjacent blocks, and then the blocks in the binary images are extracted, and finally the convex corner and missing corner contour information are merged.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the method for determining convex and concave angles of floor plans based on a region growing algorithm as described in any one of claims 1-7.

10. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the method for determining concave and convex angles of a floor plan based on a region growing algorithm as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method and device for reconstructing house type image contour and electronic equipment

    CN111145293A

  • Automatic region division method and system, robot walking control method and system, equipment and medium

    CN113744329A