A kind of orchard mcintosh image fruit branches and leaves area obtaining method
Technical field
The invention belongs to technical field of image processing, are related to a kind of Apple image fruit branches and leaves area obtaining method, especially
It is the fruit branches and leaves region acquisition of orchard mcintosh image.
Background technology
China is a large agricultural country, and fruit industry is the third-largest industry ranked in planting industry after grain, vegetables.Apple
Fruit is one of four big fruit of the world.In recent years, the apple industry in China is particularly rapid, and cultivated area and yield quickly expand
, the advantage of scale is formed already, and is being gone from strength to strength.But in apple cultivation production process, in addition to spraying as semi-mechanization, fruit
Picking is as important link in fact, and substantially still handwork at present, labor intensity is big, elapsed time is long, and has centainly
It is dangerous.On the other hand, a large amount of Farmer Labors in City in China are worked, and rural laborer is fewer and fewer;Cost of labor is higher and higher.This
Outside, as China industrializes, the deep development of urbanization, demand of the peasant to agricultural machinery working is more and more urgent, agricultural production pair
The dependence of agricultural machinery application is more and more apparent.The file of center 1 in recent years highlights propulsion agricultural technology renovation again, accelerates agriculture
Industry Mechanization Development.In view of the above circumstances, carry out apple picking robot relation technological researching, realize the machinery of Apple certainly
Dynamic intelligent picking has Great significance.
Apple picking robot based on machine vision becomes the research hotspot of domestic and international agricultural engineering field, work
Top priority is the acquisition of image target area.And target area information, particularly fruit region acquired in current existing method
Information is not complete enough, influences the accurate rate of follow-up fruit identification, it is impossible to which effective avoidance influences the success rate of picking fruit.
Invention content
To solve the above-mentioned problems, the present invention proposes a kind of orchard mcintosh image fruit branches and leaves region acquisition side
Method so that apple picking robot obtains more complete fruit, leaf, branch image-region in image processing stage, after being
Continuous fruit accurately identifies, effective avoidance picking fruit lays the foundation, and pushes the practicalization of apple picking robot.Realize this
The technical solution of invention includes following flow:
A kind of orchard mcintosh image fruit branches and leaves area obtaining method, includes the following steps:
(1) view-based access control model sensor acquisition RGB image;
(2) R-G operations are done based on RGB triple channel images, obtains color difference image;
(3) fruit image is obtained based on R-G color difference images;
(4) by the fruit image in the RGB artworks image subtraction (3) in (1), subtraction image is obtained;
(5) leaf image is obtained based on subtraction image;
(6) dynamic threshold segmentation is carried out to the R-G color difference images in (2), obtains dynamic threshold segmentation image;
(7) it by the fruit image addition in dynamic threshold segmentation image and (3), obtains and is added fruit image;
(8) RGB image described in (1) is subtracted and is added fruit image and leaf image, obtain subtraction image;
(9) branch image is obtained based on subtraction image.
Further preferred scheme, the specific implementation that the step (3) obtains fruit image include the following steps:
(3-1) carries out etching operation based on structural element to R-G color difference images;
(3-2) carries out holes filling operation to the R-G color difference images corroded;
The pixel for being less than gray value threshold value in R-G color difference images that holes filling is crossed is set to 0 by (3-3), then to image
In connected region be marked, count sum, will be less than the removing of small regions of sum of all pixels threshold value;
(3-4) carries out expansive working based on structural element to the R-G color difference images after removing of small regions;
(3-5) carries out opening operation operation based on structural element to the R-G color difference images after expansion;
(3-6) is split RGB original images based on R-G color difference images gray threshold after opening operation, obtains fruit image.
Further preferred scheme, etching operation described in (3-1), expansive working described in (3-4) use radius as 5
Disc-shaped structure element;Opening operation described in (3-5) operation use radius for 10 disc-shaped structure element.
Further preferred scheme, empty padding is using unrestrained water filling algorithm described in (3-2);It is right described in (3-3)
Connected region in image is marked using 8 neighbourhood signatures' methods.
Further preferred scheme, gray value threshold value described in (3-3) are set as 20, and sum of all pixels threshold value described in (3-3) is set
It is 2000, gray threshold is set as 0 described in (3-6).
Further preferred scheme, the specific implementation that the step (5) obtains leaf image include the following steps:
(5-1) does subtraction image 2G-R-B operations, obtains color difference image;
(5-2) is marked the connected region in 2G-R-B color difference images, counts sum, will be less than sum of all pixels threshold value
Removing of small regions;
(5-3) is split RGB original images based on 2G-R-B color difference images gray threshold after removing of small regions, obtains tree
Leaf image.
Further preferred scheme is marked the connected region in 2G-R-B color difference images described in (5-2) using 8 neighbours
Field mark method, sum of all pixels threshold value described in (5-2) are set as 500, and gray threshold is set as 0 described in (5-3).
Further preferred scheme, the specific implementation that the step (9) obtains branch image include the following steps:
(9-1) does subtraction image R-G operations again, obtains color difference image;
(9-2) carries out opening operation operation based on structural element to R-G color difference images;
(9-3) is marked the connected region in R-G color difference images after opening operation, counts sum, and it is total will to be less than pixel
The removing of small regions of number threshold value;
(9-4) is split RGB original images based on R-G color difference images gray threshold after removing of small regions, obtains branch
Image.
Further preferred scheme, the operation of opening operation described in (9-2) use radius as 2 disc-shaped structure element, (9-3)
Described in the connected region in R-G color difference images after opening operation is marked using 8 neighbourhood signatures' methods,.
Further preferred scheme, sum of all pixels threshold value described in (9-3) are set as 800, and gray threshold is set as described in (9-4)
0。
The beneficial effects of the invention are as follows:
(1) for apple picking robot, which can obtain orchard mcintosh image fruit branches and leaves
Region lays the foundation for the identification picking of follow-up fruit.
(2) it is more complete compared with previous methods particularly to pick objective fruit region for the acquisition in fruit branches and leaves region, is follow-up
Fruit accurately identifies, and effective avoidance, which is successfully picked, to provide safeguard.
(3) etching operation is carried out to R-G color difference images, eliminates the extra branch in color difference image.
(4) holes filling operation is carried out to the R-G color difference images corroded using unrestrained water filling algorithm, eliminates Apples
Hole of the real tail portion calyx because distinguishing larger formation with apple body color.
(5) using 8 neighbourhood signatures' methods, to eliminate the noise of image or block of making an uproar.
It (6), can to the R-G color difference images after removing of small regions in order to ensure the integrality of follow-up fruit image to greatest extent
It is inverse to carry out expansive working.
(7) opening operation operation is carried out to the R-G color difference images after expansion, has slackened the non-targeted right of target area edge
As.
Description of the drawings
Fig. 1 obtains main-process stream for orchard mcintosh image object;
Fig. 2 is fruit image capture flow;
Fig. 3 is leaf image capture flow;
Fig. 4 is branch image capture flow;
Fig. 5 obtains design sketch for orchard mcintosh image fruit branches and leaves region.
Specific embodiment
The invention will be further described in the following with reference to the drawings and specific embodiments.
As shown in Figure 1, orchard mcintosh image fruit branches and leaves area obtaining method proposed by the present invention includes following step
Suddenly:
(1) the acquisition view-based access control model sensor of RGB image, the area information as subsequent extracted target object, acquisition figure
As such as Fig. 5 (a).
(2) under RGB color, using R-G color factors as color characteristic, mcintosh fruit has more aobvious with background
The difference of work does R-G operations based on the middle RGB triple channel images that acquire of step (1) thus, color difference image is obtained, such as Fig. 5 (b);
From Fig. 5 (b) as can be seen that only there are fruit and branch in image, other backgrounds are blocked up not in black.
(3) fruit image is obtained based on R-G color difference images, as shown in Fig. 2, including the following steps:
1) in order to eliminate the extra branch in color difference image, disc-shaped structure element that radius is 5 is primarily based on to R-G colors
Difference image carries out etching operation, such as Fig. 5 (c);From Fig. 5 (c) as can be seen that most of branch is eliminated in image.
2) by Fig. 5 (c) it is found that the tail portion calyx of Apple because with apple body color difference it is larger form hole,
Follow-up fruit region can be caused to lack and imperfect if be not pocessed, thus using unrestrained water filling algorithm to the R- that corroded
G color difference images carry out holes filling operation, such as Fig. 5 (d);From Fig. 5 (d) as can be seen that hole is filled.
3) image that holes filling is crossed still has the noise other than fruit or block of making an uproar, to eliminate these noises or block of making an uproar,
Pixel of the gray value in R-G color difference images that holes filling is crossed less than 20 is set to 0 first, then passes through 8 neighbourhood signatures' methods pair
Connected region in image is marked, counts sum, sum of all pixels is less than to 2000 removing of small regions, such as Fig. 5 (e);From
Fig. 5 (e) is as can be seen that noise or block of making an uproar are basically eliminated.
4) in order to ensure the integrality of follow-up fruit image to greatest extent, relative to the etching operation of 2) step, based on half
The disc-shaped structure element that diameter is 5 is to the reversible carry out expansive working of R-G color difference images after removing of small regions, such as Fig. 5 (f).
5) target area edge still has non-targeted object in the R-G color difference images after expanding, and is based on radius thus
10 disc-shaped structure element carries out opening operation operation, to slacken the non-of target area edge to the R-G color difference images after expansion
Target object, such as Fig. 5 (g).
6) RGB original images are split for threshold value with R-G color difference images gray value 0 after opening operation, obtain fruit image,
Such as Fig. 5 (h).
(4) RGB artworks image subtraction fruit image obtains subtraction image, such as Fig. 5 (i).
(5) leaf image is obtained based on subtraction image, as shown in figure 3, including the following steps:
1) using 2G-R-B color factors as color characteristic, green tree leaf has more significant difference with background, for this to phase
Subtract image and do 2G-R-B operations, color difference image is obtained, such as Fig. 5 (j);From Fig. 5 (j) as can be seen that being largely greenery in image,
Other backgrounds are blocked up not in black.
2) to eliminate noise extra in color difference image or block of making an uproar, by 8 neighbourhood signatures' methods in 2G-R-B color difference images
Connected region be marked, count sum, by sum of all pixels be less than 500 removing of small regions, can from Fig. 5 (k) such as Fig. 5 (k)
To find out, noise or block of making an uproar are eliminated in image.
3) RGB original images are split for threshold value with 2G-R-B color difference images gray value 0 after removing of small regions, obtain tree
Leaf image, such as Fig. 5 (l).
(6) due to the fruit image that is obtained by (3) do not include remote fruitlet (it is distant from visual sensor, in image
Fruit just seem smaller, the picking robot based on machine vision can only pick the fruit nearer from visual sensor, i.e.,
Larger fruit), and follow-up RGB original images need to subtract all fruit images, thus based on (2) R-G color difference images dynamic
Threshold segmentation obtains dynamic threshold segmentation fruit image.
(7) by the way that in the fruit image of dynamic threshold segmentation acquisition, fruit region is it is possible that lack, thus again by dynamic threshold
Value segmentation image and (3) fruit image addition, obtain and are added image, and the corresponding fruit of fruit image is obtained to make up dynamic threshold segmentation
The missing in real region.
(8) RGB artworks image subtraction is added image and leaf image, subtraction image is obtained, such as Fig. 5 (m).
(9) branch image is obtained based on subtraction image, as shown in figure 4, including the following steps:
1) using R-G color factors as color characteristic, branch has more significant difference with background, and subtraction image is done again
R-G operations obtain color difference image, such as Fig. 5 (n);From Fig. 5 (n) as can be seen that being largely branch in image, other backgrounds mound
Not in black.
2) in order to eliminate extra noise or the block of making an uproar in R-G color difference images, it is primarily based on the disc-shaped structure member that radius is 2
Element carries out opening operation operation to R-G color difference images, such as Fig. 5 (o);From Fig. 5 (o) as can be seen that image in some extra noises or
Block of making an uproar is eliminated.
3) connected region in R-G color difference images after opening operation is marked by 8 neighbourhood signatures' methods again, counts total
Number, by less than the removing of small regions of sum of all pixels threshold value 800, such as Fig. 5 (p);From Fig. 5 (p) as can be seen that image noise or block of making an uproar
It is eliminated completely, although some small branches are also eliminated together, these small branches pick not picking robot avoidance
It impacts.
4) RGB original images are split for threshold value with R-G color difference images 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 of the present invention, and not limitation of the present invention, related technology
The those of ordinary skill in field without departing from the spirit and scope of the present invention, can also make a variety of changes, therefore
All equivalent technical solutions also belong to the scope that the present invention protects.