DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON...

11
DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1 , R. Anirudh Reddy 1 , Ch. Subrahmanya Harish 2 , P. Mahima 2 , T. Phaninder Reddy 2 Professor 1 , UG Students 2 , Department of ECE 1, 2 , B.V.Raju Institute of Technology 1, 2 , Narsapur,Medak. April 30, 2018 Abstract Agriculture is the backbone of our country. Most part of the Indian economy comes from agriculture. Most of the farmers are finding new occupation for their lively hood as risks are increasing rapidly in agriculture field. Cotton is one of the important cash crops which are grown in India from many centuries. Weed which stops the growth of the plant is the main risk in agriculture. There are multiple types of weeds and to detect all these weeds its a time- consuming process. In this paper we consider our main crop as cotton. Here we introduce a method to identify the cotton plants by this every plant other than cotton is a weed. This is done by image processing techniques, where the main template-here we give cotton, is compared with sub templates. Whenever the sub template is not cotton then we consider it as a weed. The tools we used are python 2.7.9 version, numPy and Open CV. The processing of im- age done by a simple phenomenon called template matching which is normally used for detection of an object from an image of multiple objects. 1 International Journal of Pure and Applied Mathematics Volume 118 No. 24 2018 ISSN: 1314-3395 (on-line version) url: http://www.acadpubl.eu/hub/ Special Issue http://www.acadpubl.eu/hub/

Transcript of DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON...

Page 1: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

DESIGN OF A WEED DETECTIONSYSTEM FOR COTTON FIELD

Dr. I. A. Pasha1, R. Anirudh Reddy1,Ch. Subrahmanya Harish2, P. Mahima2,

T. Phaninder Reddy2

Professor1, UG Students2,Department of ECE1,2,

B.V.Raju Institute of Technology1,2,Narsapur,Medak.

April 30, 2018

Abstract

Agriculture is the backbone of our country. Most partof the Indian economy comes from agriculture. Most of thefarmers are finding new occupation for their lively hood asrisks are increasing rapidly in agriculture field. Cotton isone of the important cash crops which are grown in Indiafrom many centuries. Weed which stops the growth of theplant is the main risk in agriculture. There are multipletypes of weeds and to detect all these weeds its a time-consuming process. In this paper we consider our maincrop as cotton. Here we introduce a method to identifythe cotton plants by this every plant other than cotton is aweed. This is done by image processing techniques, wherethe main template-here we give cotton, is compared withsub templates. Whenever the sub template is not cottonthen we consider it as a weed. The tools we used are python2.7.9 version, numPy and Open CV. The processing of im-age done by a simple phenomenon called template matchingwhich is normally used for detection of an object from animage of multiple objects.

1

International Journal of Pure and Applied MathematicsVolume 118 No. 24 2018ISSN: 1314-3395 (on-line version)url: http://www.acadpubl.eu/hub/Special Issue http://www.acadpubl.eu/hub/

Page 2: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

Key Words:Python, OpenCV, Image Processing, Tem-plate ,Template Matching, Weeds.

1 Introduction

Agriculture sector plays a key role to the contribution of Indianeconomy. Most of the rural habitats have agriculture as their mainsource of income. More than fifty percent of the people occupa-tion is agriculture. The major threat to agriculture is unnecessarygrowth of weeds. It is estimated that on an average thirty per-cent of the total expenditure on crop production is for removingof weeds manually or mechanically. Farmers need to remove weedsperiodically by engaging labour. The weeds should be removed orit will affect the yield of the crop. These weeds grow depending onthe type of soil. There are multiple varieties of weeds and their leafstructures are different.These weeds fight with the main crop forwater, nutrients, sunlight, space etc. They have the inbuilt habitof growing fast and vigorous. The main crop faces deficiency of nu-trients, water and space if weeds are not removed. These unwantedplants also reduces the yield of the crop. The quality and quantitybig crop declines. So there is an alarming need for detection andremoval of weeds automatically by the advance techniques. Somehave broader leaves and some have thinner leaves. So, detection ofevery type of weed is practically not possible and even it is possi-ble it takes lot of time to gather information about all the typesof weeds. These weeds grow by taking the resources supplied tothe crop. Weeds act as host for many disease-causing pests and in-sects which causes interruption in growth of the required plants. Asgrowth of the required plants is affected it in turn affects the yieldof the crop and market value of the crop. When weeds are removedmanually by the labor with some tools or they remove them by barehands. These weeds grow faster so they are removed periodically.It requires around four to five thousand rupees to remove the weedper acre and it is a burden to the farmer. Due to this the farmersstarted using of herbicides to regulate the growth of weeds but overusage of these chemicals affects the crop. So we came up with anidea to detect the weed by image processing. Here the image is readto classify between weed and cotton.

