Tomato plant night image segmentation method based on improved PCNN
Technical Field
The invention relates to a tomato plant night image segmentation method based on improved PCNN.
Background
Tomato production robot is the research focus in the current agricultural automation field, and as the mode that improves tomato production efficiency and realize tomato production automation, carrying out tomato production night is the effective way of the strong characteristics of tomato seasonality, and tomato production robot carries out work in daytime and night continuity and can be fine solution current tomato production in the labour resource shortage, the labour cost scheduling problem of being high. The identification and positioning of the tomato plant stems based on machine vision are the premise of picking tomatoes and trimming axillary buds and branches and leaves, and the realization of the image segmentation of the tomato plant stems is the premise of realizing the identification and positioning of the tomato plant stems. In order to improve the production efficiency of tomatoes, relevant production work is necessary at night, and the realization of the nighttime image segmentation of tomato plants is an important step for realizing the automation of a tomato production robot.
Under the illumination of the natural environment at night, the illumination is uneven, and shadows caused by branches and leaves are difficult to avoid, thereby bringing difficulty to the night image segmentation of the tomato plant stems.
The PCNN model is used for image processing, so that the neighborhood similar pixels in the target region and the background region can be well kept continuous. The problem of nighttime image segmentation of tomato plant stems is not solved by the conventional PCNN model, so that adjacent segmentation of organs of tomato plants is inaccurate, and the accuracy of identification of each organ of the tomato plants is influenced. In addition, the traditional PCNN model has the defects of high image segmentation iteration times and poor real-time performance, and is not enough to meet the requirements in production practice.
Disclosure of Invention
The invention aims to provide a tomato plant night image segmentation method based on improved PCNN, which reduces the iteration times in the traditional PCNN model image segmentation process, effectively reduces the image segmentation time, can realize the correct rate of tomato plant stem identification, and lays a foundation for identifying and positioning the tomato plant stems at night.
The technical scheme adopted by the invention is as follows:
illuminating nighttime tomato plants with an illumination system; the binocular stereo camera collects color images and transmits the images to image processing software for image segmentation; collecting a color image C of a tomato plant in a natural environment at night by using a binocular stereo camera; the method comprises the following steps:
preprocessing an image: carrying out noise reduction treatment on the tomato plant night color image C by using wiener filtering to obtain an image D;
improving the PCNN model: weighting the link input items in the PCNN model to obtain the improved PCNN model as shown in the formulas (1) to (5):
Fij(n)=Sij (1)
Lij(n)=t(∑klWijklYkl(n-1)) (2)
Uij(n)=Fij(n)(1+βLij(n)) (3)
in the formula: fij-feedback input to the neuron; sij-grey scale image S corresponds to a pixel value; l isij-a link entry; u shapeij-an internal activity item; β -inter-synaptic linkage coefficient; y isij-a pulse output value; eij-a dynamic threshold; n-the number of iterations; t is a weight coefficient; i. j-represents a pixel in the digital image; k. l-neighborhood pixels representing a center pixel; alpha is alphaE-an iterative decay time constant of the dynamic threshold system; vE-a corresponding link weight amplification factor; wijklDetermined by the W link weight matrix, as shown in equation (6):
setting an initial value of the PCNN parameter, setting the iteration number n as 1, and starting iterative image segmentation based on the improved PCNN model;
fourthly, carrying out image segmentation on the image D subjected to noise reduction by using the improved PCNN model to obtain a binary image B (n);
calculating the information entropy P (n) of the binary image B (n);
sixthly, judging whether the information entropy P (n) is larger than the information entropy P (n-1) obtained in the previous iteration: if so, the iteration times are increased by 1, and the step IV is skipped; and otherwise, taking the image segmentation result B (n-1) obtained in the previous iteration as a final image segmentation result, and finishing the iterative image segmentation based on the improved PCNN model.
The tomato plant night image segmentation method based on the improved PCNN is characterized in that the weighting method for the chaining input items in the PCNN model in the step II comprises the following steps: obtaining an optimal threshold level for image segmentation of a tomato plant night color image C by using an OTSU image segmentation algorithm, taking the level value as a weight coefficient of a link input item, wherein the link input item in the weighted PCNN model is as shown in formula (7):
Lij(n)=level(∑klWijklYkl(n-1)) (7)
in the formula: level-OTSU partition optimal threshold;
the tomato plant night image segmentation method based on the improved PCNN is characterized in that the PCNN parameter initial value setting method in the third step is as follows: obtaining an image segmentation threshold level of a tomato plant night color image C by using an OTSU image segmentation algorithm, and taking the level value as an iterative attenuation time constant alpha of a dynamic threshold systemEThe chain weight amplification factor VEAnd an initial value of the inter-synaptic linkage coefficient beta is shown in formula (8):
the invention has the beneficial effects that:
the method adopts the OTSU algorithm threshold value to assign values to the parameters in the PCNN model, realizes the self-adaptation of the parameters of the PCNN model, and adds the OTSU threshold value as a weight value in a link input item, so that the PCNN model only needs two iterations to obtain an ideal segmentation image, and the real-time performance of the PCNN model is greatly improved.
Drawings
Fig. 1 is a schematic diagram of a tomato plant night image acquisition and processing system.
FIG. 2 is a flow chart of algorithm segmentation of a tomato plant nighttime image improvement PCNN model.
Fig. 3 is a diagram of a modified PCNN model.
Fig. 4 is a schematic diagram of the link weight matrix W.
FIG. 5 is an improved PCNN model iterative segmentation graph.
Figure 6 is an OTSU algorithm segmentation graph.
In fig. 1: 1. tomato plant, 2 binocular stereo camera, 3, lighting system, 4, 1394 image acquisition card, 5, computer, 6, image processing software.
Detailed Description
The invention is further illustrated by the following figures and examples.
Fig. 1 illustrates a specific example of the illumination system for night image acquisition of tomato plants. The lighting system 3 employs an up-down lighting system consisting of 2 28w halogen lamps, with an up-down distance of 400 mm. The image receiving device adopts a binocular stereo camera 2 (the stereo camera can acquire three-dimensional position information of a target and is considered for acquiring the three-dimensional position information of a tomato plant component organ later), an image sensor in the binocular stereo camera 2 is a color Sony ICX204 CCD, the maximum resolution is 1024 multiplied by 768, and the focal length of a lens is 6 mm. The image acquisition card 4 is MOGE 1394 with a power adapter. The computer 5 is a DELL E4300 notebook computer with a memory of 2G, and the CPU is an Intel Core2 Duo P9400 WIN 7 operating system. The binocular stereo camera 2 is connected with a 1394 image acquisition card 4 by using a 1394 connecting wire, and the 1394 image acquisition card 4 is installed on a computer 5 through a 7-in-1 card reader interface.
The specific implementation of the PCNN model image segmentation algorithm for improving nighttime tomato plants is as follows:
illuminating the nighttime outdoor tomato plants 1 with an illumination system 3; a color CCD in the binocular stereo camera 2 receives a pair of optical image pairs of the tomato plant 1 and converts the optical image pairs into a pair of electronic image pairs for output; the pair of electronic images output by the binocular stereo camera 2 is input into a 1394 image acquisition card 4; the 1394 image acquisition card 4 converts the analog image signal into a digital image signal and inputs the digital image signal into the computer 5; the image processing software 6 in the computer 5 realizes the image segmentation processing on the tomato plants in the natural environment at night.
As shown in fig. 2, the improved PCNN model algorithm segmentation of the nighttime images of tomato plants is specifically realized as follows:
preprocessing an image: carrying out noise reduction treatment on the tomato plant night color image C by using wiener filtering to obtain an image D, wherein the wiener filtering is a self-adaptive linear filter with the least square as an optimal criterion; the filtering effect can be adjusted according to the local variance, the effect of removing Gaussian noise is obvious, and the method is suitable for removing noise of the tomato plant nighttime image;
improving the PCNN model: weighting the link input items in the PCNN model to obtain the improved PCNN model as shown in the formulas (1) to (5):
Fij(n)=Sij (1)
Lij(n)=t(∑klWijklYkl(n-1)) (2)
Uij(n)=Fij(n)(1+βLij(n)) (3)
in the formula: fij-feedback input to the neuron; sij-grey scale image S corresponds to a pixel value; l isij-a link entry; u shapeij-an internal activity item; β -inter-synaptic linkage coefficient; y isij-a pulse output value; eij-a dynamic threshold; n-the number of iterations; t is a weight coefficient; i. j-represents a pixel in the digital image; k. l-neighborhood pixels representing a center pixel; alpha is alphaE-an iterative decay time constant of the dynamic threshold system; vE-a corresponding link weight amplification factor; wijklDetermined by the W link weight matrix, as shown in equation (6):
setting an initial value of the PCNN parameter, setting the iteration number n as 1, and starting iterative image segmentation based on the improved PCNN model;
fourthly, carrying out image segmentation on the image D subjected to noise reduction by using the improved PCNN model to obtain a binary image B (n);
calculating the information entropy P (n) of the binary image B (n); generally, the larger the maximum entropy of the image after segmentation, the larger the amount of information obtained from the original image after segmentation, the more detailed the segmented image, and therefore, the better the segmentation effect. As shown in formula (7):
H1(P)=-P1log2P1-P0log2P0 (7)
sixthly, judging whether the information entropy P (n) is larger than the information entropy P (n-1) obtained in the previous iteration: if so, the iteration times are increased by 1, and the step IV is skipped; and otherwise, taking the image segmentation result B (n-1) obtained in the previous iteration as a final image segmentation result, and finishing the iterative image segmentation based on the improved PCNN model.
The tomato plant night image segmentation method based on the improved PCNN is characterized in that the weighting method for the chaining input items in the PCNN model in the step II comprises the following steps: obtaining an image segmentation threshold level of a tomato plant night color image C by using an OTSU image segmentation algorithm, wherein the formula (8) is as follows:
g=max{ω0(μ0-μ)2+ω1(μ1-μ)2} (8)
in the formula: omega0-the number of pixels of the foreground in proportion to the whole image; omega1-the number of pixels of the background is proportional to the whole image; mu.s0-average gray level of foreground pixels; mu.s1-average gray level of background pixels; μ — total average gray scale of image pixels; g-maximum between-class variance; max-represents the maximum value;
the level is an optimal threshold corresponding to the maximum inter-class variance g of the image, the level value is used as a weight coefficient of a link input item, and the link input item in the weighted PCNN model is as shown in the formula (9):
Lij(n)=level(∑klWijklYkl(n-1)) (9)
in the formula: level-OTSU splits the optimal threshold.
The tomato plant night image segmentation method based on the improved PCNN is characterized in that the PCNN parameter initial value setting method in the third step is as follows: obtaining an optimal threshold level of image segmentation of a tomato plant night color image C by using an OTSU image segmentation algorithm, and taking the level value as an iterative attenuation time constant alpha of a dynamic threshold systemEThe chain weight amplification factor VEInitial value of inter-synaptic linkage coefficient betaAs shown in formula (10):
through tests, the image segmentation result of the upper right corner of the image in the figure 5 is obtained based on a Matlab R2016a programming environment by applying the method, the total operation time of the algorithm is 1.126 seconds, and the maximum entropy value reaches 0.9309. In the improved PCNN model, the result of the first iteration is shown in the upper left corner of FIG. 5, and the maximum entropy value after segmentation is 0.0069; FIG. 5 shows the second iteration result in the upper right corner, after segmentation, the maximum entropy value is 0.9309, and the tomato, the stem and the leaves on the tomato plant are completely segmented; the lower left corner of fig. 5 is the result of the third iteration, the maximum entropy value after segmentation is 0.8026, and compared with the upper right corner of fig. 5, tomatoes and stalks in the lower left corner are all deleted after segmentation; the lower right corner of fig. 5 is the fourth iteration result, the maximum entropy value after segmentation is 0.7494, the tomato plant organ is seriously lost, and the noise in the image is serious; because the PCNN iterative segmentation image quality is from poor to excellent and from good to poor, the second iterative effect in the improved PCNN model is the best, and the second iterative result is selected as the image segmentation result of the improved PCNN model. FIG. 6 shows the result of OTSU segmentation, which has a maximum entropy value of 0.7151.