Lane area segmentation method, system, electronic device and storage medium
Through the segmentation method based on road images, the Hough algorithm and double threshold binarization technology are used to solve the problem of inaccurate segmentation of lane areas in complex environments, achieve fast and accurate lane area segmentation, and ensure the integrity and accuracy of the segmentation.
Patent Information
- Application Number
- CN202310271172.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-03-20
AI Technical Summary
Existing lane area segmentation methods are difficult to accurately segment the lane area when faced with changes in the brightness of road image data caused by weather changes and too many objects around the road, resulting in problems such as difficulty in removing objects and inaccurate segmentation.
A segmentation method based on road images is adopted. Grayscale processing and Hough algorithm are used to extract lines, cluster and sort them. Lines are screened using the angle between the line and the x-axis and the distance from the origin. Double-threshold binarization and morphological opening operation of digital image processing are combined to eliminate interfering objects and determine the lane area.
It achieves the rapid and accurate segmentation of the driving lane area in complex environments, effectively removes interfering objects, and ensures the integrity and accuracy of the driving lane area.
Smart Images

Figure CN116309667B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of digital image processing, and in particular relates to a lane area segmentation method, system, electronic equipment and storage medium. Background Art
[0002] Today, with highly developed road traffic, convenience and potential risks coexist. Demand for assisted and autonomous driving technologies is growing, and this in turn places higher demands on timely monitoring and early warning of road conditions. Assisted and autonomous driving technologies can help drivers maintain stability while on the road and issue warnings for erroneous driving. Road monitoring systems monitor vehicles for compliance by dividing and demarcating lanes between lane markings.
[0003] The accuracy of lane segmentation plays a crucial role in autonomous driving, assisted driving, and road monitoring systems. The input data for road monitoring systems comes from road monitoring cameras. This data needs to be analyzed and processed to obtain road information, such as lane lines, lane areas, and road signs, so that effective road monitoring can be performed. To date, although many scholars at home and abroad have proposed numerous recognition algorithms and achieved promising results, with the rapid development of science and technology, extracting road information from monitoring images remains a significant challenge. Factors such as changes in road image brightness due to weather changes and an excessive number of objects around the road can lead to confusion between surrounding objects and lane areas, making it difficult to remove objects during lane segmentation and inaccurately segmenting the lane area. Existing methods cannot effectively address these issues. Summary of the Invention
[0004] In order to solve the technical problems mentioned in the above background technology, the present invention proposes a lane area segmentation method, system, electronic device and storage medium.
[0005] In order to achieve the above technical objectives, the technical solution of the present invention is:
[0006] A lane area segmentation method based on a road image comprises the following steps:
[0007] S1. Acquire a road image and perform grayscale processing. Set a single threshold t0 to binarize the grayscale road image. Use the Hough algorithm to extract straight lines in the binary image and store the straight line information.
[0008] S2. Cluster the lines obtained in step S1 according to the number of road lines k, and remove interfering lines. Sort the clustered lines according to the angle θ between the line and the x-axis. If the angle θ between the lines and the x-axis is the same, sort them according to the distance ρ from the origin. Extract the first and last lines l1 and l2 from the sorted lines.
[0009] S3. Setting a default range for each row of the grayscaled road image in step S1, wherein the default range is from 0 to the maximum width of the road; calculating the coordinate values of the intersections of the straight lines l1, l2 obtained in step S2 with each row of the image; comparing the default range with the range of the coordinate values of the intersections l1, l2 to obtain the range of each row of the grayscaled road image; pixels within the set range retain their original grayscale values, and pixels outside the range are set to zero;
[0010] S4. Calculate the grayscale histogram of the image obtained after the segmentation in step S3, find the peaks of the histogram except for the grayscale value of 0; find the valleys on both sides of the peaks, set the grayscale values corresponding to the valleys on both sides as thresholds; perform binarization using double thresholds to segment the lane area;
[0011] S5. Perform a morphological opening operation using digital image processing on the lane area image obtained by segmentation in step S4 to disconnect narrow connections; detect connected domains and assign labels to each detected connected domain; retain the two connected domains with the largest areas, which are the lane areas of the road.
[0012] Preferably, step S1 specifically includes the following steps:
[0013] S11, performing grayscale processing on an input road image with a width of W and a height of H to obtain a grayscale road image;
[0014] S12. Utilizing the high brightness of road lines in the grayscale road image, a threshold value t0 for highlighting road lines is determined through histogram statistics. The grayscale road image obtained in step S11 is subjected to threshold binarization to obtain a road binary image. The image removes ground objects and lane areas outside the road lines, highlighting the road line information. The threshold binarization processing formula is expressed as follows:
[0015]
[0016] Where p represents the grayscale value of a single pixel in the image after threshold binarization, p represents the grayscale value of a single pixel in the image before threshold binarization, and t0 represents the threshold used for threshold binarization.
[0017] S13. Perform the Hough algorithm on the binary road image obtained in step S12 to extract straight lines in the image, and store the straight line information, wherein the straight line information includes: the angle θ between the straight line and the x-axis, the distance ρ from the straight line to the origin, and the statistical brightness light of the straight line in the Hough image.
[0018] Preferably, step S2 specifically includes the following steps:
[0019] S21. Cluster the line information obtained in step S1 according to the number k of road lines in the road image to remove interfering lines. The clustering steps are as follows: categorize the lines into k groups based on their angle range with the x-axis, then perform a weighted average of the lines within different angle ranges based on their brightness in the Hough image. Count one line information within each range, for a total of k line information.
[0020] S22. Sort the k pieces of line information obtained in step S21: first, compare the angles θ between the lines and the x-axis in the line information, and sort them by the magnitude of θ; if the values of θ are the same, sort them by the distance ρ from the origin; and obtain the k pieces of line information sorted in the order of the image.
[0021] S23. Take the first and last straight lines l1 and l2 from the straight line information sorted in step S22.
[0022] Preferably, step S3 specifically includes the following steps:
[0023] S31, setting a default range for each row of the grayscale road image obtained in step S1, with the initial range being [0, W], where W is the maximum width of the road image;
[0024] S32, finding the intersection pixels p1, p2 between the straight lines l1, l2 obtained in step S2 and each row of pixels in the grayscale road image;
[0025] S33. Compare p1 and p2 with the default range [0, W] to determine whether p1 and p2 are within [0, W]. The final range is determined based on the determination result. The determination process is as follows:
[0026] If p1∈[0,W],p2∈[0,W], then the range is [p1,p2];
[0027] If p1∈[0,W], Then the range is [p1,W];
[0028] like p2∈[0,W], then the range is [0,p2];
[0029] like Then the range is [0,W];
[0030] S34. Each row of pixels on the grayscale road image is judged in turn. If the pixels on each row are within the set range, the original grayscale value is maintained; if they are outside the set range, the grayscale value is set to 0.
[0031] Preferably, step S4 specifically includes the following steps:
[0032] S41, calculating a grayscale histogram of the road image after cutting in step S3;
[0033] S42, collecting the peak of the histogram in the grayscale histogram obtained in step S41, the grayscale value corresponding to the peak is tmax, tmax≠0;
[0034] S43, taking the peak obtained in step S42 as the center, searching for a valley on each side of the peak, where the grayscale values corresponding to the valleys on both sides are t1 and t2 respectively;
[0035] S44, using t1 and t2 as double thresholds, perform double threshold binarization on the image obtained in step (304) to obtain the lane area. The threshold binarization processing formula is expressed as follows:
[0036]
[0037] Where p represents the grayscale value of a single pixel in the image after threshold binarization.
[0038] Preferably, step S5 specifically includes the following steps:
[0039] S51, performing mathematical morphological processing on the binary image obtained in step S4, and then performing an opening operation to eliminate narrow and long connections and small protrusions in the binary image;
[0040] S52: Calculate the connected domains of the processed binary image obtained in step S51, and record each connected domain as a label class. The label classes are assigned label class numbers in sequence, and the grayscale values of the pixels contained in each label class are set as the label class number values. The specific steps are as follows:
[0041] S521, detect the first pixel of the entire image. If the grayscale value of the pixel is 255, it is a label class;
[0042] S522: Detect the first row and determine whether the grayscale value of each pixel is the same as that of the pixel in the previous row. If so, the pixel is assigned to the same label class as the pixel in the previous row. If not, a new label class is created when the grayscale value of the pixel is 255.
[0043] S523, check the first column and determine whether the grayscale value of each pixel is the same as that of the pixel in the previous row in the same column. If they are the same, the pixel is assigned to the same label class as the pixel in the previous row in the same column. If they are different, a new label class is created when the grayscale value of the pixel is 255;
[0044] S524, detect the remaining pixels, and compare the grayscale values of the pixels with the pixels in the previous column of the same row and the pixels in the previous row of the same column: if the grayscale values are the same as the pixels in the previous column of the same row, then the pixel points in the previous column of the same row are of the same label class; if the grayscale values are the same as the pixels in the previous row of the same column, then the pixel points in the previous row of the same column are of the same label class; if the grayscale values of the two pixels are different, a new label class is established when the grayscale value of the pixel point is 255; if the grayscale values of the two pixels are the same, then compare the label class numbers corresponding to the pixels in the previous column of the same row and the pixels in the previous row of the same column, the current pixel point is of the label class with the smaller label class number, and the label classes of the pixels in the previous column of the same row and the pixels in the previous row of the same column are merged into the class with the smaller label class number;
[0045] S53. Count the image areas corresponding to the label classes in step S52, change the grayscale values of all pixels in the two label classes with the largest areas to 255, and change the grayscale values of pixels in the remaining label classes to 0, and finally obtain the complete road surface area.
[0046] A lane area segmentation system, comprising:
[0047] The road image extraction module is used to collect road images and perform grayscale processing, then perform binarization processing on the grayscale images, extract and store the straight line information in the binarized images;
[0048] The road image screening and cutting module receives the line information stored by the road image extraction module and performs clustering processing. It then sorts the clustered lines according to the angle θ between the line and the x-axis. Finally, it extracts the first and last lines l1 and l2 from the sorted lines. The coordinates of the intersection of l1 and l2 with each row of the image are compared with the default range of the road image to obtain the range of each row of the grayscale road image. Pixels within the range are kept at their original grayscale values, and pixels outside the range are set to zero.
[0049] The lane segmentation module is used to calculate the grayscale histogram of the segmented image and find the peaks of the histogram except for the grayscale value of 0. It then searches for the troughs on both sides of the peak and sets the grayscale values corresponding to the troughs on both sides as thresholds. It uses a double threshold to perform binarization and segment the lane area. It then performs a morphological opening operation on the segmented lane area using digital image processing to disconnect narrow connections. It then performs connected domain detection and assigns labels to each detected connected domain. Finally, it retains the two connected domains with the largest areas, and the two output connected domains are the lane area.
[0050] An electronic device includes: a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor implements the above-mentioned lane area segmentation method when executing the computer program.
[0051] A storage medium stores a computer program, which, when read and executed, implements the above-mentioned lane area segmentation method.
[0052] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0053] (1) The present invention uses road image data obtained by a road monitoring camera and the Hough algorithm to extract straight lines in the road image, and uses the straight line information obtained from the Hough image to screen and cluster the straight lines. The straight line sorting problem on the road image is solved according to the angle of the straight line and the distance from the origin, thereby determining the edge straight lines on both sides of the road on the image, and using the edge straight lines and image threshold processing to delineate the road range, remove road interference information, help remove interfering objects, and delineate the road range.
[0054] (2) The present invention uses an image that retains the road range through threshold processing to obtain its histogram, and uses the characteristics of the histogram to find the optimal dual threshold for image segmentation, and uses dual threshold binarization to quickly and accurately segment the travel lane area.
[0055] (3) The present invention combines digital image processing methods to effectively eliminate the influence of ground objects, fill in blank areas and modify redundant parts of the segmented lane area, making the segmented lane area more complete. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 It is a schematic flow diagram of the method of the present invention;
[0057] Figure 2 It is the original data map of the road image;
[0058] Figure 3 is the road binary image;
[0059] Figure 4 This is the Hough line extraction result image;
[0060] Figure 5 is a schematic diagram of image cutting;
[0061] Figure 6 is the image cutting result graph;
[0062] Figure 7 is the grayscale histogram of the image after cutting;
[0063] Figure 8 This is the double-threshold binarization lane area segmentation result map;
[0064] Figure 9 This is the result of detecting the connected domain of the image and removing the middle dividing strip of the road. DETAILED DESCRIPTION
[0065] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.
[0066] The lane region segmentation method based on a road image according to an embodiment of the present invention includes:
[0067] Step (1) Road image straight line extraction. First, input a road image with a height of H and a width of W and perform grayscale processing. Second, set a single threshold t0 to binarize the grayscale road image to highlight the road line information. Finally, use the Hough algorithm to extract the straight lines in the image and store the straight line information.
[0068] Step (2) screens and sorts the extracted lines. First, cluster the lines obtained by the Hough algorithm in step (1) according to the number of road lines k, and remove interfering lines. Second, sort the clustered lines according to the angle θ between the line and the x-axis and the distance ρ from the origin. Finally, extract the first and last lines l1 and l2 from the sorted lines.
[0069] Step (3) Linear cutting of the road image. First, set the default range of each row of the grayscaled road image in step (1) to 0 to W; second, calculate the coordinate values of the intersection of the straight lines l1 and l2 obtained in step (2) with each row of the image; third, compare the default range with the range of the intersection coordinate values of l1 and l2 to obtain the range of each row; finally, set the pixels within the range to maintain the original grayscale value, and set the pixels outside the range to zero;
[0070] Step (4) Segmentation of the lane area. First, calculate the grayscale histogram of the image after cutting in step (3) and find the peaks of the histogram except for the grayscale value of 0. Second, find the valleys on both sides with the peak as the center and set the grayscale values corresponding to the valleys on both sides as thresholds. Finally, use double thresholds to perform binarization and segment the lane area.
[0071] In this embodiment, the step (1) specifically includes:
[0072] Step (101) inputs a road image with a width of W and a height of H and performs grayscale processing to obtain a grayscale road image.
[0073] Step (102) utilizes the characteristic of high brightness of road lines in the grayscale road image and uses histogram statistics to find the threshold value t0 for highlighting road lines. The grayscale road image obtained in step (101) is thresholded and binarized to obtain a road binary image. The terrain and lane areas outside the road lines are removed to highlight the road line information. The threshold binarization process is as follows:
[0074]
[0075] In this embodiment, t0=240, the binarization result is as follows Figure 3 .
[0076] Step (103) performs a Hough algorithm on the road binary image obtained in step (102) to extract straight lines in the image and stores the straight line information, which includes: the angle θ between the straight line and the x-axis, the distance ρ from the straight line to the origin, and the statistical brightness light of the straight line in the Hough image.
[0077] In this embodiment, the step (2) specifically includes:
[0078] Step (201) clusters the line information obtained in step (103) according to the number k of road lines in the road image to remove interfering lines. The clustering step is as follows: the lines are classified into k categories according to the angle range between the line and the x-axis, and the lines within different angle ranges are weighted averaged according to the brightness of the line in the Hough image. One line information is counted in each range, and a total of k line information is obtained.
[0079] In this embodiment, if Figure 3 It can be seen that k=8.
[0080] Step (202) sorts the k pieces of straight line information obtained in step (201): first, the angles θ between the straight lines and the x-axis in the straight line information are compared and sorted according to the size of θ; second, if the values of θ are the same, the distances ρ from the straight lines to the origin are compared; finally, the k pieces of straight line information are obtained, which are sorted in the order on the image.
[0081] Step (203) takes the first and last straight lines l1 and l2 from the straight line information sorted in step (202).
[0082] In this embodiment, the step (3) specifically includes:
[0083] Step (301) sets a default range for each row of the grayscale road image obtained in step (101), with the initial range being [0, W], where W is the width of the road image;
[0084] Step (302) is as follows Figure 5 , find the intersection pixels p1, p2 of the straight lines l1, l2 in step (203) and each row of pixels in the grayscale road image; step (303) compares p1, p2 with the default range [0, W], and determines whether p1, p2 are within [0, W] to determine the final range. The specific process is as follows:
[0085] If p1∈[0,W],p2∈[0,W], then the range is [p1,p2];
[0086] If p1∈[0,W], Then the range is [p1,W];
[0087] like p2∈[0,W], then the range is [0,p2];
[0088] like Then the range is [0,W];
[0089] Step (304) judges each row of pixels on the grayscale road image in turn. If the pixels on each row are within the set range, the original grayscale value is maintained. If they are outside the set range, the grayscale value is set to 0. The cutting result is as follows: Figure 6 .
[0090] In this embodiment, the step (4) specifically includes:
[0091] Step (401) counts the grayscale histogram of the road image after cutting in step (304). The grayscale histogram is shown in Figure 7 .
[0092] Step (402) finds the peak of the histogram in the grayscale histogram obtained in step (401), and the grayscale value corresponding to the peak is t max , t max Cannot be 0. In this embodiment, t max =101.
[0093] In step (403), a trough is searched on both sides with the peak obtained in step (402) as the center. The grayscale values corresponding to the troughs on both sides are t1 and t2 respectively. In this embodiment, t1=68 and t2=170.
[0094] In step (404), the image obtained in step (304) is binarized using t1 and t2 as double thresholds to obtain the lane area. The threshold binarization process is as follows:
[0095]
[0096] The result of threshold binarization is as follows Figure 8 .
[0097] In this embodiment, the step (4) specifically includes:
[0098] Step (501) performs mathematical morphological processing on the binary image obtained in step (404), performing an opening operation, i.e., first corroding and then dilating, to eliminate narrow and long connections and small protrusions;
[0099] Step (502) calculates the connected domains in the image obtained in step (501) and labels each connected domain, recording each as a label class. The label classes are assigned label class numbers in turn, and the grayscale values of the pixels contained in each label class are set as the label class number value. The specific steps are as follows:
[0100] Step (50201) detects the first pixel of the entire image. If the grayscale value of the pixel is 255, it is a label class;
[0101] Step (50202) detects the first row and determines whether the grayscale value of each pixel is the same as that of the pixel in the previous row. If so, the pixel is assigned the same label class as the pixel in the previous row. If not, a new label class is created when the grayscale value of the pixel is 255.
[0102] Step (50203) checks the first column and determines whether the grayscale value of each pixel is the same as that of the pixel in the previous row in the same column. If the grayscale value is the same, the pixel is assigned to the same label class as that of the pixel in the previous row in the same column. If the grayscale value is different, a new label class is created when the pixel grayscale value is 255.
[0103] Step (50204) detects the remaining pixels and compares the grayscale values of the pixels with those of the pixels in the previous column of the same row and the pixels in the previous row of the same column: if the grayscale values are the same as those of the pixels in the previous column of the same row, the pixels in the previous column of the same row are of the same label class; if the grayscale values are the same as those of the pixels in the previous row of the same column, the pixels in the previous row of the same column are of the same label class; if the grayscale values of the pixels are different from those of the two pixels, a new label class is established when the grayscale value of the pixel is 255; if the grayscale values of the pixels are the same as those of the two pixels, the label class numbers corresponding to the pixels in the previous column of the same row and the pixels in the previous row of the same column are compared, the current pixel belongs to the label class with the smaller label class number, and the label classes of the pixels in the previous column of the same row and the pixels in the previous row of the same column are merged into the class with the smaller label class number.
[0104] Step (503) counts the image area corresponding to each label class in step (502), and changes the grayscale values of all pixels in the two label classes with the largest area to 255, and changes the grayscale values of pixels in the remaining label classes to 0, and finally obtains the complete road surface area, such as Figure 9 .
[0105] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiment of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and literal translation scripting language JavaScript, etc.
[0106] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0107] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0108] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0109] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0110] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A lane area segmentation method based on road images, characterized in that: The following steps are involved: S1. Acquire a road image and perform grayscale processing. Set a single threshold t0 to binarize the grayscale road image. Use the Hough algorithm to extract straight lines in the binary image and store the straight line information. S2. Cluster the lines obtained in step S1 according to the number of road lines k, and remove interfering lines. Sort the clustered lines according to the angle θ between the line and the x-axis. If the angle θ between the lines and the x-axis is the same, sort them according to the distance ρ from the origin. Extract the first and last lines l1 and l2 from the sorted lines. S3. Setting a default range for each row of the grayscaled road image in step S1, wherein the default range is from 0 to the maximum width of the road; calculating the coordinate values of the intersections of the straight lines l1, l2 obtained in step S2 with each row of the image; comparing the default range with the range of the coordinate values of the intersections l1, l2 to obtain the range of each row of the grayscaled road image; pixels within the set range retain their original grayscale values, and pixels outside the range are set to zero; S4, counting the grayscale histogram of the image obtained after the cutting in step S3, and finding the peaks of the histogram except the grayscale value of 0; Find the troughs on both sides with the peak as the center, and set the grayscale values corresponding to the troughs on both sides as the threshold; Use double thresholds for binarization to segment the travel lane area; S5. Performing a morphological opening operation of digital image processing on the lane area image obtained by segmentation in step S4 to disconnect narrow connections; Detect the connected domains and assign labels to each detected connected domain; retain the two connected domains with the largest area, which are the lane areas of the road; Step S5 specifically includes the following steps: S51, performing mathematical morphological processing on the binary image obtained in step S4, and then performing an opening operation to eliminate narrow and long connections and small protrusions in the binary image; S52: Calculate the connected domains of the processed binary image obtained in step S51, and record each connected domain as a label class. The label classes are assigned label class numbers in sequence, and the grayscale values of the pixels contained in each label class are set as the label class number values. The specific steps are as follows: S521, detect the first pixel of the entire image. If the grayscale value of the pixel is 255, it is a label class; S522: Detect the first row and determine whether the grayscale value of each pixel is the same as that of the pixel in the previous row. If so, the pixel is assigned to the same label class as the pixel in the previous row. If not, a new label class is created when the grayscale value of the pixel is 255. S523, check the first column and determine whether the grayscale value of each pixel is the same as that of the pixel in the previous row in the same column. If they are the same, the pixel is assigned to the same label class as the pixel in the previous row in the same column. If they are different, a new label class is created when the grayscale value of the pixel is 255; S524, detect the remaining pixels, and compare the grayscale values of the pixels with the pixels in the previous column of the same row and the pixels in the previous row of the same column: if the grayscale values are the same as the pixels in the previous column of the same row, then the pixel points in the previous column of the same row are of the same label class; if the grayscale values are the same as the pixels in the previous row of the same column, then the pixel points in the previous row of the same column are of the same label class; if the grayscale values of the two pixels are different, a new label class is established when the grayscale value of the pixel point is 255; if the grayscale values of the two pixels are the same, then compare the label class numbers corresponding to the pixels in the previous column of the same row and the pixels in the previous row of the same column, the current pixel point is of the label class with the smaller label class number, and the label classes of the pixels in the previous column of the same row and the pixels in the previous row of the same column are merged into the class with the smaller label class number; S53. Count the image areas corresponding to the label classes in step S52, change the grayscale values of all pixels in the two label classes with the largest areas to 255, and change the grayscale values of pixels in the remaining label classes to 0, and finally obtain the complete road surface area.
2. The method for lane area segmentation based on road image according to claim 1, characterized in that: Step S1 specifically includes the following steps: S11, performing grayscale processing on an input road image with a width of W and a height of H to obtain a grayscale road image; S12. Utilizing the high brightness of road lines in the grayscale road image, a threshold value t0 for highlighting road lines is determined through histogram statistics. The grayscale road image obtained in step S11 is subjected to threshold binarization to obtain a road binary image. The image removes ground objects and lane areas outside the road lines, highlighting the road line information. The threshold binarization processing formula is expressed as follows: Where p represents the grayscale value of a single pixel in the image after threshold binarization, p represents the grayscale value of a single pixel in the image before threshold binarization, and t0 represents the threshold used for threshold binarization. S13. Perform the Hough algorithm on the binary road image obtained in step S12 to extract straight lines in the image, and store the straight line information, wherein the straight line information includes: the angle θ between the straight line and the x-axis, the distance ρ from the straight line to the origin, and the statistical brightness light of the straight line in the Hough image.
3. The method for lane segmentation based on road images according to claim 1, characterized in that: Step S2 specifically includes the following steps: S21, clustering the line information obtained in step S1 according to the number k of road lines in the road image to remove interfering lines; the clustering step is as follows: classifying the lines into k categories according to the angle range between the line and the x-axis, then performing weighted averaging of the lines within different angle ranges according to the brightness light of the line in the Hough image, and counting one line information in each range, obtaining a total of k line information; S22. Sort the k pieces of line information obtained in step S21: first, compare the angles θ between the lines and the x-axis in the line information, and sort them by the magnitude of θ; if the values of θ are the same, sort them by the distance ρ from the origin; and obtain the k pieces of line information sorted in the order of the image. S23 , taking the first and last straight lines l1 and l2 from the straight line information sorted in step S22 .
4. The method for lane area segmentation based on road image according to claim 1, characterized in that: Step S3 specifically includes the following steps: S31, setting a default range for each row of the grayscale road image obtained in step S1, with the initial range being [0, W], where W is the maximum width of the road image; S32, finding the intersection pixels p1, p2 of the straight lines l1, l2 obtained in step S2 and each row of pixels in the grayscale road image; S33. Compare p1 and p2 with the default range [0, W] to determine whether p1 and p2 are within [0, W]. Determine the final range based on the determination result. The determination process is as follows: If p1∈[0,W],p2∈[0,W], then the range is [p1,p2]; If p1∈[0,W], Then the range is [p1,W]; like p2∈[0,W], then the range is [0,p2]; like Then the range is [0,W]; S34. Each row of pixels on the grayscale road image is judged in turn. If the pixels on each row are within the set range, the original grayscale value is maintained; if they are outside the set range, the grayscale value is set to 0.
5. The method for lane area segmentation based on road image according to claim 1, characterized in that: Step S4 specifically includes the following steps: S41, calculating a grayscale histogram of the road image after cutting in step S3; S42, collecting the peak of the histogram in the grayscale histogram obtained in step S41, the grayscale value corresponding to the peak is t max , t max ≠0; S43, taking the peak obtained in step S42 as the center, searching for a valley on each side of the peak, where the grayscale values corresponding to the valleys on both sides are t1 and t2 respectively; S44, using t1 and t2 as double thresholds, perform double threshold binarization on the image obtained in step (304) to obtain the lane area. The threshold binarization processing formula is expressed as follows: Where p represents the grayscale value of a single pixel in the image after threshold binarization.
6. A lane area segmentation system based on the lane area segmentation method according to any one of claims 1 to 5, characterized in that: include: The road image extraction module is used to collect road images and perform grayscale processing, then perform binarization processing on the grayscale images, extract and store the straight line information in the binarized images; The road image screening and cutting module receives the line information stored by the road image extraction module and performs clustering processing. It then sorts the clustered lines according to the angle θ between the line and the x-axis. Finally, it extracts the first and last lines l1 and l2 from the sorted lines. The coordinates of the intersection of l1 and l2 with each row of the image are compared with the default range of the road image to obtain the range of each row of the grayscale road image. Pixels within the range are kept at their original grayscale values, and pixels outside the range are set to zero. The lane area segmentation module is used to calculate the grayscale histogram of the segmented image and find the peaks of the histogram except the grayscale value of 0; Find the troughs on both sides with the peak as the center, and set the grayscale values corresponding to the troughs on both sides as the threshold; A double threshold is used for binarization to segment the travel lane area. A morphological opening operation is then performed on the segmented travel lane area to disconnect narrow connections. Connected domain detection is then performed, and each detected connected domain is assigned a label. Finally, the two connected domains with the largest area are retained, and the output two connected domains are the travel lane area.
7. An electronic device, characterized in that: The method is characterized in that it comprises: a memory and a processor, the memory stores a computer program executable by the processor, and the processor implements the lane area segmentation method according to any one of claims 1 to 5 when executing the computer program.
8. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is read and executed, the lane area segmentation method according to any one of claims 1 to 5 is implemented.