Subway station room layout paper wall line extraction method based on improved canny algorithm and hough transform
By using an improved Canny algorithm and Hough transform, combined with image processing and wall line merging techniques, wall line information of subway station room layout drawings is automatically extracted. This solves the problems of low efficiency and poor accuracy in traditional methods, and achieves efficient and accurate wall line extraction and data output.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2026-03-03
AI Technical Summary
Traditional methods for vectorizing wall lines in subway station room layout drawings rely on manual annotation or semi-automatic recognition, which suffers from low efficiency and low accuracy, making it difficult to meet the needs of shortening the design cycle and controlling engineering costs.
An improved Canny algorithm and Hough transform are employed, and contrast is enhanced through multi-channel CLAHE processing of the image. Edge detection is performed by combining the Laplacian sharpening kernel, noise is removed by using a median filter, and wall lines are detected and merged by length-weighted directional consistency through Hough transform, thereby achieving automated and accurate extraction of wall line information.
It improves the accuracy and efficiency of extracting wall lines from subway station room layout drawings. The output standardized data can be directly imported into CAD software, supporting intelligent design and construction and reducing labor costs.
Smart Images

Figure CN120318082B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary field of rail transit information technology and computer vision, and in particular to a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform. The method is especially suitable for the accurate identification and standardized vector data output of room wall lines in subway room layout drawings. Background Technology
[0002] In recent years, my country's urbanization process has accelerated, and rail transit construction has entered a stage of rapid development. During this urbanization process, the scale of my country's rail transit lines has continued to expand, significantly increasing the design complexity of subway station rooms. The contradiction between compressed design cycles and the need for engineering cost control has become increasingly prominent. At the same time, the penetration of artificial intelligence technologies (such as computer vision and deep learning) into the field of civil engineering has given rise to new paradigms of "intelligent transportation" and "intelligent civil engineering." Technologies such as automated and precise analysis of wall lines in subway station room layout drawings and standardized vector data output provide strong support for the intelligent transformation of future large-scale rail transit construction.
[0003] Traditional methods for extracting wall lines from subway station room layout drawings rely on manual annotation or semi-automatic software recognition, resulting in low efficiency and accuracy. In the design process of subway station room layouts, multi-channel collaborative image enhancement and improved wall line edge detection technology, combined with wall line merging algorithms, can automatically and accurately extract and output wall line information from subway station room layout drawings. This facilitates intelligent design and construction applications in subsequent CAD engineering, improving design efficiency. Summary of the Invention
[0004] The purpose of this invention is to solve the problems in the prior art and proposes a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform.
[0005] This invention is achieved through the following technical solution: This invention proposes a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform. The method includes the following steps:
[0006] A. Apply contrast-limited adaptive histogram equalization (CLAHE) to the B, G, and R channels of the input subway station room layout color block image to enhance image contrast, and apply Laplacian sharpening kernel to enhance the high-frequency sharpening of the wall lines at the edges of the color blocks.
[0007] B. By using a median filter instead of a Gaussian filter to filter nonlinear noise in each sharpened channel, Canny edge detection is performed on each channel, and the multi-channel room edge wall line detection results are fused by bit OR operation. The fused room edge wall lines are then binarized and subjected to morphological closing operation to connect broken wall lines.
[0008] C. By detecting and extracting room wall line information through Hough transform, adjacent room wall lines with similar angles are merged based on length-weighted directional consistency to obtain the wall line geometric information of subway station room layout drawings, which can be imported into CAD software.
[0009] Further, step A specifically includes:
[0010] a1. Separate the BGR color channel of the color block diagram of the subway station room layout;
[0011] a2. Apply contrast-limited adaptive histogram equalization (CLAHE) to each channel independently to enhance image contrast;
[0012] a3. Apply the Laplacian sharpening kernel to enhance the high-frequency sharpening of the wall lines at the edges of color blocks.
[0013] Further, step B specifically includes:
[0014] b1. Perform nonlinear denoising on each enhancement channel using a median filter;
[0015] b2. The Canny algorithm with dual thresholds is used to detect the room edge wall lines in each channel, and the resulting room edge wall line maps for each color channel are denoted as E. B E G and E R ;
[0016] b3. Generate a joint edge graph E by fusing bits using bitwise OR operations. fusion =E B ∨E G ∨E R ;
[0017] b4. Binarize the merged room edge wall lines and perform morphological closing operations to connect the broken wall lines.
[0018] Further, step C specifically includes:
[0019] c1. Obtain the initial set of wall lines L = {l1, l2, ..., l...} through Hough transform detection. n};
[0020] c2. For any two wall lines l i ,l j Consistency determination of execution direction in ∈L;
[0021] c3. Determine the spatial proximity of wall lines with the same direction;
[0022] c4. Perform a weighted directional average on wall lines that are in the same direction and spatially adjacent to obtain the merged direction and determine the endpoints of the merged wall lines;
[0023] c5. Store the extracted room wall line information into an Excel spreadsheet, which supports importing from CAD files.
[0024] Furthermore, in step c2, for any two wall lines l i ,l j ∈L, where the wall line l i The two endpoints are represented by (x1, y1) and (x2, y2), and the wall line l j The two endpoints are represented by (x′1, y′1) and (x′2, y′2). Calculate the angle difference: Δθ=|θ i -θ j The actual angle difference needs to be corrected to Δθ. 实际 =min(Δθ,180°-Δθ), if Δθ 实际 <θ t If the angles of the two wall lines are similar, then θ is considered to be similar. t This is a preset angle threshold.
[0025] Furthermore, in step c3, the two wall lines with the same direction are calculated. i ,l j Minimum Euclidean distance between ∈L If d min <d t If the two wall lines are considered sufficiently close, then d t This is the preset distance threshold.
[0026] Furthermore, in step c4, for wall lines l that satisfy the conditions of consistent direction and spatial proximity... i ,l j The combined principal direction ∈L is calculated using a weighted average, and the wall line l is... i ,l j The direction vector ∈L is represented by the difference between its endpoints: v i =(x2-x1,y2-y1),v j = (x′2-x′1, y′2-y′1); the lengths of the two wall lines are respectively: The direction vector after weighted average: Length v merge Components in the x and y directions: Normalize the merged direction vector:
[0027] Further, in step c4, the four endpoints (x1, y1) and (x2, y2) of the two wall lines are projected onto the weighted average direction u. The projection value is calculated using the dot product formula: proj(p) = p x ·u x +p y ·u y , where point p = (p x ,p y () represents any endpoint; determine the endpoints to be merged: That is, the starting point of the merged wall line is the endpoint with the smallest projection value, corresponding to the leftmost point in the main direction, and the ending point is the endpoint with the largest projection value, corresponding to the rightmost point in the main direction.
[0028] The present invention also proposes an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method for extracting wall lines from subway station room layout drawings based on the improved Canny algorithm and Hough transform.
[0029] The present invention also proposes a computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement the steps of the method for extracting wall lines from subway station room layout drawings based on the improved Canny algorithm and Hough transform.
[0030] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0031] This invention proposes a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform. The method enhances images through multi-channel CLAHE processing and Laplacian sharpening, applies an improved Canny edge detection algorithm and Hough transform to detect wall lines, and then merges the wall lines to extract standardized geometric data of wall lines from subway station room layout drawings. The output file can be directly imported into CAD software, exhibiting good adaptability to practical engineering applications and solving the problems of low efficiency, poor accuracy, and unstructured output of traditional methods. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0033] Figure 1This is a flowchart of a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform, as described in this invention.
[0034] Figure 2 These are the color block diagram of the subway station room layout and the label diagram of the station room name input in this invention;
[0035] Figure 3 These are the room wall lines extracted in this invention after image preprocessing enhancement and improved Canny detection;
[0036] Figure 4 This is a schematic diagram illustrating the principle of merging adjacent room wall lines with similar angles based on length-weighted directional consistency in this invention.
[0037] Figure 5 This is a schematic diagram of the processing result after Hough transform and wall line merging in this invention;
[0038] Figure 6 This is a schematic diagram illustrating the effect of importing the wall line geometric data extracted in this invention into CAD. Detailed Implementation
[0039] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0040] Combination Figures 1-6 This invention proposes a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform. The method includes the following steps:
[0041] A. Apply contrast-limited adaptive histogram equalization (CLAHE) to the B, G, and R channels of the input subway station room layout color block image to enhance image contrast, and apply Laplacian sharpening kernel to enhance the high-frequency sharpening of the wall lines at the edges of the color blocks.
[0042] B. By using a median filter instead of a Gaussian filter to filter nonlinear noise in each sharpened channel, Canny edge detection is performed on each channel, and the multi-channel room edge wall line detection results are fused by bit OR operation. The fused room edge wall lines are then binarized and subjected to morphological closing operation to connect broken wall lines.
[0043] C. By detecting and extracting room wall line information through Hough transform, adjacent room wall lines with similar angles are merged based on length-weighted directional consistency to obtain the wall line geometric information of subway station room layout drawings, which can be imported into CAD software.
[0044] Step A specifically involves:
[0045] a1. Separate the BGR color channel of the color block diagram of the subway station room layout;
[0046] a2. Apply contrast-limited adaptive histogram equalization (CLAHE) to each channel independently to enhance image contrast;
[0047] a3. Apply the Laplacian sharpening kernel to enhance the high-frequency sharpening of the wall lines at the edges of color blocks.
[0048] Step B specifically involves:
[0049] b1. Perform nonlinear denoising on each enhancement channel using a median filter;
[0050] b2. The Canny algorithm with dual thresholds is used to detect the room edge wall lines in each channel, and the resulting room edge wall line maps for each color channel are denoted as E. B E G and E R ;
[0051] b3. Generate a joint edge graph E by fusing bits using bitwise OR operations. fusion =E B ∨E G ∨E R ;
[0052] b4. Binarize the merged room edge wall lines and perform morphological closing operations to connect the broken wall lines.
[0053] Step C specifically involves:
[0054] c1. Obtain the initial set of wall lines L = {l1, l2, ..., l...} through Hough transform detection. n};
[0055] c2. For any two wall lines l i ,l j Consistency determination of execution direction in ∈L;
[0056] c3. Determine the spatial proximity of wall lines with the same direction;
[0057] c4. Perform a weighted directional average on wall lines that are in the same direction and spatially adjacent to obtain the merged direction and determine the endpoints of the merged wall lines;
[0058] c5. Store the extracted room wall line information into an Excel spreadsheet, which supports importing from CAD files.
[0059] In step c2, for any two wall lines l i ,l j ∈L, where the wall line l i The two endpoints are represented by (x1, y1) and (x2, y2), and the wall line l j The two endpoints are represented by (x′1, y′1) and (x′2, y′2). Calculate the angle difference: Δθ=|θ i -θ j The actual angle difference needs to be corrected to Δθ. 实际 =min(Δθ,180°-Δθ), if Δθ 实际 <θ t If the angles of the two wall lines are similar, then θ is considered to be similar. t This is a preset angle threshold.
[0060] In step c3, calculate the two wall lines with the same direction l. i ,l j Minimum Euclidean distance between ∈L If d min <d t If the two wall lines are considered sufficiently close, then d t This is the preset distance threshold.
[0061] In step c4, the wall lines l that satisfy the conditions of consistent direction and spatial proximity are... i ,l j The combined principal direction ∈L is calculated using a weighted average, and the wall line l is... i ,l j The direction vector ∈L is represented by the difference between its endpoints: v i =(x2-x1,y2-y1),v j = (x′2-x′1, y′2-y′1); the lengths of the two wall lines are respectively: The direction vector after weighted average: Length v merge Components in the x and y directions: Normalize the merged direction vector:
[0062] In step c4, the four endpoints (x1, y1) and (x2, y2) of the two wall lines are projected onto the weighted average direction u. The projection value is calculated using the dot product formula: proj(p) = p x ·u x +p y ·u y, where point p = (p x ,p y () represents any endpoint; determine the endpoints to be merged: That is, the starting point of the merged wall line is the endpoint with the smallest projection value, corresponding to the leftmost point in the main direction, and the ending point is the endpoint with the largest projection value, corresponding to the rightmost point in the main direction.
[0063] Example
[0064] This embodiment applies the invention to the extraction of wall line geometric information from room layout drawings of a subway station in a certain area. Figure 1 A flowchart of the method of the present invention is provided. Figure 2 The original color block diagram of the subway station room layout and the labeling diagram of the station room names are provided. Figure 3 The extracted room wall lines are presented after image preprocessing enhancement and improved Canny detection; Figure 4 A schematic diagram is given on the principle of merging adjacent room wall lines with similar angles based on length-weighted directional consistency. It includes two wall lines that need to be merged, the merging direction based on length-weighted average, and the endpoints of the merged wall lines. Figure 5 This is a schematic diagram of the processing result after Hough transform and wall line merging. Figure 6 A schematic diagram showing the effect of importing the extracted wall line geometry data into CAD.
[0065] In this embodiment, step A enhances the image by performing multi-channel preprocessing on the color block diagram of the subway station room layout, such as... Figure 2 The color block image of the subway station room layout is subjected to three-channel color separation, CLAHE processing to enhance image contrast, and Laplacian sharpening. Then, step B extracts the image using improved Canny edge detection and morphological closing operations. Figure 3 The room wall lines are shown.
[0066] In this embodiment, step C extracts room wall line information through Hough transform, and then merges adjacent room wall lines with similar angles based on length-weighted directional consistency. The principle of wall line merging is as follows: Figure 4 As shown, the results before and after the merger are as follows: Figure 5 As shown, the wall line geometry information obtained from the subway station room layout drawings can be imported into CAD software to generate vector line segments, such as... Figure 6 As shown.
[0067] This invention proposes a method for extracting wall lines from subway station room layout drawings based on an improved Canny algorithm and Hough transform. The method includes the following steps: Image preprocessing and enhancement of the original subway station room layout color block drawing is performed, separating the BGR color channels and applying Contrast-Limited Adaptive Histogram Equalization (CLAHE) to each of the three channels to enhance image contrast. Then, Laplacian convolution kernels are used to sharpen and enhance the room edge wall lines on each of the three color channels. Canny edge detection is performed on each processed channel, and median filtering is used to replace Gaussian filtering to filter nonlinear noise. The multi-channel room edge wall line detection results are then fused. The fused room edge wall lines are binarized and subjected to morphological closing operations to connect broken wall lines. Hough transform is used to detect and extract room wall line information. Adjacent room wall lines with similar angles are merged based on the direction consistency weighted by line segment length to obtain the wall line geometric information of the subway station room layout drawing. This method supports one-click import into engineering design software such as AutoCAD and Revit to generate vector graphics. This invention can be applied to the digital conversion of subway station room design drawings, improving the accuracy and efficiency of geometric information extraction from drawings, outputting structured data, reducing labor costs, and promoting the intelligent upgrading of engineering design processes.
[0068] The present invention also proposes an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method for extracting wall lines from subway station room layout drawings based on the improved Canny algorithm and Hough transform.
[0069] The present invention also proposes a computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement the steps of the method for extracting wall lines from subway station room layout drawings based on the improved Canny algorithm and Hough transform.
[0070] The memory in this application embodiment can be volatile memory or non-volatile memory, or it can include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DRRAM). It should be noted that the memory used in the methods described in this invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0071] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs (DVDs)), or semiconductor media (e.g., solid-state disks (SSDs)).
[0072] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0073] It should be noted that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuitry in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0074] The above provides a detailed description of the wall line extraction method for subway station room layout drawings based on the improved Canny algorithm and Hough transform proposed in this invention. Specific examples have been used to illustrate the principle and implementation of this invention. The description of the above embodiments is only for the purpose of helping to understand the method and core idea of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation and application scope based on the idea of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A subway station room layout drawing wall line extraction method based on an improved Canny algorithm and Hough transform, characterized in that, The method comprises the following steps: A. Applying CLAHE processing to enhance the contrast of the input subway station room layout color block diagram B, G, R three channels respectively, and applying Laplacian sharpening kernel to perform high-frequency sharpening enhancement on the color block edge wall line; B. By using a median filter instead of a Gaussian filter, filter the nonlinear noise of each channel after sharpening, perform Canny edge detection on each channel, and fuse the multi-channel room edge wall line detection results by bit OR operation, and perform binaryzation processing and morphological closing operation on the fused room edge wall line to connect the broken wall line; C. Detect and extract room wall line information by Hough transform, merge adjacent and angle similar room wall lines based on length weighted direction consistency, obtain the wall line geometric information of the subway station room layout drawing, and support import into CAD software; The step C is specifically: c1. obtain an initial set of wall lines by hough transform detection ; c2. for any two wall lines performing the direction consistency determination; c3. Determine the spatial proximity of the direction consistent wall line pairs; c4. Perform weighted direction average on the direction consistent and spatially adjacent wall lines to obtain the merged direction and determine the end points of the merged wall lines; c5. Store the extracted room wall line information in an Excel table to support import into CAD; Step c2 for any two wall lines where two end points of wall line are denoted by and , two end points of wall line are denoted by and , the angle difference is calculated as , the actual angle difference is corrected as , if , the angle of two wall lines is considered similar, where is a pre-defined angle threshold; Step c3: Calculate the minimum Euclidean distance between two wall lines with the same direction If , then the two wall lines are considered close enough, where is a pre-defined distance threshold. The wall lines in step c4 that meet the direction consistency and spatial proximity The combined main direction is calculated by weighted average The direction vector of the wall line is represented by its endpoint difference: The lengths of the two wall lines are: , The weighted average direction vector: The module length ; The components in the x, y directions: , Unitize the combined direction vector: ; The four end points of the two wall lines in step c4 And Project onto the weighted average direction The projection value is calculated by the dot product formula: Where the point is an arbitrary end point; determine the merged end points: That is, the start point of the merged wall line is the end point with the smallest projection value, corresponding to the leftmost point in the main direction, and the end point is the end point with the largest projection value, corresponding to the rightmost point in the main direction.
2. The method of claim 1, wherein, The step A is specifically: a1. Separate the BGR color channels of the subway station room layout color block diagram; a2. Independently apply CLAHE processing to enhance the contrast of each channel; a3. Apply Laplacian sharpening kernel to perform high-frequency sharpening enhancement on the color block edge wall line.
3. The method of claim 1, wherein, The step B is specifically: b1. Use a median filter to perform nonlinear noise reduction on each enhanced channel; b2. The Canny algorithm with double threshold is used to detect the room edge wall line of each channel, and the room edge wall line map of each color channel is recorded as ; b3. fusing to generate a joint edge map by a bitwise OR operation ; b4. Perform binaryzation processing and morphological closing operation on the fused room edge wall line to connect the broken wall line.
4. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to realize the steps of the method of any one of claims 1-3.
5. A computer readable storage medium storing computer instructions, characterized in that, The computer instructions are executed by the processor to realize the steps of the method of any one of claims 1-3.