A method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks
By combining graph neural networks and convolutional neural networks, the problems of lack of standards and shape ambiguity in architectural floor plan recognition are solved, achieving high-precision, automated planar element recognition and vector output, adaptable to various floor plan styles.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-13
AI Technical Summary
Existing technologies lack standards for the identification and reconstruction of architectural floor plans, making accurate identification difficult. They are particularly unsuitable for irregular layouts and rooms or irregularly shaped elements with complex shapes. Furthermore, traditional image segmentation methods result in shape blurring and low computational efficiency.
This method combines graph neural networks and convolutional neural networks. It optimizes the identification of room edges through graph analysis and region merging, and uses convolutional neural networks to identify items in the room and perform functional prediction. This achieves high-fidelity conversion from pixel-level to vector-level, adapting to various floor plan styles.
It improves recognition accuracy and efficiency, adapts to various floor plan styles, maintains shape invariance, overcomes the limitations of traditional methods, and realizes automated recognition and efficient vector output of architectural floor plan elements.
Smart Images

Figure CN121305602B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of architectural planar element recognition technology, specifically relating to a method for architectural planar element recognition based on graph neural networks and convolutional neural networks. Background Technology
[0002] Before the advent of Computer-Aided Design (CAD) technology, engineering drawings in the construction industry were mostly drawn by hand. However, with the continuous development of CAD technology, this design-aiding technique has gradually developed and been widely adopted in the field of architectural engineering design. But the lack of relatively fixed standards for the design of drawings in architectural engineering makes accurate identification and reconstruction of these drawings extremely difficult.
[0003] With the continuous development of deep learning, Minjie Wang et al. proposed the Deep Graph Library (DGL) in their paper "Deep Graph Library: AGraph-Centric, Highly-Performant Package for Graph Neural Networks," a high-efficiency computational library for graph neural networks (GNNs). It refines the computational model of GNNs into sparse tensor operations. In multiple benchmark tests, DGL significantly outperforms other mainstream GNN frameworks in terms of speed and memory consumption, while its advantages for small-scale tasks remain unclear.
[0004] Phillip Schönfelder et al., in their paper "Graph neural network based intelligent tutoring system: A survey, Neurocomputing, Volume 610, 2024, 128442, ISSN," focused on a key task in automated planar graph analysis—text information extraction. They proposed a dedicated data synthesis pipeline capable of generating training images that simulate real-world data features, enhancing the model's generalization ability. A comprehensive comparison was made of various deep learning object detection architectures and OCR tools, including: object detection models: Tesseract, EAST, CRAFT, Faster R-CNN, YOLO series (v5, v7, v8, etc.); OCR tools: PARSEq, MATRN, EasyOCR, Tesseract. Experimental results showed that YOLOv7 performed best on text detection tasks (up to 97.5% wmAP), while PARSEq performed well on character recognition tasks (85.2% CER). However, the dataset and method in the paper primarily target text extraction from planar graphs, and their adaptability to specific planar graph styles was not discussed.
[0005] In RC-Net: Row and Column Network with Text Feature for Parsing Floor Plan Images. J. Comput. Sci. Technol. 38, 526–539 (2023), Wang Teng et al. proposed a new framework, RC-Net, which uses neural networks to parse floor plan images. This framework significantly simplifies the conversion of historical floor plan data (such as books or paper materials) into electronic resources. However, issues remain regarding the robustness of text extraction and computational efficiency and complexity.
[0006] Existing methods are typically based on image learning frameworks, which identify planar elements by segmenting image pixels. This approach may have limitations in specific tasks and is not well-suited to irregular layouts (such as rooms with complex shapes or irregularly shaped elements) due to shape blurring caused by convolution. Summary of the Invention
[0007] To address the technical problems existing in the prior art, this invention provides a method for recognizing architectural plan elements based on graph neural networks and convolutional neural networks. It optimizes the adjacency graph of regions through graph analysis and region merging, identifies room edges, and calculates room areas. A convolutional neural network image recognition model is used to identify items within the room, and room functions are predicted based on the recognition results. By abstracting the plan layout using machine learning methods, and given the high flexibility and transformability of vector data types, the vector output, while maintaining the original plan image format, can be transformed into various objects according to the user's purpose. This fills a gap in the prior art, achieving automated recognition of architectural plan elements with high accuracy and efficiency.
[0008] This invention provides a method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks, comprising the following steps:
[0009] Step S01: Input the building plan pixel image, and preprocess it through layer filtering and information extraction to obtain a binarized pixel image;
[0010] Step S02: Vectorize the binarized pixel image to obtain a vectorized image;
[0011] Step S03: Perform image segmentation on the vectorized image;
[0012] Step S04: Construct a region adjacency graph using the segmented vectorized image;
[0013] Step S05: Optimize the region adjacency graph using graph analysis and region merging using a graph neural network to identify room edges;
[0014] Step S06: Calculate the room area;
[0015] Step S07: Use a convolutional neural network image recognition model to identify items in the room;
[0016] Step S08: Predict room function based on the recognition results.
[0017] Preferably, step S01 specifically includes the following steps:
[0018] Input a planar image, merge the red, blue, and green channels of the image into one channel, and perform binarization processing;
[0019] Use optical character recognition technology to remove text information from images.
[0020] Preferably, step S02 specifically includes the following steps:
[0021] The white areas in the binarized pixel image are vectorized and buffered according to the thickness of the surrounding pixel lines to obtain the first set of vectorized polygons.
[0022] If the binarized pixel image includes black areas, then the white areas are subtracted using empty polygons of the same size as the binarized pixel image, and the black areas are converted into a second set of polygons.
[0023] Finally, the first polygon set and the second polygon set are merged to generate a complete polygon set;
[0024] The buffer is defined as covering each pixel line in the vectorized white area with two polygons from both the horizontal and vertical directions, based on the thickness of the pixel line.
[0025] Preferably, step S03 specifically includes the following steps:
[0026] S301, perform superpixel segmentation;
[0027] S302 visualizes the segmented regions;
[0028] S303 utilizes a pre-trained model to perform semantic segmentation of segmented regions through deep learning.
[0029] Preferably, step S04 specifically includes the following steps:
[0030] S401, Construct a region adjacency graph based on the color mean of superpixels;
[0031] S402: Assign weights to the region adjacency graph based on color similarity or boundary gradient, and obtain the edge features and node features of the region adjacency graph.
[0032] Preferably, step S05 specifically includes the following steps:
[0033] S501 converts the region adjacency graph into input data usable by the GNN network model, including graph structure, node features and edge features, and inputs it into the GNN network model.
[0034] S502 uses graph neural network models GCN or GAT to analyze graph structure, node features, and edge features;
[0035] S503 uses labeled data to train a GNN network model to predict node categories or boundary relationships;
[0036] S504: Merge adjacent regions based on edge features and / or node categories, use edge weights to predict whether edges belong to the same room, trim edges to segment regions based on edge weight thresholds, obtain node classification results, and identify room edges.
[0037] S505 maps the node classification results back to the original image, generating an image with labeled rooms and optimized boundaries.
[0038] Preferably, step S06 specifically includes: counting the number of pixels in each room, converting it into area according to the scale, and obtaining the room area.
[0039] Preferably, step S07 specifically includes the following steps:
[0040] S701, Load the object detection model and input the segmented room image;
[0041] S702: Traverse the segmented room regions, capture independent images of each room, and call the object detection model for each room to identify objects.
[0042] Preferably, step S08 specifically includes the following steps:
[0043] S801, predefined mapping rules between items and room functions;
[0044] S802, iterate through the detection results of items in the room and count the categories of items appearing in the room;
[0045] S803, calculate the functional probability distribution of each room based on the category and quantity of the items and the mapping rules between items and room functions.
[0046] Preferably, the method further includes step S09, visualization of the recognition results, which specifically includes the following steps:
[0047] S901, Generate a color-coded marker map;
[0048] S902, Overlapping Boundary;
[0049] S903, export room area information;
[0050] S904, mark the detected items and functional categories for each room on the resulting image;
[0051] S905 saves the labeled image and room function information.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] 1. Data Conversion from Pixel-Level to Vectorized: Most existing methods are based on pixel-level segmentation, classifying planar images by pixels, but they have limitations in shape preservation and accuracy. This invention achieves high-fidelity preservation of geometric shape and spatial characteristics by combining a composite model of graph neural networks and convolutional neural networks in the vectorization stage with region adjacency graph optimization and multimodal data conversion techniques. This effectively solves the shape blurring problem caused by convolution operations in traditional image segmentation methods.
[0054] 2. Improved training performance of graph neural network models: By recognizing indoor objects and capturing the spatial relationships between nodes, classification accuracy can be effectively improved.
[0055] 3. Improved Robustness: This invention achieves excellent performance in terms of scale and rotation invariance by employing the following technical means, making it adaptable to various planar drawing styles:
[0056] 1) Vectorization: Convert pixel images into polygon vector data (e.g., lines become polygons). Vector graphics will not be distorted when enlarged, reduced (scale changes) or rotated;
[0057] 2) Graph Neural Network (GNN) Analysis: GNN is used to analyze the connections between rooms (such as the connection between walls and doors). GNN only cares about the connections, and the connections remain unchanged no matter how the graph is rotated or scaled.
[0058] 3) Local object detection: Each room is cut out separately, and an object detection model is used to find objects (such as beds and tables). Only local features are considered, and the whole room is not affected by rotation or scaling.
[0059] 4. Improved versatility, independent of specific styles, overcoming the limitations of rule-based or pixel-based segmentation methods that are heavily dependent on specific datasets. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of the vectorization process according to an embodiment of the present invention. Figure 1In the diagram, (a) is the input binarized image, (b) is an empty polygon of the same size as the binarized pixel image, (c) is the first set of vectorized polygons obtained by vectorizing and buffering the white region according to the thickness of the surrounding pixel lines, (d) is the second set of polygons after performing a difference operation on the white region using an empty polygon of the same size as the binarized pixel image, and the black region is transformed, and (e) is the polygon set generated by merging the first set of polygons and the second set of polygons.
[0061] Figure 2 This is a schematic diagram of the buffering process in the vectorization process of an embodiment of the present invention.
[0062] Figure 3 This is a test set and training accuracy curve for one embodiment of the present invention.
[0063] Figure 4 This is a curve showing the training accuracy of one embodiment of the present invention compared with other network models.
[0064] Figure 5 This is a technical roadmap of a building planar element recognition method based on graph neural networks and convolutional neural networks, according to an embodiment of the present invention. Detailed Implementation
[0065] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. The described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0066] This invention provides a method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks, comprising the following steps:
[0067] Step S01: Input the building plan pixel image, and preprocess it through layer filtering and information extraction to obtain a binarized pixel image;
[0068] Step S02: Vectorize the binarized pixel image to obtain a vectorized image;
[0069] Step S03: Perform image segmentation on the vectorized image;
[0070] Step S04: Construct a region adjacency graph using the segmented vectorized image;
[0071] Step S05: Optimize the region adjacency graph using graph analysis and region merging using a graph neural network to identify room edges;
[0072] Step S06: Calculate the room area;
[0073] Step S07: Use a convolutional neural network image recognition model to identify items in the room;
[0074] Step S08: Predict room function based on the recognition results.
[0075] Furthermore, step S01 specifically includes the following steps:
[0076] Input a planar image, merge the red, blue, and green channels of the image into one channel, and perform binarization processing;
[0077] Use optical character recognition technology to remove text information from images.
[0078] Furthermore, step S02 specifically includes the following steps:
[0079] The white areas in the binarized pixel image are vectorized and buffered according to the thickness of the surrounding pixel lines to obtain the first set of vectorized polygons.
[0080] If the binarized pixel image includes black areas, then the white areas are subtracted using empty polygons of the same size as the binarized pixel image, and the black areas are converted into a second set of polygons.
[0081] Finally, the first polygon set and the second polygon set are merged to generate a complete polygon set;
[0082] The buffer is defined as covering each pixel line in the vectorized white area with two polygons from both the horizontal and vertical directions, based on the thickness of the pixel line.
[0083] Furthermore, step S03 specifically includes the following steps:
[0084] S301, perform superpixel segmentation;
[0085] S302 visualizes the segmented regions;
[0086] S303 utilizes a pre-trained model to perform semantic segmentation of segmented regions through deep learning.
[0087] Furthermore, step S04 specifically includes the following steps:
[0088] S401, Construct a region adjacency graph based on the color mean of superpixels;
[0089] S402: Assign weights to the region adjacency graph based on color similarity or boundary gradient, and obtain the edge features and node features of the region adjacency graph.
[0090] Furthermore, step S05 specifically includes the following steps:
[0091] S501 converts the region adjacency graph into input data usable by the GNN network model, including graph structure, node features and edge features, and inputs it into the GNN network model.
[0092] S502 uses graph neural network models GCN or GAT to analyze graph structure, node features, and edge features;
[0093] S503 uses labeled data to train a GNN network model to predict node categories or boundary relationships; for example... Figures 3-4 The figure shows the training accuracy of this embodiment and its comparison with other network models.
[0094] S504: Merge adjacent regions based on edge features and / or node categories, use edge weights to predict whether edges belong to the same room, trim edges to segment regions based on edge weight thresholds, obtain node classification results, and identify room edges.
[0095] S505 maps the node classification results back to the original image, generating an image with labeled rooms and optimized boundaries.
[0096] Further, step S06 specifically includes: counting the number of pixels in each room, converting it to area according to the scale, and obtaining the room area.
[0097] Furthermore, step S07 specifically includes the following steps:
[0098] S701, Load the object detection model and input the segmented room image;
[0099] S702: Traverse the segmented room regions, capture independent images of each room, and call the object detection model for each room to identify objects.
[0100] Furthermore, step S08 specifically includes the following steps:
[0101] S801, predefined mapping rules between items and room functions;
[0102] S802, iterate through the detection results of items in the room and count the categories of items appearing in the room;
[0103] S803, calculate the functional probability distribution of each room based on the category and quantity of the items and the mapping rules between items and room functions.
[0104] Furthermore, it also includes step S09, visualization of the recognition results, which specifically includes the following steps:
[0105] S901, Generate a color-coded marker map;
[0106] S902, Overlapping Boundary;
[0107] S903, export room area information;
[0108] S904, mark the detected items and functional categories for each room on the resulting image;
[0109] S905 saves the labeled image and room function information.
[0110] Example 1
[0111] The following is a detailed description of the architectural planar element recognition method based on graph neural networks and convolutional neural networks of the present invention.
[0112] This invention provides a method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks, comprising the following steps:
[0113] Step S01: Input the building plan pixel image, and preprocess it through layer filtering and information extraction to obtain a binarized pixel image;
[0114] Step S02: Vectorize the binarized pixel image to obtain a vectorized image;
[0115] Step S03: Perform image segmentation on the vectorized image;
[0116] Step S04: Construct a region adjacency graph using the segmented vectorized image;
[0117] Step S05: Optimize the region adjacency graph using graph analysis and region merging using a graph neural network to identify room edges;
[0118] Step S06: Calculate the room area;
[0119] Step S07: Use a convolutional neural network image recognition model to identify items in the room;
[0120] Step S08: Predict room function based on the recognition results.
[0121] Example 2
[0122] The following is a detailed description of the architectural planar element recognition method based on graph neural networks and convolutional neural networks of the present invention.
[0123] like Figures 1-5 As shown, this invention provides a method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks, comprising the following steps:
[0124] Step S01: Input the building plan pixel image, and preprocess it through layer filtering and information extraction to obtain a binarized pixel image;
[0125] In this embodiment, step S01 specifically includes the following steps:
[0126] Input a planar image, merge the red, blue, and green channels of the image into one channel, and perform binarization processing;
[0127] Use optical character recognition technology to remove text information from images.
[0128] Binarization is an operation in image processing that converts a grayscale or color image into an image containing only black (0) and white (1). Its purpose is to simplify image content and make processing more efficient, especially when extracting specific targets (such as lines, regions, text, etc. in a planar image).
[0129] Optical Character Recognition (OCR) technology is used to remove text information. In architectural floor plans, text information (such as room names, dimensions, annotations, etc.) often coexists with architectural elements (such as walls, doors, windows, etc.). To focus on the analysis and processing of architectural elements, this text information needs to be removed first.
[0130] Step S02: Vectorize the binarized pixel image to obtain a vectorized image;
[0131] In this embodiment, as Figure 1 As shown, step S02 specifically includes the following steps:
[0132] Binarized pixel image ( Figure 1 The white area in (a) is vectorized and buffered according to the thickness of the surrounding pixel lines to obtain the first vectorized polygon set. Figure 1 (c) in the middle);
[0133] If the binarized pixel image includes black areas, then use an empty polygon of the same size as the binarized pixel image. Figure 1 (b) performs a difference operation on the white area to convert the black area into a second polygon set. Figure 1 (d) in the middle);
[0134] Finally, the first polygon set and the second polygon set are merged to generate a complete polygon set. Figure 1 (e) in the middle);
[0135] The buffering process involves covering each pixel line in the vectorized white area with two polygons from both the horizontal and vertical directions, based on the thickness of the pixel lines. The buffered polygons are crucial because if the polygons are separated, the adjacency operation will return a false value when constructing the adjacency graph. Figure 2 As shown, with the width t of the pixel line as the reference, the buffer distance parameter is selected as t / 2 because each pixel line must be covered by two polygons from both the horizontal and vertical directions.
[0136] Before performing image segmentation, the following environment framework can be installed:
[0137] OpenCV: Used for image reading, grayscale conversion, noise reduction, and edge enhancement;
[0138] Scikit-Image: Provides the SLIC superpixel segmentation algorithm and region segmentation tools;
[0139] Deep learning: For example, complex planar graphs can be semantically segmented using U-Net in PyTorch;
[0140] Scikit-Image: Provides region merging functionality (such as threshold-based cropping).
[0141] PyTorch Geometric or DGL: Optimizes region segmentation using graph neural networks (GNNs) in complex tasks.
[0142] Step S03 involves image segmentation of the vectorized image, which specifically includes the following steps in this embodiment:
[0143] S301, perform superpixel segmentation;
[0144] S302 visualizes the segmented regions;
[0145] S303 utilizes a pre-trained model to perform semantic segmentation of segmented regions through deep learning.
[0146] Furthermore, in this embodiment:
[0147] S301, Superpixel segmentation: Superpixels are generated using the SLIC algorithm;
[0148] S302, Visualization of segmented regions: Use skimage.segmentation.mark_boundaries() to check superpixel effects;
[0149] S303 utilizes pre-trained models (such as U-Net) to perform semantic segmentation of segmented regions through deep learning.
[0150] Step S04: Construct a region adjacency graph using the segmented vectorized image; in this embodiment, this specifically includes the following steps:
[0151] S401, Construct a region adjacency graph based on the color mean of superpixels;
[0152] S402: Assign weights to the region adjacency graph based on color similarity or boundary gradient, and obtain the edge features and node features of the region adjacency graph.
[0153] Step S05 involves using a graph neural network to optimize the region adjacency graph through graph analysis and region merging, thereby identifying room edges. In this embodiment, step S05 specifically includes the following steps:
[0154] S501 converts the region adjacency graph into input data usable by the GNN network model, including graph structure, node features and edge features, and inputs it into the GNN network model.
[0155] In this embodiment, the features of each node may include: average color (RGB value), texture features (such as statistics of the Gray-Level Co-occurrence Matrix (GLCM), and region area (number of pixels). Edge features may include: color difference between adjacent regions and boundary gradient strength. Graph data generation: The adjacency graph is converted into GNN format using NetworkX.
[0156] S502 uses graph neural network models GCN or GAT to analyze graph structure, node features, and edge features;
[0157] This embodiment also includes the definition of the GNN model, as shown in the following pseudocode:
[0158] import torch
[0159] import torch.nn.functional as F
[0160] from torch_geometric.nn import GCNConv, GATConv
[0161] # Define the GNN model
[0162] class GNNModel(torch.nn.Module):
[0163] def __init__(self, input_dim, hidden_dim, output_dim):
[0164] super(GNNModel, self).__init__()
[0165] self.conv1 = GCNConv(input_dim, hidden_dim)
[0166] self.conv2 = GCNConv(hidden_dim, output_dim)
[0167] def forward(self, data):
[0168] x, edge_index = data.x, data.edge_index
[0169] x = F.relu(self.conv1(x, edge_index))
[0170] x = F.softmax(self.conv2(x, edge_index), dim=1)
[0171] return x
[0172] # GNN model initialization
[0173] model=GNNModel(input_dim=node_features.shape[1],hidden_dim=32,output_dim=num_classes)
[0174] S503 uses labeled data to train a GNN network model to predict node categories or boundary relationships;
[0175] In this embodiment, the dataset is divided as follows: nodes are divided into training set, validation set, and test set; then, a loss function is defined: cross-entropy loss is used for node classification tasks, and the training loop is repeated. The specific pseudocode is as follows:
[0176] optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
[0177] for epoch in range(epochs):
[0178] model.train()
[0179] optimizer.zero_grad()
[0180] out = model(data)
[0181] loss = loss_fn(out[data.train_mask], data.y[data.train_mask])
[0182] loss.backward()
[0183] optimizer.step()
[0184] print(f'Epoch {epoch}, Loss: {loss.item()}')
[0185] S504: Merge adjacent regions based on edge features and / or node categories, use edge weights to predict whether edges belong to the same room, trim edges to segment regions based on edge weight thresholds, obtain node classification results, and identify room edges.
[0186] The pseudocode is as follows:
[0187] from skimage.future import graph
[0188] labels = graph.cut_threshold(segments, rag, threshold=optimized_threshold)
[0189] S505 maps the node classification results back to the original image, generating an image with labeled rooms and optimized boundaries.
[0190] The pseudocode is as follows:
[0191] import color from skimage
[0192] colored_labels = color.label2rgb(labels, image, kind='avg')
[0193] plt.imshow(colored_labels)
[0194] plt.show()
[0195] Step S06: Calculate the room area; in this embodiment, step S06 specifically includes: counting the number of pixels in each room, converting it to area according to the scale, and obtaining the room area.
[0196] In this embodiment, the pseudocode is as follows:
[0197] import numpy as np
[0198] unique_labels, counts = np.unique(labels, return_counts=True)
[0199] area_map = {label: count for label, count in zip(unique_labels,counts)}
[0200] Step S07: Identify items in the room using a convolutional neural network image recognition model; in this embodiment, step S07 specifically includes the following steps:
[0201] S701, Load the pre-trained object detection model (YOLOv8 can be used in this embodiment), and input the segmented room image;
[0202] import YOLO from ultralytics
[0203] model = YOLO("yolov8n.pt") # Select a suitable pre-trained model
[0204] results = model(image_path) # Input the segmented room image
[0205] S702: Traverse the segmented room regions, capture independent images of each room, and call the object detection model for each room to identify objects.
[0206] This embodiment also includes saving the detection results: The detection results for each room are stored, including item category and location, as shown in the pseudocode below:
[0207] detected_objects = results.pandas().xyxy# Save as Pandas DataFrame
[0208] Step S08: Predict room function based on the recognition result. In this embodiment, step S08 specifically includes the following steps:
[0209] S801, predefined mapping rules between items and room functions;
[0210] In this embodiment, the pseudocode is as follows:
[0211] room_mapping = {
[0212] "toilet": "bathroom",
[0213] "bed": "bedroom",
[0214] "sofa": "living room",
[0215] "desk": "office",
[0216] "stove": "kitchen",
[0217] }
[0218] S802, iterate through the detection results of items in the room and count the categories of items appearing in the room;
[0219] room_objects = {}
[0220] for room_id, objects in detected_objects.groupby("room_id"):
[0221] room_objects[room_id] = objects["class"].value_counts()
[0222] S803, calculate the functional probability distribution of each room based on the category and quantity of the items and the mapping rules between items and room functions. In this embodiment, the pseudocode is as follows:
[0223] room_function = {}
[0224] for room_id, objects in room_objects.items():
[0225] probable_function=max(objects.index,key=lambdaobj: room_mapping.get(obj, "unknown"))
[0226] room_function[room_id] = probable_function
[0227] Furthermore, this embodiment also includes step S09, visualization of the recognition result, which specifically includes the following steps:
[0228] S901, Generate a color-coded image; in this embodiment, the pseudocode is as follows:
[0229] import color from skimage
[0230] colored_labels = color.label2rgb(labels, image, kind='avg')
[0231] S902, Overlapping Boundary; in this embodiment, the pseudocode is as follows:
[0232] from skimage.segmentation import mark_boundaries
[0233] plt.imshow(mark_boundaries(colored_labels, labels))
[0234] S903, Export room area information; in this embodiment, the pseudocode is as follows:
[0235] import pandas as pd
[0236] df = pd.DataFrame({"Room ID": unique_labels, "Area (pixels)":counts})
[0237] df.to_csv("room_areas.csv", index=False)
[0238] S904, Mark the detected items and functional categories for each room on the resulting image; in this embodiment, the pseudocode is as follows:
[0239] for room_id, function in room_function.items():
[0240] centroid = calculate_room_centroid(room_segments[room_id])
[0241] plt.text(centroid[0], centroid[1], f"{function}", color="red")
[0242] S905, save the labeled image and room function information. In this embodiment, the pseudocode is as follows:
[0243] plt.savefig("annotated_floorplan.png")
[0244] pd.DataFrame(room_function).to_csv("room_functions.csv").
[0245] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks, characterized in that, Includes the following steps: Step S01: Input the building plan pixel image, and preprocess it through layer filtering and information extraction to obtain a binarized pixel image; Step S02: Vectorize the binarized pixel image to obtain a vectorized image; Step S03: Perform image segmentation on the vectorized image; Step S04: Construct a region adjacency graph using the segmented vectorized image; Step S05: Optimize the region adjacency graph using graph analysis and region merging using a graph neural network to identify room edges; Step S06: Calculate the room area; Step S07: Use a convolutional neural network image recognition model to identify items in the room; Step S08: Predict room function based on the recognition results; Specifically, step S05 includes the following steps: S501 converts the region adjacency graph into input data usable by the GNN network model, including graph structure, node features and edge features, and inputs it into the GNN network model. S502 uses graph neural network models GCN or GAT to analyze graph structure, node features, and edge features; S503 uses labeled data to train a GNN network model to predict node categories or boundary relationships; S504: Merge adjacent regions based on edge features and / or node categories, use edge weights to predict whether edges belong to the same room, trim edges to segment regions based on edge weight thresholds, obtain node classification results, and identify room edges. S505 maps the node classification results back to the original image, generating an image with labeled rooms and optimized boundaries; Specifically, step S02 includes the following steps: The white areas in the binarized pixel image are vectorized and buffered according to the thickness of the surrounding pixel lines to obtain the first set of vectorized polygons. If the binarized pixel image includes black areas, then the white areas are subtracted using empty polygons of the same size as the binarized pixel image, and the black areas are converted into a second set of polygons. Finally, the first polygon set and the second polygon set are merged to generate a complete polygon set; The buffer is defined as covering each pixel line in the vectorized white area with two polygons from both the horizontal and vertical directions, based on the thickness of the pixel line.
2. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, Step S01 specifically includes the following steps: Input a planar image, merge the red, blue, and green channels of the image into one channel, and perform binarization processing; Use optical character recognition technology to remove text information from images.
3. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, Step S03 specifically includes the following steps: S301, perform superpixel segmentation; S302 visualizes the segmented regions; S303 utilizes a pre-trained model to perform semantic segmentation of segmented regions through deep learning.
4. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 3, characterized in that, Step S04 specifically includes the following steps: S401, Construct a region adjacency graph based on the color mean of superpixels; S402: Assign weights to the region adjacency graph based on color similarity or boundary gradient, and obtain the edge features and node features of the region adjacency graph.
5. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, Step S06 specifically includes: counting the number of pixels in each room, converting it to area according to the scale, and obtaining the room area.
6. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, Step S07 specifically includes the following steps: S701, Load the object detection model and input the segmented room image; S702: Traverse the segmented room regions, capture independent images of each room, and call the object detection model for each room to identify objects.
7. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, Step S08 specifically includes the following steps: S801, predefined mapping rules between items and room functions; S802, iterate through the detection results of items in the room and count the categories of items appearing in the room; S803, calculate the functional probability distribution of each room based on the category and quantity of the items and the mapping rules between items and room functions.
8. The method for recognizing architectural planar elements based on graph neural networks and convolutional neural networks according to claim 1, characterized in that, It also includes step S09, visualization of the recognition results, which specifically includes the following steps: S901, Generate a color-coded marker map; S902, Overlapping Boundary; S903, export room area information; S904, mark the detected items and functional categories for each room on the resulting image; S905 saves the labeled image and room function information.
Citation Information
Patent Citations
House type image recognition method based on region segmentation and target detection
CN118447527A
Vectorization rough planar graph segmentation method based on double-flow graph neural network
CN119048756A