2

International Journal of Pure and Applied Mathematics Special Issue

Page 3: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

2 LITERATURE SURVEY

A weed detection system is used in [1], [2] where it uses weed plantsas the template images. But, the main problem here is, there mightbe multiple types of weeds in the cotton field. So, taking differenttemplates of the weeds is really a tough task. So, in real timesystems, the accuracy of this project will be low. The efficiency isalso considerably low.

As per analysis in [3], the section of a plant is explained bycomparing two algorithms namely Bayesian classifier and SupportVector Machine. By this the suitable way to differentiate the greencrop and weed is understood. Yet complete detection between weedand crop is not completely explained. As per [4], [5] the weeds arerecognised and herbicides are carefully sprayed on the weeds. Theyused MATLAB and Support Vector Machine algorithms respec-tively for the detection of weeds.

According to the weed detection system used in [9] had usedan algorithm which implement Erosion and Dilation approach todetect weeds, thereby herbicides is sprayed on them with the helpof pumps. But herbicides shows harmful effects on Nit only thecrop but also on the consumer who consume the yield. So we wentfor developing a system which automatically detects weeds and helpin mechanical removal of weeds.

In Germany, Bosch scientists developed a robot named BoniRob[7].This is about size of a car which uses laser-radar vision system anddistinguish the leaves from the plants that farmer want to harvestand then stamps the unwanted plants. Franklin Robotics made asolar powered robot called, Tertill treats small plants as weeds andtrims them by patrolling all over farm. Dutch agricultural engi-neers [10] developed Hortibot, which uses GPS(Global PositioningSystem) to locate the weed and sprays herbicide on it. This sys-tem is very huge in size and cost. It is suitable for only foreignagricultural lands.

3 DEPLOYMENT OF SOFTWARE

Software that used to develop this design is Python. We usedPython 2.7.9 version for this purpose. Python library providesmany image processing operations. Python was developed by Guido

3

International Journal of Pure and Applied Mathematics Special Issue

Page 4: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

van Rossom. Python is known for its readability of code and its sim-plicity. Python language is efficient in memory management. Bothstructural and object oriented programming can be done. IDLE isthe integrated development environment for the Python program-ming , where we type and execute the code.

Open CV-Python is the Python API of OpenCV. It combinesthe best qualities of Open CV/C++ API and Python. The impor-tant features of Python are its simplicity and code readability.Wehave also installed NUMPy along with Python and OpenCV. Be-cause it is highly optimized library fornumerical operations.OpenCVhelps us in template matching technique. Python library, OpenCVuses NumPy for storing and analysing array data. NumPy is anopen source software. It is also a library for Python. It helps forcomputations of multidimensional arrays, matrices which the helpof inbuilt mathematical functions.

Pip is a command that is used in Python language for installa-tion of software package. Pip is the type of Package ManagementSystem. Because of pip having the advantage of command lineinterface, we can install any packages with single command.

4 BLOCK DIAGRAM

The basic idea of the project can be referred from the block dia-gram. The top view of the crop is taken as the base image is usedfor further analysis in detection of weed and cotton. The image iscaptured during day time. The top view of the crop covers all thecotton plants and weeds that are to be removed.

Figure 2 : Block diagram

The image is read in gray scale as it contains less number ofbits per pixel. A basic colour image or otherwise called a RGB

4

International Journal of Pure and Applied Mathematics Special Issue

Page 5: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

image consists of 24-32 bits per pixel which is a lot to study forthe processor.A binary image or the black & white image containsonly two pixels which may help for the processing speed but mightnot be efficient in getting the exact details for the proper analysis.That is why as an intermediate solution, we go for the gray scaleimage for analysis of the image. A gray scale image contains 8 bitsper pixel. This actually deals with the processing speed and alsohelps in the perfect analysis and detailed processing of the image.

