Weed Detection using Machine Vision

Size: px
Start display at page:

Download "Weed Detection using Machine Vision"

Transcription

1 Weed Detection using Machine Vision 1 Dhirdekar Shubham, 2 Summaiya Badeghar, 3 Manali Jangam, 4 M.P.Dale 1,2,3 B.E. Students, Electronics & Telecommunication, MESCOE, PUNE, Maharashtra, India 4 Professor, Department of Electronics & Telecommunication, MESCOE, PUNE, Maharashtra, India 1 dhirdekarshubham07@gmail.com, 2 summaiya.badeghar.5@gmail.com, 3 manalijangam99@gmail.com, 4 mpdale@mescoepune.org Abstract Weed management is costly in agriculture field. There are huge varieties of weeds species available, which decreases the growth of the crop and reduces the farm yields. The goal of this paper is to develop a new weed detection system. Plants growing between rows are considered as weed. The problem of pollution is also caused by more usage of herbicides which results in contamination of drinking water. That is also may be harmful to animals also. Therefore, we have to reduce the excessive usage of herbicides i.e, to spray herbicide on only weed. In this paper, images are taken at regular interval and when weed is detected, the herbicide will spray effectively on only weed. This is achieved by erosion-dilation method. The input image which is RGB is converted into excessive green and then to binary image by setting certain threshold. The white pixels count present in the ROI is determined and if it crosses predefined threshold, it will be considered as weeds. Relay is used to connect either load circuit or sprayer circuit. When relay contacts are closed it will supply power to load circuit i.e, robot will start moving and when relay contacts are open circuit it will supply power to sprayer circuit such that robot will stop and it will spray herbicides on weed. Keywords Image Processing, Weed detection, Morphological operations- Dilation and Erosion, herbicide Sprayer, Arduino. I. INTRODUCTION In agriculture, the spraying of chemical is done to remove weeds in field. In order to decrease the spraying of chemical volume, the solution is to spray herbicide only in the areas where it is necessary i.e, where weed grows. Unwanted plants growing between rows are mainly considered as weed. Weeds can also decrease cultivation of crops. A large amount of time and money is spend by farmers for managing weeds, For above reason, we are focusing on identification and removal of weeds using image processing, with the use of this technique of weed detection, it would help removal of weed with ease and may also require less cost and also less efforts. For identification of weeds, different techniques have reflectance of plants with artificial neural network, principal component analysis, recognition based on leaf shape, texture feature, Hough transform, some of them are based on Fourier transform and Kaman filtering to discriminate between crop and weeds. For discrimination between plants and weed Kargar used wavelet transform. That led to accuracy from 49 to 97 %. Spectral reflectance technique is used for plant species identification. Spectrometer is necessary to record spectral reflectance parameter but cost is higher than the common former can offered. Various types of spectral reflectance parameter is used like for vegetation indices, to measure crop properties in the visible spectrum typically ratios of broadband reflectance values are used. The features like, variance of the near infrared spectrum, skewness, average gives the high level of success in color segmentation. Piron algorithm got 72% of accuracy in their proposed system for detection of weed in carrot rows. Kiani S, verified that different ANN gives different accuracies with different texture features such as energy, contrast, homogeneity, inertia, entropy as a input to the ANN. Gabor wavelet combined with PCA algorithm got 90.5% of precision. Xavier P. used a computer vision system that could discriminate between weed and Crop under lighting condition. This system has two independent subsystems, a fast image processing that could give results in realtime, and second is a slower and more accurate processing that can be used to correct the earlier mistakes occurred in first subsystem. Aravind R. proposed a system which is based on morphological operations i.e, erosion and dilation that could discriminate plants and weed such that plants are considered as broad leaves and weed are considered are narrow leaves. Ajinkya P. used edge detection to identify weed. K. Lee and K. Hong used Fast Fourier Transfer (FFT) techniques with distance between centroid and contour on the detected leaf image. It has reached accuracy of 97.19%. Amruta A. used back propagation neural network for crop and weed discriminator. Extracted texture features of each small segment of crop and weed is given to the neural network. Output of the neural network is used for crop been used. They are such as wavelet transform, spectral 78

