Summary of the invention
First purpose of the embodiment of the invention provides a kind of image characteristic extracting method, utilizes this method can solve preferably as the inter-adhesive problem of the fruit image of target image.
Second purpose of the embodiment of the invention provides a kind of image characteristics extraction device, utilizes this device can solve preferably as the inter-adhesive problem of the fruit image of target image equally.
For realizing above-mentioned first purpose, some embodiments of the present invention provide a kind of image characteristic extracting method, comprising:
Generate weighted image according to the image that collects, the pixel of said weighted image is obtained by the gray-scale value weighting than (G+B)/(G-B) and Lab color space respective pixel with difference in the rgb color space respective pixel;
Generate bianry image according to said weighted image, said bianry image comprises target image and background image, and said target image is blocked mutually by the image of single target or a plurality of targets and constitutes;
Fill the hole of target image in the said bianry image and eliminate the noise of said bianry image;
Obtain the edge image of the target image of the intact hole of said filling, and obtain the boundary rectangle image of said edge image;
For arbitrary said boundary rectangle image, calculate the corresponding center of circle and radius according to the edge image in this boundary rectangle image.
For realizing above-mentioned second purpose, other embodiment of the present invention also provide a kind of image characteristics extraction device, comprising: first generation module, second generation module, processing module, first acquisition module and second acquisition module;
Said first generation module comprises first acquiring unit, converting unit, second acquisition unit and generation unit, said first acquiring unit, be used for obtaining each pixel in the image that collects at rgb color space with difference than (G+B)/(G-B); Said converting unit is used for the said image that collects is transformed into the Lab color space from said rgb color space; Said second acquisition unit links to each other with said converting unit, is used for obtaining from said Lab color space a passage the gray-scale value of each pixel the corresponding said image that collects; Said generation unit links to each other respectively with said second acquisition unit with said first acquiring unit, is used for obtaining the weighted value of each pixel in the corresponding said image that collects according to said and poor ratio and gray-scale value, generates weighted image;
Said second generation module links to each other with said generation unit, is used for generating bianry image according to said weighted image, and said bianry image comprises target image and background image;
Said processing module links to each other with second generation module, the noise that is used for filling the hole of said bianry image target image and eliminates said bianry image;
Said first acquisition module links to each other with said processing module, is used to obtain the edge image that said filling finishes the target image of hole, and obtains the boundary rectangle image of said edge image;
Said second acquisition module links to each other with said first acquisition module, is used for calculating the corresponding center of circle and radius for arbitrary said boundary rectangle image according to the edge image in this boundary rectangle image.。
Can know by technique scheme; Some embodiments of the present invention provide a kind of image characteristic extracting method, through the image that collects is handled, generate weighted image, bianry image; In bianry image, fill the hole of target image and eliminate random noise; Final edge image and boundary rectangle image through target image obtain the characteristics of image of one group of center of circle and radius, solved target more and overlapping, when blocking; To the identification problem of target adhesion image, have characteristics accurately and rapidly; Other embodiment of the present invention provide a kind of image characteristics extraction device; In first generation module, be used for obtaining each pixel in the said image that collects at rgb color space with the difference ratio; Simultaneously the image that collects is transformed into the Lab color space from rgb color space by converting unit; And obtain the gray-scale value of each pixel by second acquisition unit; Finally by generation unit basis and difference than the weighted value of obtaining each pixel with gray-scale value with the generation weighted image; To generate bianry image, processing module is filled the hole of target image, the random noise of elimination bianry image to second generation module in bianry image to the weighted value pixel segmentation of weighted image, and obtains the edge image and the boundary rectangle image of target image by first acquisition module; Finally by second acquisition module for arbitrary said boundary rectangle image; Edge image according in this boundary rectangle image calculates the corresponding center of circle and radius, can well solve the segmentation problem of adhesion fruit image, and the method for this image characteristics extraction has characteristics fast and accurately.
Embodiment
Through accompanying drawing and embodiment, the technical scheme of the embodiment of the invention is done further detailed description below.
The image characteristic extracting method that all embodiment of the present invention are provided mainly is under field conditions (factors), the method that the similar round objective fruit is carried out image characteristics extraction, below among each embodiment the similar round objective fruit can to select with the apple be example.
Fig. 1 is the process flow diagram of embodiment of the invention image characteristic extracting method.As shown in Figure 1, the image characteristic extracting method of present embodiment is specially:
The image that step 11, basis collect generates weighted image, and the pixel of said weighted image is obtained by the gray-scale value weighting with difference ratio and Lab color space respective pixel in the rgb color space respective pixel;
This step can be specially: at first; To pluck apple image gather; The image that generally collects all is in rgb color space; The all corresponding one group of RGB of each pixel in the said image that collects (red, green, blue) value in rgb color space, is obtained the said image that collects and differ from than (G+B)/(G-B) according to the said rgb value of each pixel that collects in the image; Then, the said image that collects is transformed into the Lab color space from said rgb color space, obtain the cie color value (X, Y, Z), said cie color value (X, Y Z) with the corresponding relation of rgb value are:
X=2.7689R+1.7517G+1.13025B,
Y=1.000R+4.5907G+0.0601B,
Z=0.55907G+5.5943B,
In said Lab color space; The all corresponding L of each pixel in the said image that collects, a, three passages of b; It is all corresponding one group (L, a, b) value of each pixel; A passage from said Lab color space in the present embodiment obtains the gray-scale value IMAGa of each pixel in the corresponding said image that collects, and IMAGa is the function of said cie color value X and Y:
IMAGa=500[f(X/X
0)-f(Y/Y
0)],
Wherein, function f is: f (x)=x
1/3, X
0, Y
0Value for standard sources;
At last; According to said and poor than (G+B)/(G-B) and gray-scale value IMAGa; Adopt formula IMAGJ=0.5*IMAGa+0.5* (G+B)/(G-B); Obtain weighted value IMAGJ, said weighted value be to generate in the weighted image value of each pixel in the corresponding said image that collects of each pixel, to generate weighted image.
Here need explanatorily be that (X, Y Z) can obtain before or after said rgb color space is transformed into the Lab color space said cie color value, did not influence and obtained gray-scale value IMAGa.
Step 12, generate bianry image according to said weighted image, said bianry image comprises target image and background image, and said target image is blocked mutually by the image of single target or a plurality of targets and constitutes;
This step can be specially: the weighted value IMAGJ to all pixels in the said weighted image adopts Ostu method automatic threshold to cut apart; Generate bianry image; Said bianry image comprises target image and background image; Generally have a plurality of apple fruit images in the said image that collects, target image is the form of expression of said fruit image in said bianry image; The target image that said target image possibly be made up of the single target apple is perhaps blocked mutually by a plurality of target apples and the target image that constitutes; Target image is made up of the white pixel point in the present embodiment, and hereinafter to be referred as white point, background image is made up of black pixel point, hereinafter to be referred as black color dots.
Step 13, fill the hole of target image in the said bianry image and eliminate the noise of said bianry image;
Owing to apple surface illumination reflection and reason such as block; Cut apart in the bianry image that weighted value IMAGJ generated of all pixels in the said weighted image, there is the hole phenomenon in the inside of some target image, and the zone of hole is made up of black color dots; Simultaneously; Part such as limb, ground might form the less white portion in some zones in said bianry image, become the noise of target image, and promptly noise is made up of white point;
This step can be specially: the structural element that adopts 4*4 carries out twice opening operation and closed operation continuously to said bianry image; Can fill above-mentioned target image inside holes and eliminate the partial noise in the bianry image; The structural element of said 4*4 is meant that the length of side is the square array of 4 pixels; Pixel value wherein all is 1, and said opening operation can be removed the bright details littler than the structural element of 4*4, and closed operation can be removed the dark-coloured details littler than the structural element of 4*4; Opening and closing operation combination is used can smoothed image, eliminates the noise of part point-like; Calculate each target image area then; Set area threshold; Convert area into background image (being made up of black color dots) less than the target image (white portion) of said area threshold, can eliminate the noise of remainder, said area threshold can be chosen about 50 pixels as required; Omitted the synoptic diagram that exists noise and its target image to have hole in the bianry image in the present embodiment; Fig. 2 is the synoptic diagram after the embodiment of the invention is carried out the filling perforation hole and eliminated noise bianry image, and as shown in Figure 2, each white portion among the figure is the target image of having filled hole.
Step 14, obtain the edge image of the target image of the intact hole of said filling, and obtain the boundary rectangle image of said edge image;
This step can be specially: at first, in the bianry image after above-mentioned steps 13 is handled, the search white point; Whether other 8 neighborhood territory pixel points of judging the white point that searches have black color dots, if having, said white point then is a marginal point; Do not handle; Otherwise be non-marginal point, be converted into black color dots, finally getting access to the white point is the edge image of marginal point.Said edge image is the edge image of each white portion among Fig. 2; Because the target image of the intact hole of the corresponding said filling of said white portion; Therefore said edge image is the edge image of the target image of the intact hole of said filling; According to the edge image of said each white portion, obtain the boundary rectangle image of said edge image at last.Fig. 3 is the edge image of target image among embodiment of the invention Fig. 2 and the synoptic diagram of boundary rectangle.As shown in Figure 3, the edge image among Fig. 3 in each boundary rectangle image is the target image of same position in the corresponding diagram 2 all.
Step 15, for arbitrary said boundary rectangle image, calculate the corresponding center of circle and radius according to the edge image in this boundary rectangle image.
This step can be specially: at first for the arbitrary boundary rectangle image among Fig. 3; Said boundary rectangle image can by the coordinate in the upper left corner (X1, Y1) (X2 Y2) limits the scope of its internal edge image with the coordinate in the upper right corner; Particularly; The X1 coordinate in the upper left corner is an X coordinate figure minimum value in the marginal point of said edge image, and the Y1 coordinate is a Y coordinate maximal value in the marginal point of said edge image, and the X2 coordinate figure in the lower right corner is an X coordinate figure maximal value in the marginal point of said edge image; The Y2 coordinate figure is a Y coordinate minimum value in the marginal point of said edge image, and all coordinates in the present embodiment all are that unit is weighed with the pixel; According to said boundary rectangle image and its inner edge image, adopt genetic algorithm to obtain said boundary rectangle image and its inner edge image corresponding target image center of circle and radius again;
The genetic algorithm that present embodiment adopted is that an initial population from the potential disaggregation of representative problem begins.Said initial population is made up of the chromosome of the some of process gene code.Said chromosome is as the set of a plurality of genes, and its inner performance (being genotype) is certain assortment of genes, and it has determined chromosomal external presentation (being phenotype).At first, needing to realize from phenotype is gene code to genotypic mapping, owing to copy the work of gene code very complicated, in practical application, often simplifies, and generally adopts binary coding; Then, after just producing, according to the principle of the survival of the fittest and the survival of the fittest for population; Produce the approximate solution of becoming better and better by the generation evolution; According to chromosomal fitness size selective staining body, and intersect and variation, produce population of future generation by means of natural genetics genotype is made up.It is the same that this process will cause kind of images of a group of characters to be evolved naturally, and the optimum chromosomal genotype in the last reign of a dynasty population can be used as the approximate optimum solution of problem through the phenotype of decoding.The search of said genetic algorithm can be carried out a plurality of chromosomal parallel comparisons at one time from colony, and population of new generation is adapted to environment more than previous generation, has improved speed and the precision found the solution;
In the present embodiment, the genetic algorithm of utilization is:
Step 1501, generation initial population;
This step can be specially: if apple fruit edge is blocked too much, the center of circle that might the apple fruit appear at this apple fruit target image the outside of corresponding boundary rectangle image, therefore; Can set a constant Lr according to the size of each target image in the bianry image of Fig. 2, Lr can be set at the approximate value of apple radius, and unit is a pixel; For example, the radius of apple image is between 80 pixel systems, 100 pixels in the image that is collected, and then can establish Lr is 100; Be to improve the search efficiency of genetic algorithm, (X1 is Y1) with the coordinate (X2 in the lower right corner to the coordinate in the said boundary rectangle image upper left corner to utilize constant Lr; Y2) (x y) does following processing: x ∈ [X1-Lr, X2+Lr] to the coordinate in the limited range; Y ∈ [Y1+Lr, Y2-Lr]; Then in coordinate figure x and y institute restricted portion, adopt the method for random number generation, (x, y), wherein (x y) represents a chromosome to each coordinate, and these 50 chromosomes have constituted initial population to produce 50 coordinates at random.
Step 1502, to chromosome coding, and generate said chromosomal genotype;
This step can be specially: to above-mentioned chromosome Ik (k=1,2 ..., 50) encode; Because the genotype GK of chromosome Ik is a binary number, considers the size of apple image in the image that is collected again, therefore will represent chromosomal coordinate (x; Y) x in and y value adopt 10 binary number representation respectively, and to form 20 binary number xy, for example coordinate (8; 14), 20 bits formed of 8 and 14 10 bits are 00000,01000; 00000,01110, the 20 bit xy here are the genotype GK of chromosome Ik.
Step 1503, obtain all chromosomal fitness in the initial population;
This step can be specially: (x y) obtains the distance of this coordinate each marginal point to its edge image, and adds up in these distances the number n near apple image radius distance in the image that is collected according to the chromosomal coordinate of representative; For example; The apple image radius is between 80 pixel systems, 100 pixels in the image that is collected, but the number of the distance of statistical distance between 70 pixel to 110 pixels, further; But the distance that can set near this radius is communication distance; Therefore but the number of communication distance is n, but and then obtain the variance var of these communication distances in 70 pixel to 110 pixel distance scopes, and through formula f that present embodiment provided
Fitness=n/var obtains each chromosomal fitness in the initial population;
Step 1504, each chromosome is intersected and makes a variation, finally obtain optimum chromosome.
This step can be specially: according to each chromosomal fitness in the initial population, each chromosomal genotype is intersected and made a variation, generate first population of future generation; Setting described crossing-over rate in the present embodiment is 30%, and aberration rate is 0.1%, further; First population of future generation continues execution in step 1503 and step 1504, sets in the present embodiment and evolves to the 100 population of future generation, finally obtains optimum chromosome; Wherein optimum chromosomal phenotype be selected in external rectangular image the center of circle of corresponding target image, further, according to step 1503; But obtain the communication distance of this center of circle each marginal point to its edge image; But but and add up maximum preceding 3 communication distances of equal value in this communication distance, but obtain the average of these 3 communication distances, be the radius of target image.
The image characteristic extracting method that is provided in this enforcement; Through image normalization and conversioning colour space to collecting; Generate weighted image, and to the weighted value pixel segmentation of weighted image to generate bianry image, in bianry image, fill target image hole, eliminate the random noise of bianry image and obtain the edge image and the boundary rectangle image of target image; Finally according to said edge image and the characteristics of image of choosing one group of center of circle of boundary rectangle Image Acquisition and radius; Not only can solve the occlusion issue between the fruit image preferably, being blocked at the fruit image surpasses at 2/3 o'clock, still can extract the characteristic of the center of circle and radius accurately; And can well solve the segmentation problem of adhesion fruit image, the method for this image characteristics extraction has characteristics fast and accurately.
The image characteristic extracting method of the embodiment of the invention also comprises:
Step 16, convert the edge image of the said center of circle and radius into said background image;
Described in Fig. 3 for arbitrary boundary rectangle image in; Constitute circular image with the corresponding center of circle and radius, Fig. 4 is the synoptic diagram of the embodiment of the invention with one group of center of circle and radius formation circular image, and is as shown in Figure 4; Fig. 4 is the boundary rectangle image of being chosen, and its inside is edge image; Then adopt " elimination method ", convert the said inner edge image of boundary rectangle image of choosing into said background image.
Further, also comprise:
Step 17, when said boundary rectangle image inside also comprises remaining edge image, then obtain the corresponding center of circle and the radius of said remaining edge image according to said remaining edge image and said boundary rectangle image calculation;
This step can be specially: Fig. 5 chooses the synoptic diagram of residue edge image in the boundary rectangle image for the embodiment of the invention; Further; On the basis of Fig. 5, when choosing boundary rectangle image inside also to have remaining edge image, confirm the number of choosing the inner marginal point of boundary rectangle image said when said; Wherein set a threshold value 50 earlier; Surpass threshold value 50 explanations and choose boundary rectangle image inside also to have remaining edge image, this remaining edge image be other apple edge of image images, and further specifying correspondence, said to choose the target image of boundary rectangle image be fruit adhesion image; Then then according to said remaining edge image and the said boundary rectangle image of choosing; Return step 1503; And adopt above-mentioned genetic algorithm; Calculate and obtain the corresponding center of circle and the radius of said remaining edge image, no longer include remaining edge image, no longer exist till other apple images up to the boundary rectangle image inside of being chosen.
Next; Choose another boundary rectangle image of Fig. 3 bianry image in the image that is collected; And to its execution in step 15 and step 16; The center of circle and the radius of all boundary rectangle image inward flange images in obtaining Fig. 3 bianry image are to accomplish the center of circle of the image that collected and the extraction of radial features.
Fig. 6 is the structural representation of embodiment of the invention image characteristics extraction device.As shown in Figure 6, embodiment of the invention image characteristics extraction device comprises first generation module 61, second generation module 62, processing module 64, first acquisition module 63, second acquisition module 65,
Wherein, first generation module 61 comprises first acquiring unit 6101, converting unit 6102, second acquisition unit 6103 and generation unit 6104; First acquiring unit 6101, at the said image that collects in rgb color space, obtain each pixel in the said image that collects with difference than (G+B)/(G-B); Converting unit 6102 is transformed into the Lab color space with the said image that collects from said rgb color space; Be specially the said image that collects is transformed into the Lab color space from said rgb color space; In said Lab color space; The all corresponding L of each pixel in the said image that collects, a, three passages of b, i.e. all corresponding one group (L, a, b) value of each pixel; Second acquisition unit 6103 links to each other with converting unit 6102, and from said Lab color space a passage, obtains the gray-scale value IMAGa of each pixel in the corresponding said image that collects; Generation unit 6104; Link to each other respectively with second acquisition unit 6103 with first acquiring unit 6101; And according to said and poor ratio and gray-scale value, the weighted value of obtaining each pixel in the corresponding said image that collects generates weighted image, is specially according to said and poor than (G+B)/(G-B) and gray-scale value IMAGa; Adopt formula IMAGJ=0.5*IMAGa+0.5* (G+B)/(G-B); Obtain weighted value IMAGJ, said weighted value be to generate in the weighted image value of each pixel in the corresponding said image that collects of each pixel, finally generate weighted image.
Second generation module 62; Link to each other with first generation unit 6104; And according to said weighted image generation bianry image; Be specially and adopt Ostu method automatic threshold to cut apart to generate bianry image to the weighted value IMAGJ of all pixels in the said weighted image, said bianry image comprises target image and background image, and wherein target image is specially by single target or a plurality of target and blocks mutually and the target image that constitutes; Processing module 64; Link to each other with second generation module 62; And fill the hole of target image in the said bianry image and eliminate the noise of said bianry image, be specially the structural element that adopts 4*4 said bianry image is carried out twice opening operation and closed operation continuously, can fill above-mentioned target image inside holes and eliminate the partial noise in the bianry image; Further calculate each target image area; Set area threshold, convert area into background image less than the zone of said area threshold, can eliminate the noise of remainder; First acquisition module 63 links to each other with processing module 64, and obtains the edge image of the target image of the intact hole of said filling; And obtain the boundary rectangle image of said edge image, and be specially and at first search for white point, judge then whether other 8 neighborhood territory pixel points of the white point that searches have black color dots; If have, said white point is a marginal point then, does not handle; Otherwise be non-marginal point, be converted into black color dots, then getting access to the white point is the edge image of marginal point; Final according to being the edge image of marginal point with the white point, obtain the boundary rectangle image of the target image edge image of the intact hole of said filling; Second acquisition module 65 links to each other with first acquisition module 63, for arbitrary said boundary rectangle image, calculates the corresponding center of circle and radius according to the edge image in this boundary rectangle image.
The image characteristics extraction device that is provided in this enforcement; In first generation module through the normalization unit to each pixel normalization in the said image that collects; By first acquiring unit obtain after the normalization with the difference ratio; Simultaneously the image that collects is transformed into the Lab color space from rgb color space, and obtains the gray-scale value of each pixel by second acquisition unit by converting unit, finally by generation unit basis and difference than the weighted value of obtaining each pixel with gray-scale value with the generation weighted image; Second generation module to the weighted value pixel segmentation of weighted image to generate bianry image; Processing module in bianry image, fill target image hole, eliminate the random noise of bianry image, and obtain edge image and the boundary rectangle image of target image by first acquisition module, finally by second acquisition module according to said edge image with choose the characteristics of image of one group of center of circle of boundary rectangle Image Acquisition and radius; Can solve the occlusion issue between the fruit image preferably; Be blocked above 2/3 o'clock at the fruit image, still can extract the characteristic of the center of circle and radius accurately, have characteristics fast and accurately.
Embodiment of the invention image characteristics extraction device also comprises modular converter and the 3rd acquisition module; Wherein modular converter links to each other with said second acquisition module; Be used for converting the edge image of the said center of circle and radius into said background image (being black color dots); Said first acquisition module of the 3rd acquisition module links to each other; When said boundary rectangle image inside also comprises remaining edge image, then obtain the corresponding center of circle and the radius of said remaining edge image according to said remaining edge image and said boundary rectangle image calculation, in said boundary rectangle image, no longer include remaining edge image till.
What should explain at last is: above embodiment only in order to the explanation embodiment of the invention technical scheme but not limit it; Although the embodiment of the invention has been carried out detailed explanation with reference to preferred embodiment; Those of ordinary skill in the art is to be understood that: it still can make amendment or be equal to replacement the technical scheme of the embodiment of the invention, also can not make amended technical scheme break away from the spirit and the scope of embodiment of the invention technical scheme and these are revised or be equal to replacement.