The image processing technique we used here is template match-ing. In template matching process the template image is convolutedwith the base image or main top view image in two dimensionally.Here we consider the shape of the leaf which our farm, in this caseit is cotton leaf. According to [6], we need to analyse the shape ofthe main crop, i.e., cotton and weeds. This is because all leaves aregreen in colour, structure plays a vital role to differentiate. Afterthis process the location of cotton plants is highlighted or markedfor easy understanding of farmer.

5 FLOW CHART

The flow chart is shown in the following figure. The flow chart givesthe process flow of the project.To explain in detail, in the templatematching system the template is slides over the base image frompixel to the other pixel until it gets a match. This analysis startsfrom the starting point of the base image.

In this process the properties of the template images and thebase or input image are compared and when a match occurs theposition of the image is marked or highlighted. If there is no matchthe process continues with next given template image.

5

International Journal of Pure and Applied Mathematics Special Issue

Page 6: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

Figure 3: Flow chart of the image processing execution

6 SYSTEMDESIGN AND IMPLEMEN-

TATION

The base and the template images are converted to the gray scaleonce they are given as input. The gray scale images are easy toprocess and efficiency is very high when compared to the RGBimages and binary or black and white images.

Predefined techniques are provided by Open CV. Template match-ing is nothing but to detect the objects in a given base image. Us-ing this technique multiple objects can be detected. After verifyingthe accuracy of those techniques, normalized coefficient templatematching is implemented here.

Normalized coefficient method is shownbelow:

R(x, y) =

∑x′y′ (T

′(x

′y

′).I

′(x + x

′, y + y

′))

√∑x′y′ T

′(x′y′)2.∑

x′y′ I′(x + x′ , y + y′)2

Here, R(x, y) represents the resultant intensity of the pixel ob-tained by normalizing the coefficients of the template image coeffi-cients T(x, y) and the input image I(x, y). This type of normalizedtemplate matching is found to be efficient for detecting the multi-ple objects in a single image. While mentioning multiple objects, itmeans that the same type of objects that are multiple in numbers.

6

International Journal of Pure and Applied Mathematics Special Issue

Page 7: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

The following picture is the top view of a cotton crop whichwas taken during morning time. In the picture covers both cottonplants and the weed. In this picture only one type of weed is shown,in some cases there can be multiple varieties of weeds. So the aimof the project is detect the cotton and showing every other plantas weed. Hence we concentrate on cotton not weed.

Fig. 2.

Figure 4: Input Image from cotton fieldThis is the top view of the cotton field and it shows cotton plats

and weed. This weed is one type from many other types of weeds.This image is read and then converted to the gray scale. Gray scaleconversion increases the speed of processing and efficiency.

Figure 5: The base image is read

This figure shows the read image of the cotton field. This imageis the converted into gray scale which is shown as follows.

Figure 6: Gray scale conversion of the base image

7

International Journal of Pure and Applied Mathematics Special Issue

Page 8: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

The next step is to pass the template images for comparison.The template images contain cotton. Some of the template imagesin RGB format are as follows.

Figure 7: Template images

These are the collection of cotton plants that are given to theprocessor. This is equivalent to a database providing to the pro-cessor. Here care must be taken, as we are passing cotton as thereference images we have to provide images of cotton of every stage.So that recognition of the cotton becomes easy.

These collections of templates are then converted into gray scaleas it will be easy for the processor to find a match in the base image.There are predefined commands in the Open CV for convertingimages into gray scale. This increases the speed of processing. Theconverted templates into gray scale are as follows.

Figure 8: Gray scale template images

These template images are read in gray scale format. Now wegot all the requisites for the project. Open CV provides some pre-defined functions which can be used for template matching. For de-tecting single object the template matching technique differs from

8

International Journal of Pure and Applied Mathematics Special Issue

Page 9: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

detecting multiple objects. To explain the process of template slid-ing we are assuming the following figure.

As mentioned earlier, first the templates are read by the proces-sor and it makes them slide over the base image. There are someissues when this template matching is considered. This may notprovide the efficient results as the size of the cotton leaves maychange with the time. To avoid this, template images are changedperiodically or we have to provide images of cotton from initialstage to a stage where it can sustain on its own. The followingimage shows the process of template sliding.

