The BP neural network of different brown rice seed identifications makes up and recognition methods
Technical field
The present invention relates to a kind of method that detects brown rice seed type based on computer image processing technology in conjunction with the BP neural network.Belong to the Computer Automatic Recognition field.
Background technology
Brown rice is as storage raw material and husk rice raw material, and its quality directly influences the edible also nutritive value of rice, and then influences its economic worth and grain security.Unsound grain, immature kernel, dead rice etc. are to be difficult to the constituent avoided in the brown rice, and they influence not only thereafter that the processing quality of rice also can impact Rice Cooking Properties simultaneously.It is bigger that the type of brown rice seed and content are influenced by rice variety and growing environment etc.China mainly is by the artificial visually examine to brown rice seed type detection at present, and this method subjectivity is strong, labour intensity is big, error is big, is unfavorable for quick and precisely the brown rice seed being classified.
Summary of the invention
The present invention is for solving the detection problem of fast, accurately discerning dissimilar brown rice seeds, and proposing a kind of is that the basis utilizes the BP neural network to discern dissimilar brown rice seeds with the computer image processing technology.
Adopt following technical scheme: comprise following steps:
● 1) obtain image: dissimilar brown rice seeds are placed image capturing system, obtain the RGB image.With the black material is background, and the grain of rice does not separately contact;
● 2) the image pre-service: eliminate the influence of background noise, then to carrying out image threshold segmentation;
● 3) the different brown rice seed image feature informations of extraction: color, form and the textural characteristics value of extracting each seed by image processing software;
● 4) principal component analysis (PCA) is to the image feature information dimensionality reduction;
● 5) design BP neural network structure: input layer, hidden layer, the output layer node number of design BP neural network;
● 6) neural network training: carry out the training of neural network by dissimilar brown rice seeds.
Further technical scheme of the present invention is: step 2) specifically be that the RGB image is converted into gray level image, use the Ostu adaptive threshold to determine segmentation threshold behind the medium filtering, gray level image is carried out binary conversion treatment, at last bianry image is carried out the morphology ON operation, extract information from objective pattern, comprise major axis, minor axis, length breadth ratio, girth, area, girth
2/ area;
Further technical scheme of the present invention is: step 3) is extracted original image R, G, B, H, S, each component image of I, and it is carried out medium filtering.The textural characteristics of gray level image comprises mean value, average contrast, smoothness, third moment, consistance, entropy behind extraction R, G, B, H, S, I and the medium filtering.Further technical scheme of the present invention is: dissimilar brown rice seeds described in the step 6) are meant and improve grain, blue or green grain, the white grain of chalk, the white grain of blue or green chalk, white immature kernel, blue or green immature kernel, white dead rice, blue or green dead rice, sprouted kernel, injured kernel, the heterochromatic grain of improving.
Further technical scheme of the present invention is: step 5) is specially: choose three-layer neural network.The major component that principal component analysis (PCA) obtains is carried out normalized, obtain input vector, normalized makes network input vector scope be [0,1].The design of output vector is designed to vector form according to brown rice seed kind.Take all factors into consideration input vector and object vector, the building network structure.Output vector adopts following form output:
Improve grain: (1,0,0,0,0,0,0,0,0,0,0);
The blue or green grain that improves: (0,1,0,0,0,0,0,0,0,0,0);
The white grain of chalk: (0,0,1,0,0,0,0,0,0,0,0);
The white grain of blue or green chalk: (0,0,0,1,0,0,0,0,0,0,0);
Immature kernel: (0,0,0,0,1,0,0,0,0,0,0);
Blue or green immature kernel: (0,0,0,0,0,1,0,0,0,0,0);
Dead rice: (0,0,0,0,0,0,1,0,0,0,0);
Blue or green dead rice: (0,0,0,0,0,0,0,1,0,0,0);
Sprouted kernel: (0,0,0,0,0,0,0,0,1,0,0);
Injured kernel: (0,0,0,0,0,0,0,0,0,1,0);
Heterochromatic grain: (0,0,0,0,0,0,0,0,0,0,1);
According to system's inputoutput data characteristics, determine the input layer and the output layer node number of BP neural network.The hidden layer node number is chosen according to formula n2=2 * n1+1.Wherein n2 is the hidden layer neuron number, and n1 is the input neuron number.The transport function of hidden layer neuron adopts S type tan tansig, and output layer neuron transport function adopts S type logarithmic function logsig.
Further technical characterictic of the present invention is: preferred 100 of dissimilar brown rice seeds described in the step 6).
The BP network of different brown rice seed identifications is neural to be made up and recognition methods, it is characterized in that: the BP neural network that adopts above-mentioned arbitrary described construction method to build is carried out different brown rice seed identifications.
Method proposed by the invention, by black is that background is obtained dissimilar brown rice seed images, utilize image processing techniques to obtain its characteristic information, and utilize principal component analysis (PCA), utilize the BP neural network that dissimilar brown rice seeds is discerned at last the characteristic information dimensionality reduction.This method can be discerned dissimilar seeds objective, accurately and rapidly, overcomes the drawback of traditional manual detection.
Embodiment
Below by concrete example the inventive method is described.
Below the specific embodiment of the present invention is described: the step-by-step procedures of the described method of the embodiment of the invention is as follows:
At first, choosing 150 brown rice and place respectively on the scanner, is background with the black material, and the grain of rice does not separately contact, and adopts resolution 300dpi scanning to obtain image, and picture stores with the tif form.
Then, carry out pre-service and image segmentation.Earlier the RGB image is converted into the gray scale figure, medium filtering re-uses the Ostu adaptive threshold and determines segmentation threshold then, and gray level image is carried out binary conversion treatment at last bianry image is carried out the morphology ON operation, and to the bianry image mark.
The morphological feature of the grain of rice behind the extraction morphology ON operation, morphological feature comprises major axis, minor axis, length breadth ratio, girth, area, girth
2/ area.
Extract original image R, G, B, H, S, each component image of I, and to its medium filtering, R, G, B, H, S, I textural characteristics and gray level image Gray textural characteristics comprise mean value, average contrast, smoothness, third moment, consistance, entropy after the extraction filtering.
The characteristic information that extracts is carried out the principal component analysis (PCA) dimensionality reduction.
Design the BP neural network structure then, choose three-layer neural network.The major component that principal component analysis (PCA) obtains is carried out normalized, obtain input vector, normalized makes network input vector scope be [0,1].The design of output vector is designed to vector form according to brown rice seed kind.Take all factors into consideration input vector and object vector, the building network structure.Output vector adopts following form output:
Improve grain: (1,0,0,0,0,0,0,0,0,0,0);
The blue or green grain that improves: (0,1,0,0,0,0,0,0,0,0,0);
The white grain of chalk: (0,0,1,0,0,0,0,0,0,0,0);
The white grain of blue or green chalk: (0,0,0,1,0,0,0,0,0,0,0);
Immature kernel: (0,0,0,0,1,0,0,0,0,0,0);
Blue or green immature kernel: (0,0,0,0,0,1,0,0,0,0,0);
Dead rice: (0,0,0,0,0,0,1,0,0,0,0);
Blue or green dead rice: (0,0,0,0,0,0,0,1,0,0,0);
Sprouted kernel: (0,0,0,0,0,0,0,0,1,0,0);
Injured kernel: (0,0,0,0,0,0,0,0,0,1,0);
Heterochromatic grain: (0,0,0,0,0,0,0,0,0,0,1);
According to system's inputoutput data characteristics, determine the input layer and the output layer node number of BP neural network.The hidden layer node number is chosen according to formula n2=2 * n1+1.Wherein n2 is the hidden layer neuron number, and n1 is the input neuron number.The transport function of hidden layer neuron adopts S type tan tansig, and output layer neuron transport function adopts S type logarithmic function logsig.
Then carry out network training, the BP neural network is trained the BP neural network with training data.Every kind of seed of 11 kinds of brown rice seeds all has 150 groups of major component signals, and therefrom 100 groups of picked at random are as the training data training network, and 50 groups of data are as test data test network classification capacity.
With the neural network that trains seed classification under the test data is classified at last.Use 50 * 11 groups of test data test network classification capacities of picked at random in the network training.For the output result processing that rounds up.
It should be noted last that: above embodiment is the unrestricted technical scheme of the present invention in order to explanation only, although the present invention is had been described in detail with reference to the foregoing description, those of ordinary skill in the art is to be understood that: still can make amendment or be equal to replacement the present invention, and not breaking away from any modification or partial replacement of spirit and scope of the invention, it all should be encompassed in the middle of the claim scope of the present invention.