2 and weed classification. Size based features Area, Perimeter, Minor axis and Major axis are used for detection of crop. II. BLOCK DIAGRAM Figure 1. Block Diagram Figure. shows the block diagram of overall system for crop and weed detection. We captured the image using digital camera. While capturing the image camera position is towards ground. After taking the image, image is given to the laptop for image processing. MATLAB software is used. After the image processing algorithm data is given to the controller. Processed data is given to the controller board through the USB. Here Arduino board is used as a controller board. Data received by the controller robotic manipulator moves in x, y, z direction and spraying the herbicides on particular weed. DC motors are connected to the robotic manipulator after receiving the data it actuates the manipulator. By this way only weed areas gets sprayed by pesticides and plant will be protected. III. METHODOLOGY ADOPTED A. Image Acquisition The first step of image acquisition is done with help of camera. Here, Digital camera Night vision QHM500-8LM(S) is used. It has maximum frame rate of 30fps and resolution of 8 Mega Pixels. The camera is mounted using mechanical assembly facing downwards on the robot chassis. Images are captured in natural light condition and then captured image is proceed with MATLAB software. B. Excessive green Fig. Flowchart of algorithm In excessive green color algorithm soil is removed from the images and only green color information is remain which is required. Excessive green color algorithm: mask=inimage(:,:,1)<inimage(:,:,2)&inimage(:,:,3)<inim age(:,:,2); outimage = bsxfun(@times, inimage, uint8(mask)); C. Binary Image Figure 3. Excessive Green Image The excessive green image is converted into binary image using the direct function in MATLAB. Figure 2. Input Image 79

3 Figure 4. Binary Image D. Morphological operations Erosion The next step is to erode the image. Erosion is a basically shrinks the image. The way the image is shrink is determined by a structuring element. The structuring element is normally smaller than the image with a 3X3 size. Here, we have used line as a structuring element. The erosion process will move the structuring element from left to right and top to bottom. At the centre position indicated by the centre of the structuring element, the process will look for whether there is a complete overlap with structuring element or not. If there is no complete overlapping then the centre pixel indicated by the centre of the structuring element will be set white or 0. Figure 5. Dilated Image E. Thresholding and Summation The summation of dilated image of weed, plant and both plant and weed together has found out separately. And according to that threshold has been set. F. Detection of weed Here, the consideration is made such that the plantation crops are broad leaves plants and weed are narrow leaves plants. Thus three cases can be considered here. Case 1 Broad leaves i.e. plants in the ROI. The amount of white pixels in the ROI will be comparatively less than when there are both broad and narrow leaves are present but greater as compared to that when there narrow leaves are present. Case 2 Narrow leaves i.e. weeds in the ROI. The amount of white pixels in the ROI will be comparatively less than when there are both broad and narrow leaves are present and also it will have less white pixels as compared to presence of broad leaves. Figure 6. Eroded Image Case 3 Dilation Dilation is a process in which the binary image is expanded from its original shape. The dilation process is similar to convolution process. If there exists an overlapping then the centre pixel indicated by the centre of the structuring element will be set 1 or black. Dilation bridged gaps in the image. After eroding the image A, the dilation segmentation algorithm is applied, which has its own 3x3 structuring element, due to which it will dilate the required image. A dilated by the structuring element of dilation of B. Broad and narrow leaves i.e. when both weed and plants are present in the ROI. In this case the amount of white pixels is greater than above two cases. G. Sprayer The spraying of herbicides happens only if Case 2 occurs. Otherwise the chemicals will not be sprayed in either of the two cases. IV. HARDWARE IMPLEMENTATION The block diagram of the hardware is shown in Figure 6. Arduino is used as controller. The above explained algorithm is implemented in MATLAB. Camera is used to take images i.e, of plantation crop. The images thus taken are processed in MATLAB for identification of crop and weed and simultaneously it is decided whether 80