Figure 9: Template sliding in progress

The completion of the template matching is done after all thetemplates slide over the base image. The inbuilt function of OpenCV returns a gray scale image. For user understandability, we lo-cated the matched object and showed the result in the RGB image.Thus the resulted image contains the marked portions of cotton inthe base image.

The final output is as follows:

Figure 10: Output showing the weed locations

For a clear view, the result is shown as below.

9

International Journal of Pure and Applied Mathematics Special Issue

Page 10: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

Figure 11: Final Output showing the weed locations

7 CONCLUSION

This project is mainly concerned to detect cotton plants as therecan be multiple types of weeds in the field. Here we take manyimages of cotton plants and create a database through it. In otherwords, we take the images of cotton crop at different stages of itsgrowth and store in the database. Hence every time it comparesthe base image with the template images in the database. Thereis a future scope for even finding diseases of the main crop [8] andaccurately distinguish between main crop and weed in the worstconditions also.

Therefore, the moment it detects the cotton crop, it identifiesand locate the cotton. Hence,by detecting cotton we can infer thatthe rest of the plants which is not detected as weed. Also cannotget images of every variety of weed and though if we still try tomanage and collect various types of weed plants,there would stillbe a memory management issue and is also a time taking process.So, detecting the cotton instead of weed is the best option.

Also, there are many other various techniques for weed detec-tion. All these techniques like feature extraction method uses weedas their base image. But these techniques cannot be handy as theremight be a possibility of different types of weeds that can grow inthe cotton filed. Because of the same reason, detecting cotton inthe field is considered as the best possible solution.

References

[1] R.Anirudh Reddy, G. Laasya, P.Sindhuja, T.Sowmya, and Mu-dasarBasha, Image Processing For Weed Detection in IJET-MAS conference, Chandigarh, India in April 2017.

10

International Journal of Pure and Applied Mathematics Special Issue

Page 11: DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD · DESIGN OF A WEED DETECTION SYSTEM FOR COTTON FIELD Dr. I. A. Pasha 1, R. Anirudh Reddy, Ch. Subrahmanya Harish 2, P. Mahima,

[2] R. Anirudh Reddy, G. Laasya, ” Design of Weed DetectionSystem for Cotton field”, in MAT journals, Journal of Im-age processing and Artificial intelligence, Volume 3 Issue 3,September 2017

[3] Faisal Ahmed, A.S.M. Hossian Bari, EmamHossian, Perfor-mance analysis of Support Vector Machine and Bayesian Clas-sifier for Crop and Weed classification from digital Images,World Applied Sciences Journal, 2011.

[4] Latha, Poojith, Amarnath Reddy, Image processing in Agri-culture in International Journal of Innovative Research in Elec-trical, Electronics, Instrumentation and Control Engineering,June 2014.

[5] Riya Desai, Kruti Desai, ZinalSolanki, Removal of weeds usingImage Processing: A technical review in International Journalof Advanced Computer Technology (IJACT).

[6] S.G. Wu, F.S. Bao, E.Y. Xu, Yu-Xuan Wang, Yi-Fan Chang,and Qiao-Liang Xiang.A Leaf Recognition Algorithm for PlantClassification Using Probabilistic Neural Network. In Proc.IEEE International Symposium on Signal Processing and In-formation Technology, pages 1116, 2007.

[7] Florian Johannes Knoll,TimHoltrof, Stephen Hussmann, In-vestigation of Different Sensor Systems to Classify Plant andWeed in Organic Farming Applications.

[8] AnupVibhute, S K Bodhe, Applications of Image Processingin Agriculture: A Survey, International Journal of ComputerApplications, Volume 52, August 2012.

[9] RAravind, M Daman, B S Kariyappa, ” Design and develop-ment of automatic weed detection and smart herbicide sprayerrobot”, Intelligent Computational Systems(RAICS), Decem-ber 2015.

[10] Ronald Piquepaille, ”Hortibot: An Accessory Kit Transform-ing a Slope Mower into a Robotic Tool Carrier for High-TechPlant Nursing”, July 2006.

11

International Journal of Pure and Applied Mathematics Special Issue