Leading line extraction method
Technical field
The invention belongs to technical field of image processing, relate in particular to a kind of leading line extraction method.
Background technology
In recent years, has the development of supermatic agricultural machinery and more intelligentized agricultural robot rapidly, its navigation parts are because effect is crucial, technical difficulty is larger, it is the focus of research always, the navigation parts divide by kind the modes such as GPS navigation, inertial navigation and machine vision navigation, wherein the latter, has obtained more widely and has used along with the fast development of electronic technology owing to have the advantages such as the acquisition of signal scope is wide, information completely.
Use machine vision to carry out robotization agricultural machinery or agricultural robot independent navigation, it is early stage to start from the eighties in 20th century, and relatively cheap reliable ccd image sensor began to occur at that time.Along with the continuous progress of the correlation techniques such as computing machine, microelectronics, some complicated images are processed and analytical algorithm can realize smoothly, so that the research of navigation of agricultural robot technology develops rapidly.
In the natural scene of farmland complexity, image segmentation often becomes very difficult because of the puzzlement of the noises such as illumination, shade, can't obtain comparatively satisfied, stable image segmentation.Period crops early in the farmland, plant is relatively short and small, and is neat by the row plantation, row with go between substantially parallel.Simultaneously, it is green that crops generally are, and crop row presents rectilinear form or small curve curve on the whole, and crop row is continuous, and the navigation characteristic that detects can not undergone mutation every interior in the short time, and people usually extract crop row in the image as leading line.
The researchist has proposed various crop row straight line extracting method both at home and abroad, and least square method and Hough transformation (Hough Transform) are detection of straight lines two kinds of methods commonly used.Although least square method can the rapid extraction straight line, responsive to picture noise, when image in the more situation of weeds, can not extract exactly leading line, and, in the time of the multirow crop, be difficult to directly use least square method and carry out fitting a straight line.The Hough conversion is based on the duality principle of point-line, although the algorithm robustness is better, maximum shortcoming is exactly that the time complexity of algorithm is larger, is difficult to the higher farmland operation environment of requirement of real time.Therefore, seeking a kind of effective line detection algorithm and obtain the datum line that navigates, is the key that realizes vision guided navigation.
Summary of the invention
The technical matters that (one) will solve
The purpose of this invention is to provide a kind of leading line rapid extracting method, solve leading line and extract the poor and unsettled problem of algorithm of real-time.
(2) technical scheme
In order to address the above problem, the present invention proposes a kind of leading line extraction method in conjunction with the method for unique point number in least square method and the calculating specific region.Particularly, the invention provides a kind of leading line extraction method, comprise step: S1, gather the crop map picture, make that a certain row crop is positioned at the image centre position in the image, and so that this row crop certain limit is arranged in image; S2, try to achieve bianry image behind the image segmentation according to the image that collects; S3, try to achieve the unique point image according to described bianry image; S4, the Partial Feature dot image is carried out least square fitting, obtain first fitting a straight line; S5, according to described first fitting a straight line, generate two parallel lines, consist of a bar-shaped zone, the feature in the zoning is counted; S6, adjust bar-shaped zone within the specific limits, and the feature of calculating in the bar-shaped zone after adjusting counts, the feature corresponding straight line of maximum bar-shaped zones of counting is required leading line.
Preferably, certain limit is more than 3 meters among the described step S1.
Preferably, described step S2 comprises: the described image that collects is equally divided into left, center, right three parts in the horizontal direction, the pixel value of left and right half is converted to 0, for center section, carry out following conversion: with described center section image in rgb color space, G passage pixel value and R passage pixel value are subtracted each other, obtain each pixel G-R value of chromatism, if certain pixel G-R<0, its gray-scale value is made as 255, be expressed as white, otherwise gray-scale value is made as 0, is expressed as black.
Preferably, described step S3 comprises: bianry image is equally divided into left, center, right three parts, in described bianry image mid range, in the horizontal direction image is lined by line scan, when for the first time to scan gray-scale value be 255 pixel, think that namely it is an end points of certain white line segment, continue scanning, when to run into next gray-scale value be 0 pixel, its previous gray-scale value is another end points that 255 pixel is this white line segment, according to two end points, obtain line segment length, if line segment length less than 10 pixels, is converted to 0 with all pixel values on the line segment, if line segment length is more than or equal to 10 pixels, it is constant that pixel in the middle of this line segment is remained 255 gray-scale values, and rest of pixels is converted to 0, according to this mode, remaining white line segment in the image is carried out identical conversion, obtain comprising the unique point image of series of features point.
Preferably, the described direction that image is lined by line scan is for from left to right.
Preferably, described step S4 comprises: described unique point image is equally divided into up and down two parts in vertical direction, the unique point in the latter half image is carried out least square fitting, obtain first fitting a straight line.
Preferably, described step S5 comprises: take the slope of described first fitting a straight line as slope, the crop row width that deducts half take the intercept of first fitting a straight line is as intercept, obtain straight line, take the slope of described first fitting a straight line as slope, the crop row width that adds half take the intercept of first fitting a straight line obtains other straight line as intercept, and described two straight lines have formed a bar-shaped zone in image.
Preferably, described step S6 comprises: slope range for ± 0.1, the intercept scope is in ± 10 the scope, adjusts two straight lines that consist of bar-shaped zone, calculate each feature of adjusting in the bar-shaped zone that consists of and count.
Preferably, described leading line extraction method is leading line rapid extracting method between corn field.
(3) beneficial effect
Leading line extraction method provided by the invention can improve extraction rate and the reliability of leading line preferably, has the advantages such as simple, reliable, that real-time is good.
Description of drawings
Further describe the present invention with reference to the accompanying drawings and in conjunction with example.Wherein:
Fig. 1 is the leading line extraction method process flow diagram according to the embodiment of the invention;
Fig. 2 is the image synoptic diagram that collects according to the embodiment of the invention;
Fig. 3 is the synoptic diagram of the bianry image that generates behind the image segmentation according to the embodiment of the invention;
Fig. 4 is the synoptic diagram according to the unique point image of the embodiment of the invention;
Fig. 5 is the synoptic diagram according to the first fitting a straight line of the embodiment of the invention;
Fig. 6 is the synoptic diagram that extracts according to the bar-shaped zone leading line of the embodiment of the invention.
Embodiment
Below in conjunction with drawings and Examples, the specific embodiment of the present invention is described in further detail.Following examples are used for explanation the present invention, but are not used for limiting the scope of the invention.
Embodiments of the invention are selected to look like as example take corn map, but the invention is not restricted to corn, can also be other various crops.The corn field leading line extraction method that present embodiment provides mainly is under field conditions (factors), realizes the rapid extraction to the corn field leading line.
Fig. 1 is the leading line extraction method process flow diagram according to the embodiment of the invention, and the method comprising the steps of:
S1, gather the crop map picture, make that a certain row crop is positioned at the image centre position in the image, and guarantee that this row crop certain limit (for example more than 3 meters) is arranged in image;
As shown in Figure 1, by adjusting height and the angle of camera, make that a certain row crop is positioned at the image centre position in the image, and guarantee that the corn in the image reaches more than 3 meters in actual field.
S2, try to achieve bianry image behind the image segmentation according to the described image that collects;
Fig. 3 is that the embodiment of the invention is carried out the bianry image that generates behind the image segmentation by the image that collects among Fig. 2, this step can be specially: the described image that collects is equally divided into left, center, right three parts in the horizontal direction, pixel value to left and right half is converted to 0, for center section, carry out following conversion: the image that generally collects all is in rgb color space, corresponding one group of RGB(is red for each pixel in the described image that collects, green, blue) value, with described center section image in rgb color space, G passage pixel value and R passage pixel value are subtracted each other, namely utilize the G-R operator to cut apart, obtain each pixel G-R value of chromatism, if certain pixel G-R<0, be 255(white with its gray-scale value), otherwise gray-scale value is 0(black).
S3, try to achieve the unique point image according to described bianry image;
Bianry image shown in Fig. 3, white portion (gray-scale value is 255) is corn, black part (gray-scale value is 0) is background, white portion shows as the line segment that is uneven in length in every delegation, the mid point that extracts all white line segments is unique point, concrete grammar is: bianry image is equally divided into left, center, right three parts, in described bianry image mid range, in the horizontal direction to line by line from left to right scanning of image, when for the first time to scan gray-scale value be 255 pixel, think that namely it is an end points of certain white line segment, continue scanning to the right, when to run into next gray-scale value be 0 pixel, its previous gray-scale value is another end points that 255 pixel is this white line segment, according to two end points, obtains line segment length, if line segment length less than 10 pixels, is converted to 0 with all pixel values on the line segment; If line segment length is more than or equal to 10 pixels, it is constant that the pixel in the middle of this line segment is remained 255 gray-scale values, and rest of pixels is converted to 0; The like, remaining white line segment in the image is carried out identical conversion, obtain comprising the unique point image of series of features point, as shown in Figure 4.
S4, the Partial Feature dot image is carried out least square fitting, obtain first fitting a straight line;
This step specifically can comprise: the unique point image is equally divided into upper and lower two parts in vertical direction, the unique point of the latter half from crop, can directly carry out least square fitting.Utilize least square method that the unique point of the latter half is carried out fitting a straight line, obtain the first fitting a straight line among Fig. 5.
S5, according to described first fitting a straight line, generate two parallel lines, consist of a bar-shaped zone, the feature in the zoning is counted;
The capable width in image of corn broadens from top to bottom gradually, take the width at image middle part as the crop row width.The slope of first fitting a straight line is as slope in described Fig. 5, and the crop row width that deducts half take the intercept of first fitting a straight line obtains straight line (such as the left side straight line among Fig. 5) as intercept; Take the slope of described first fitting a straight line as slope, the crop row width that adds half take the intercept of first fitting a straight line is as intercept, obtain other straight line (such as the right side straight line among Fig. 5), described two straight lines have formed a bar-shaped zone (such as the zone between the left side among Fig. 5 and the right side straight line) in image.
S6, adjust bar-shaped zone within the specific limits, the feature of calculating successively in the bar-shaped zone after adjusting is counted, and the feature corresponding straight line of maximum bar-shaped zones of counting is required leading line.
Adjust within the specific limits slope and the intercept of two straight lines of described formation bar-shaped zone, for example, slope range is ± 0.1, the intercept scope is ± 10, corresponding bar-shaped zone can change thereupon, calculate respectively after each the adjustment feature in the bar-shaped zone and count, when feature is counted maximum, with two straight line parallels that consist of bar-shaped zone, be in the middle straight line (such as the middle straight line among Fig. 6) of bar-shaped zone, be required leading line.
Description of the invention provides for example with for the purpose of describing, and is not exhaustively or limit the invention to disclosed form.Many modifications and variations are obvious for the ordinary skill in the art.Selecting and describing embodiment is for better explanation principle of the present invention and practical application, thereby and makes those of ordinary skill in the art can understand the various embodiment with various modifications that the present invention's design is suitable for special-purpose.