A kind of orchard mcintosh image fruit branch and leaf area obtaining method
Technical field
The invention belongs to technical field of image processing, relate to a kind of Apple image fruit branch and leaf area obtaining method, especially
It it is the fruit branch and leaf region acquisition of orchard mcintosh image.
Background technology
China is a large agricultural country, and fruit industry is to rank the third-largest industry after grain, vegetable in plant husbandry.Herba Marsileae Quadrifoliae
Fruit is one of big fruit in the world four.In recent years, the apple industry of China is particularly rapid, and cultivated area and yield quickly expand
, already formed the advantage of scale, and gone from strength to strength.But in apple cultivation production process, except spray medicine is in addition to semi-mechanization, really
Real harvesting is as important step, and the most still manual work, labor intensity is big, elapsed time is long, and has certain
Dangerous.On the other hand, a large amount of Farmer Labors in City of China is worked, and rural laborer is fewer and feweri;Cost of labor is more and more higher.This
Outward, along with China's industrialization, the deep development of urbanization, peasant is more and more urgent to the demand of agricultural machinery working, agricultural production pair
The dependence of agricultural machinery application is more and more obvious.No. 1 file of central authorities in recent years highlights again propelling agricultural technology renovation, accelerates agriculture
Industry Mechanization Development.In view of the above circumstances, apple picking robot relation technological researching is carried out, it is achieved the machinery of Apple is certainly
Dynamic intellectuality is plucked has Great significance.
Apple picking robot based on machine vision becomes the study hotspot of domestic and international agricultural engineering field, its work
Top priority is the acquisition of image target area.And target area information, particularly fruit region acquired in current existing method
Information is the most complete, affects the accurate rate of follow-up fruit identification, it is impossible to effectively avoidance affects the success rate of picking fruit.
Summary of the invention
In order to solve the problems referred to above, the present invention proposes a kind of mcintosh image fruit branch and leaf region, orchard acquisition side
Method so that apple picking robot obtains the most complete fruit, leaves, branch image-region at image processing stage, for rear
Continuous fruit accurately identifies, effective avoidance picking fruit lays the foundation, and promotes the practicalization of apple picking robot.Realize this
The technical scheme of invention includes following flow process:
A kind of orchard mcintosh image fruit branch and leaf area obtaining method, comprises the following steps:
(1) view-based access control model sensor acquisition RGB image;
(2) do R-G computing based on RGB triple channel image, obtain color difference image;
(3) fruit image is obtained based on R-G color difference image;
(4) the RGB original image in (1) is deducted the fruit image in (3), obtain subtraction image;
(5) leaves image is obtained based on subtraction image;
(6) the R-G color difference image in (2) is carried out dynamic threshold segmentation, obtain dynamic threshold segmentation image;
(7) by dynamic threshold segmentation image and the fruit image addition in (3), obtain and be added fruit image;
(8) RGB image described in (1) is deducted addition fruit image and leaves image, obtain subtraction image;
(9) branch chart picture is obtained based on subtraction image.
Further preferably scheme, described step (3) obtains implementing of fruit image and comprises the steps:
(3-1) based on structural element, R-G color difference image is carried out etching operation;
(3-2) the R-G color difference image corroded is carried out holes filling operation;
(3-3) in the R-G color difference image crossed by holes filling, the pixel less than gray value threshold value is set to 0, then to image
In connected region be marked, add up sum, by the removing of small regions less than sum of all pixels threshold value;
(3-4) based on structural element, the R-G color difference image after removing of small regions is carried out expansive working;
(3-5) based on structural element, the R-G color difference image after expanding is carried out opening operation operation;
(3-6) based on R-G color difference image gray threshold after opening operation, RGB original image is split, obtain fruit image.
Further preferably scheme, expansive working described in etching operation described in (3-1), (3-4) all uses radius to be 5
Disc-shaped structure element;(3-5) the disc-shaped structure element that the operation of opening operation described in uses radius to be 10.
Further preferably scheme, cavity padding described in (3-2) uses unrestrained water filling algorithm;(3-3) described in right
Connected region in image is marked employing 8 neighbourhood signatures's methods.
Further preferably scheme, described in (3-3), gray value threshold value is set to 20, and described in (3-3), sum of all pixels threshold value sets
Being 2000, described in (3-6), gray threshold is set to 0.
Further preferably scheme, described step (5) obtains implementing of leaves image and comprises the steps:
(5-1) subtraction image is done 2G-R-B computing, obtain color difference image;
(5-2) connected region in 2G-R-B color difference image is marked, adds up sum, will be less than sum of all pixels threshold value
Removing of small regions;
(5-3) based on 2G-R-B color difference image gray threshold after removing of small regions, RGB original image is split, obtain tree
Leaf image.
Further preferably scheme, is marked employing 8 adjacent to the connected region in 2G-R-B color difference image described in (5-2)
Field mark method, described in (5-2), sum of all pixels threshold value is set to 500, and described in (5-3), gray threshold is set to 0.
Further preferably scheme, described step (9) obtains implementing of branch chart picture and comprises the steps:
(9-1) subtraction image is done again R-G computing, obtain color difference image;
(9-2) based on structural element, R-G color difference image is carried out opening operation operation;
(9-3) connected region in R-G color difference image after opening operation is marked, adds up sum, will be total less than pixel
The removing of small regions of number threshold value;
(9-4) based on R-G color difference image gray threshold after removing of small regions, RGB original image is split, obtain branch
Image.
Further preferably scheme, the disc-shaped structure element that the operation of opening operation described in (9-2) uses radius to be 2, (9-3)
Described in the connected region in R-G color difference image after opening operation is marked employing 8 neighbourhood signatures's methods,.
Further preferably scheme, described in (9-3), sum of all pixels threshold value is set to 800, and described in (9-4), gray threshold is set to
0。
The invention has the beneficial effects as follows:
(1) for apple picking robot, this inventive method can obtain orchard mcintosh image fruit branch and leaf
Region, plucks for follow-up fruit identification and lays the foundation.
(2) particularly to pluck objective fruit region relatively previous methods the most complete, for follow-up in the acquisition in fruit branch and leaf region
Fruit accurately identifies, effective avoidance is successfully plucked and provided safeguard.
(3) R-G color difference image is carried out etching operation, eliminate the unnecessary branch in color difference image.
(4) use unrestrained water filling algorithm that the R-G color difference image corroded is carried out holes filling operation, eliminate Apples
Real afterbody calyx because distinguishing the hole of bigger formation with Fructus Mali pumilae body color.
(5) 8 neighbourhood signatures's methods are used, to eliminate the noise of image or block of making an uproar.
(6) in order to ensure the integrity of follow-up fruit image to greatest extent, can to the R-G color difference image after removing of small regions
Against carrying out expansive working.
(7) the R-G color difference image after expanding is carried out opening operation operation, slacken the non-targeted pair at edge, target area
As.
Accompanying drawing explanation
Fig. 1 is that orchard mcintosh image object obtains main-process stream;
Fig. 2 is fruit image capture flow;
Fig. 3 is leaves image capture flow;
Fig. 4 is branch image capture flow;
Fig. 5 is that mcintosh image fruit branch and leaf region, orchard obtains design sketch.
Detailed description of the invention
The invention will be further described with specific embodiment below in conjunction with the accompanying drawings.
As it is shown in figure 1, the orchard mcintosh image fruit branch and leaf area obtaining method that the present invention proposes includes walking as follows
Rapid:
(1) the collection view-based access control model sensor of RGB image, as the area information of subsequent extracted destination object, gathers figure
As such as Fig. 5 (a).
(2) under RGB color, with R-G color factor as color characteristic, mcintosh fruit and background have the most aobvious
The difference write, is done R-G computing by this based on gathering RGB triple channel image in step (1), obtains color difference image, such as Fig. 5 (b);
From Fig. 5 (b) it can be seen that only leave fruit and branch image, other backgrounds block up not in black.
(3) fruit image is obtained based on R-G color difference image, as in figure 2 it is shown, comprise the following steps:
1) for the unnecessary branch in color difference eliminating image, it is primarily based on disc-shaped structure element that radius is 5 to R-G color
Difference image carries out etching operation, such as Fig. 5 (c);From Fig. 5 (c) it can be seen that image major part branch be eliminated.
2) from Fig. 5 (c), the afterbody calyx of Apple defines more greatly hole because distinguishing with Fructus Mali pumilae body color,
Imperfect if not being acted upon causing follow-up fruit region to lack, the unrestrained water filling algorithm R-to corroding is used for this
G color difference image carries out holes filling operation, such as Fig. 5 (d);From Fig. 5 (d) it can be seen that hole is filled.
3) image that holes filling is crossed yet suffers from the noise beyond fruit or block of making an uproar, for eliminating these noises or block of making an uproar,
First in the R-G color difference image crossed by holes filling, the gray value pixel less than 20 is set to 0, then by 8 neighbourhood signatures's methods pair
Connected region in image is marked, adds up sum, by the sum of all pixels removing of small regions less than 2000, such as Fig. 5 (e);From
Fig. 5 (e) is it can be seen that noise or block of making an uproar are basically eliminated.
4) in order to ensure the integrity of follow-up fruit image to greatest extent, relative to 2) etching operation of step, based on half
Footpath be 5 disc-shaped structure element carry out expansive working, such as Fig. 5 (f) to the R-G color difference image after removing of small regions is reversible.
5) in the R-G color difference image after expanding, edge, target area yet suffers from non-targeted object, for this based on radius is
The disc-shaped structure element of 10, carries out opening operation operation, to slacken the non-of edge, target area to the R-G color difference image after expanding
Destination object, such as Fig. 5 (g).
6) for threshold value, RGB original image is split with R-G color difference image gray value 0 after opening operation, obtains fruit image,
Such as Fig. 5 (h).
(4) RGB original image deducts fruit image, obtains subtraction image, such as Fig. 5 (i).
(5) leaves image is obtained based on subtraction image, as it is shown on figure 3, comprise the following steps:
1) with 2G-R-B color factor as color characteristic, green tree leaf and background have more significantly difference, for this to phase
Subtract image and do 2G-R-B computing, obtain color difference image, such as Fig. 5 (j);From Fig. 5 (j) it can be seen that image major part be greenery,
Other backgrounds block up not in black.
2) it is noise unnecessary in color difference eliminating image or block of making an uproar, by 8 neighbourhood signatures's methods in 2G-R-B color difference image
Connected region be marked, add up sum, by the sum of all pixels removing of small regions less than 500, such as Fig. 5 (k), can from Fig. 5 (k)
To find out, in image, noise or block of making an uproar eliminate.
3) for threshold value, RGB original image is split with 2G-R-B color difference image gray value 0 after removing of small regions, obtain tree
Leaf image, such as Fig. 5 (l).
(6) not comprise remote fruitlet (distant from vision sensor, in image for the fruit image owing to being obtained by (3)
Fruit just seem smaller, picking robot based on machine vision only can pluck the fruit close to vision sensor, i.e.
Bigger fruit), and follow-up RGB original image needs to deduct all of fruit image, dynamic based on (2) R-G color difference image for this
Threshold segmentation, obtains dynamic threshold segmentation fruit image.
(7), in the fruit image obtained by dynamic threshold segmentation, fruit region likely lacks, for this again by dynamic threshold
It is worth segmentation image and (3) fruit image addition, obtains and be added image, to make up the dynamic threshold segmentation acquisition corresponding fruit of fruit image
The disappearance in real region.
(8) RGB original image deducts addition image and leaves image, obtains subtraction image, such as Fig. 5 (m).
(9) obtain branch chart picture based on subtraction image, as shown in Figure 4, comprise the following steps:
1) with R-G color factor as color characteristic, branch and background have more significantly difference, again do subtraction image
R-G computing, obtains color difference image, such as Fig. 5 (n);From Fig. 5 (n) it can be seen that image major part be branch, other backgrounds block up
Not in black.
2) in order to eliminate the unnecessary noise in R-G color difference image or block of making an uproar, it is primarily based on the disc-shaped structure unit that radius is 2
Element carries out opening operation operation to R-G color difference image, such as Fig. 5 (o);From Fig. 5 (o) it can be seen that image some unnecessary noises or
Block of making an uproar is eliminated.
3) connected region in R-G color difference image after opening operation is marked by 8 neighbourhood signatures's methods, adds up total again
Number, by the removing of small regions less than sum of all pixels threshold value 800, such as Fig. 5 (p);From Fig. 5 (p) it can be seen that image noise or block of making an uproar
It is eliminated completely, although some little branches eliminate the most in the lump, but picking robot avoidance is plucked not by these little branches
Impact.
4) for threshold value, RGB original image is split with R-G color difference image gray value 0 after removing of small regions, obtain branch
Image, such as Fig. 5 (q).
Embodiment of above is merely to illustrate technical scheme, and not limitation of the present invention, relevant technology
The those of ordinary skill in field, without departing from the spirit and scope of the present invention, it is also possible to make a variety of changes, therefore
The technical scheme of all equivalents falls within the category of present invention protection.