4 it is crop or weed based on summation and threshold decided. And if weed is present then sprayer mechanism will start and herbicide will be sprayed effectively on that area. at one end. Camera and sprayer mechanism are mounted on a robot that moves in the forward direction in the field. Case III: Figure 9. Only crop in ROI Figure 7. Block diagram of hardware system The motors are attached to the wheels, and it is interface with Arduino. The controller is given 5V of supply. Camera is connected serially(usb). Relay is used to switched between control circuit and load circuit. The power source is given to the electromagnet through a control switch and through contacts to the load. When current starts flowing through the control coil, the electromagnet starts energizing and hence produces the magnetic field. Thus the upper contact arm starts to be attracted to the lower fixed arm and thus closes the contacts causing a short circuit for the power to the load. When short circuit is occurred robot will start to move. On the other hand, if the relay was already de-energized when the contacts were closed, then the contact move oppositely and make an open circuit. And now, during the open circuit sprayer circuitry will work. Narrow leaves in the ROI. It indicates only weed is present. As shown in figure. Case IV: Figure 10. Only weed in ROI Broad and narrow leaves in the ROI. It is shown in figure. V. RESULTS AND DISCUSSION According to the cases, Case I: No plants in the ROI. As shown in following figure, hence herbicide will not spray Figure 11. Crop and weed in ROI VI. CONCLUSION AND FUTURE WORK This paper introduces a erosion-dilation approach for weed detection. The reason behind developing such system is to detect and reuse weed affected area for plantation. This system effectively reduces the cost and man power. Thus, we can conclude that image processing is effective tool that can use in agriculture domain. Case II: Figure 8. No plants in ROI Broad leaves in the ROI. It indicates only crop is present. As shown in figure. Future work will involve Environmental depended weed detection system i.e, it will detect weed in different lightning conditions, wind, cloudy and different natural parameters. So, we needed to develop such classifier further. In the future work, this system can also be implemented to identify the diseases that are occurring in plants. 81

5 ACKNOWLEDGMENT We would like to articulate our deep gratitude to our project guide Dr.M.P.Dale for her guidance, advice and support during the course of our project. We would also like to thank our HOD, Prof. P. B. Chopade, all faculty members and staff of the Department of Electronics and Telecommunication, MES College of Engineering, Pune, for their generous help and guidance in various ways for this project. REFERENCES [1] Amir H. Kargar B, Ali M. Shirzadifar, Automatic Weed Detection System and Smart Herbicide Sprayer Robot for corn fields,ieee Int. Conf. on Robotics and Mechatronics, Tehran, Feb pp [2] Amruta. A. Aware, Crop and Weed Detection Based on Texture and Size Features and Automatic Spraying of Herbicides, International Journal of Advanced Research in Computer Science and Software Engineering, Volume 6, Issue 1, January 2016 [3] Aravind R, Daman M, Design and development of Automatic Weed Detection System and Smart Herbicide Sprayer Robot, IEEE Recent Advances in Intelligent Computational Systems (RAICS), Trivandrum December [4] Muhammad Hameed Siddiqi,Irshad Ahmad, Weed Recognition Based on Erosion and Dilation Segmentation Algorithm, International Conference on Education Techology and Computer,2009. [5] Ajinkya Paikekari, Vrushali Ghule, Rani Meshram, B.Raskar, Weed detection using image processing, International Research Journal of Engineering and Technology, March [6] K. Lee and K. Hong, An Implementation of Leaf Recognition System using Leaf Vein and Shape, International Journal of Bio-Science and Bio-Technology, vol. 5, no. 2, April [7] Rafael C. Gonzalez, Richard E. Woods, Morphological Image Processing, in Digital Image Processing, 3nd edition, New Jersey, Prentice-Hall Inc., 2006, pp [8] Piron, A., Leemans, V., Kleynen, 0., Lebeau, F., Destain, M. -F.(2008). Selection of the most efficient wavelength bands for discriminating weeds from crop. Computers and Electronics in Agriculture, 62, [9] KİANİ S, Crop-Weed Discrimination Via Wavelet-Based Texture Analysis, Internatıonal Journal of Natural and Engineering Sciences 6 (2) : 7-11,2012. [10] Xavier P. Burgos-Artizzu, Angela Ribeiro, Maria Guijarro, Gonzalo Pajares; Real- time image processing for crop/weed discrimination in maize fields ; Elsevier;