You are on page 1of 51

REAL TIME ASSISTANCE TO FARMER AND HEALTH

SECTOR ANDROID APP


TABLE OF CONTENTS
CHAPTER TITLE PAGE NO
NO

ABSTRACT

1. CHAPTER 1 : INTRODUCTION

1.1 SYSTEM SPECIFICATION


1.1.1 HARDWARE SPECIFICATION
1.1.2 SOFTWARE SPECIFICATION

2. CHAPTER 2 : SYSTEM STUDY

2.1 EXISTING SYSTEM

2.1.1 DRAW BACKS IN EXISTING SYSTEM


2.2 PROPOSED SYSTEM
2.2.1 FEATURES IN PROPOSED SYSTEM
2.3 SOFTWARE ENVIRONMENT
2.3.1 FRONT END : ANDROID
2.3.2 BACK END : SQ LITE
3. CHAPTER 3: SYSTEM DESIGN &
DEVEOPMENT
3.1 FILE DESIGN
3.2 INPUT DESIGN
3.3 OUTPUT DESIGN
3.4 DATABASE DESIGN
3.4.1 OBJECTIVES OF DATABASE DESIGN
3.5 SYSTEM DEVEOPMENT
3.5.1 DISCRIPTION OF MODULES

4. CHAPTER 4 : METHODOLOGY
5. CHAPTER 5 : TESTING AND IMPLEMENT
5.1 TEST PLAN
5.1.1 BLACK BOX TESTING
5.1.2 UNIT TESTING
5.1.3 INTEGRATION TESTING
5.2 SYSTEM IMPLEMENTATION

TABLE OF CONTENTS
CHAPTER TITLE PAGE NO
NO

6. CHAPTER 6 : CONCLUSION

6.1 SCOPE FOR FUTURE ENHANCEMENT

7. CHAPTER 7 : BIBLIOGRAPHY &


REFERENCE

8 CHAPTER 8 : APPENDICES

8.1 DATA FLOW DIAGRAM

8.2 SAMPLE COADING


8.3 SAMPLE INPUT
ABSTRACT:

Agricultural productivity is something on which economy highly depends. This is the one of
the reasons that disease detection in plants plays an important role in agriculture field, as having
disease in plants are quite natural. If proper care is not taken in this area then it causes serious
effects on plants and due to which respective product quality, quantity or productivity is affected.
For instance a disease named little leaf disease is a hazardous disease found in pine trees in
United States. Detection of plant disease through some automatic technique is beneficial as it
reduces a large work of monitoring in big farms of crops, and at very early stage itself it detects
the symptoms of diseases i.e. when they appear on plant leaves. This paper presents an algorithm
for image segmentation technique which is used for automatic detection and classification of
plant leaf diseases. It also covers survey on different diseases classification techniques that can
be used for p-lant leaf disease detection. Image segmentation, which is an important aspect for
disease detection in plant leaf disease, is done by using Discrete & Convolution algorithm.
CHAPTER - 1
INTRODUCTION
The agricultural land mass is more than just being a feeding sourcing in today’s world. Indian
economy is highly dependent of agricultural productivity. Therefore in field of agriculture,
detection of disease in plants plays an important role. To detect a plant disease in very initial
stage, use of automatic disease detection technique is beneficial. For instance a disease named
little leaf disease is a hazardous disease found in pine trees in United States. The affected tree has
a stunted growth and dies within 6 years. Its impact is found in Alabama, Georgia parts of
Southern US. In such scenarios early detection could have been fruitful. The existing method for
plant disease detection is simply naked eye observation by experts through which identification
and detection of plant diseases is done. For doing so, a large team of experts as well as
continuous monitoring of plant is required, which costs very high when we do with large farms.
At the same time, in some countries, farmers do not have proper facilities or even idea that they
can contact to experts. Due to which consulting experts even cost high as well as time consuming
too. In such conditions, the suggested technique proves to be beneficial in monitoring large fields
of crops.

Automatic detection of the diseases by just seeing the symptoms on the plant leaves makes it
easier as well as cheaper. This also supports machine vision to provide image based automatic
process control, inspection, and robot guidance.

Plant disease identification by visual way is more laborious task and at the same time, less
accurate and can be done only in limited areas. Whereas if automatic detection technique is used
it will take less efforts, less time and become more accurate. In plants, some general diseases
seen are brown and yellow spots, early and late scorch, and others are fungal, viral and bacterial
diseases. Image processing is used for measuring affected area of disease and to determine the
difference in the color of the affected area.

Image segmentation is the process of separating or grouping an image into different parts. There
are currently many different ways of performing image segmentation, ranging from the simple
there sholding method to advanced color image segmentation methods. These parts normally
correspond to something that humans can easily separate and view as individual objects.
Computers have no means of intelligently recognizing objects, and so many different methods
have been developed in order to segment images. The segmentation process is based on various
features found in the image. This might be color information, boundaries or segment of an
image.
. 1.1 SYSTEM REQUIREMENTS

Defending requirements to establish specifications is the first step in the


development of the system. However in many situations not enough care is taken in
establishing correct requirements up front

1.1.1 HARDWARE REQUIREMENTS

PROCESSOR : Intel Core i3.


RAM : 4 GB DDR2 RAM
MONITOR : 15” COLOR
HARD DISK : 100 GB
1.1.2 SOFTWARE REQUIREMENTS

Back End : SQLITE


Operating System : Windows 07
IDE : Eclipse, Android Studio
CHAPTER - 2

SYSTEM STUDY

2.1 EXISTING SYSTEM

The leaf optical model PROSPECT is widely used to retrieve leaf biochemical parameters, such
as leaf chlorophyll content (Chl), carotenoid content (Car), leaf mass per area (LMA) and
equivalent water thickness (EWT). Most methods for retrieving leaf pigment content are based
on reflectance spectra and they may suffer from ill-posed problems in the inversion process. This
study proposes a new inversion method by integrating the continuous wavelet analysis into the
PROSPECT model inversion process. Instead of inputting reflectance directly to the inversion
process as for most studies, this method uses the wavelet transformed spectra from various scales
to construct the merit function for inversion. The performance of the new method was evaluated
with data from small-plot experiments of wheat and rice crops. Our experimental results
demonstrated that the wavelet-transformed spectra led to better inversion performance as
compared to the reflectance spectra and vegetation indices (VIs). The optimal scales of wavelet
decomposition are different for retrieving Chl and Car. This inversion method has great potential
for predicting leaf pigment content of different crops without the need of calibration models.

2.1.1 DRAW BACKS IN EXISTING SYSTEM

2.2 PROPOSED SYSTEM

2.2.1 FEATURES IN PROPOSED SYSTEM

2.3 SOFTWARE REQUIREMENT:

Android 6.0
The Android 6.0 Marshmallow update is usually doled out by your handset's manufacturer
and it can take some months for updates to the new operating system to be made available as the
manufacturers test the new software to make sure it's compatible.Marshmallow primarily focuses
on improving the overall user experience of its predecessor, Lollipop. It introduced a new
permissions architecture, new APIs for contextual assistants (first used by a new feature "Now
on Tap" to provide context-sensitive search results), a new power management system that
reduces background activity when a device is not being physically handled, native support for
fingerprint recognition and USB Type-C connectors, the ability to migrate data and applications
to a microSD card, and other internal changes. As of 8 August 2017, 32.3% of devices accessing
Google Play run Android 6.0.
Android is a mobile operating system developed by Google, based on a modified version of the
Linux kernel and other open source software and designed primarily for touchscreen mobile
devices such as smartphones and tablets. In addition, Google has further developed Android TV
for televisions, Android Auto for cars, and Android Wear for wrist watches, each with a
specialized user interface. Variants of Android are also used on game consoles, digital cameras,
PCs and other electronics.
Initially developed by Android Inc., which Google bought in 2005, Android was unveiled in
2007, with the first commercial Android device launched in September 2008. The operating
system has since gone through multiple major releases, with the current version being 8.1
"Oreo", released in December 2017. Android has been the best-selling OS worldwide on
smartphones since 2011 and on tablets since 2013. As of May 2017, it has over two billion
monthly active users, the largest installed base of any operating system, and as of 2017, the
Google Play store features over 3.5 million apps

HISTORY
The release was internally codenamed "Macadamia Nut Cookie". The first developer preview
build, codenamed Android "M", was unveiled and released at Google I/O on May 28, 2015, for
the Nexus 5 and Nexus 6 smartphones, Nexus 9 tablet, and Nexus Player set-top box. The second
developer preview was released on July 9, 2015, and the third and final preview was released on
August 17, 2015, along with announcing that Android M would be titled Android
"Marshmallow". On September 29, 2015, Google unveiled launch devices for Marshmallow: the
LG-produced Nexus 5X, the Huawei-produced Nexus 6P, alongside Google's own Pixel C tablet.
Android 6.0 updates and factory images for Nexus 5, 6, 7 (2013), 9, and Player were released on
October 5, 2015, Older Nexus devices, including the Nexus 4, Nexus 7 (2012) and Nexus 10, did
not receive an official update. On October 14, 2015, LG announced that it planned to release
Marshmallow for its flagship LG G4 smartphone in Poland the following week, marking the first
third-party device to receive an update to Marshmallow. Android 6.0.1, a software patch
featuring security fixes, support for Unicode 8.0 emoji (although without supporting skin tone
extensions for human emoji), and the return of the "until next alarm" feature in Do Not Disturb
mode, was released on December 7, 2015.Android Inc. was founded in Palo Alto, California in
October 2003 by Andy Rubin, Rich Miner, Nick Sears, and Chris White. Rubin described the
Android project as "tremendous potential in developing smarter mobile devices that are more
aware of its owner's location and preferences". The early intentions of the company were to
develop an advanced operating system for digital cameras, and this was the basis of its pitch to
investors in April 2004.The company then decided that the market for cameras was not large
enough for its goals, and by five months later it had diverted its efforts and was pitching Android
as a handset operating system that would rival Symbian and Microsoft Windows Mobile.Rubin
had difficulty attracting investors early on, and Android was facing eviction from its office
space. Steve Perlman, a close friend of Rubin, brought him $10,000 in cash in an envelope, and
shortly thereafter wired an undisclosed amount as seed funding. Perlman refused a stake in the
company, and has stated "I did it because I believed in the thing, and I wanted to help Andy."
In July 2005, Google acquired Android Inc. for at least $50 million. Its key employees, including
Rubin, Miner and White, joined Google as part of the acquisition. Not much was known about
the secretive Android at the time, with the company having provided few details other than that it
was making software for mobile phones. At Google, the team led by Rubin developed a mobile
device platform powered by the Linux kernel. Google marketed the platform to handset makers
and carriers on the promise of providing a flexible, upgradeable system. Google had "lined up a
series of hardware components and software partners and signaled to carriers that it was open to
various degrees of cooperation".
Speculation about Google's intention to enter the mobile communications market continued to
build through December 2006. An early prototype had a close resemblance to a BlackBerry
phone, with no touchscreen and a physical QWERTY keyboard, but the arrival of 2007's Apple
iPhone meant that Android "had to go back to the drawing board". Google later changed its
Android specification documents to state that "Touchscreens will be supported", although "the
Product was designed with the presence of discrete physical buttons as an assumption, therefore
a touchscreen cannot completely replace physical buttons". By 2008, both Nokia and BlackBerry
announced touch-based smartphones to rival the iPhone 3G, and Android's focus eventually
switched to just touchscreens. The first commercially available smartphone running Android was
the HTC Dream, also known as T-Mobile G1, announced on September 23, 2008.
Eric Schmidt, Andy Rubin and Hugo Barra at a 2012 press conference announcing Google's
Nexus 7 tablet
On November 5, 2007, the Open Handset Alliance, a consortium of technology companies
including Google, device manufacturers such as HTC, Motorola and Samsung, wireless carriers
such as Sprint and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments,
unveiled itself, with a goal to develop "the first truly open and comprehensive platform for
mobile devices". Within a year, the Open Handset Alliance faced two other open source
competitors, the Symbian Foundation and the LiMo Foundation, the latter also developing a
Linux-based mobile operating system like Google. In September 2007, InformationWeek
covered an Evalueserve study reporting that Google had filed several patent applications in the
area of mobile telephony.
Since 2008, Android has seen numerous updates which have incrementally improved the
operating system, adding new features and fixing bugs in previous releases. Each major release is
named in alphabetical order after a dessert or sugary treat, with the first few Android versions
being called "Cupcake", "Donut", "Eclair", and "Froyo", in that order. During its announcement
of Android KitKat in 2013, Google explained that "Since these devices make our lives so sweet,
each Android version is named after a dessert", although a Google spokesperson told CNN in an
interview that "It’s kind of like an internal team thing, and we prefer to be a little bit — how
should I say — a bit inscrutable in the matter, I’ll say".
In 2010, Google launched its Nexus series of devices, a lineup in which Google partnered with
different device manufacturers to produce new devices and introduce new Android versions. The
series was described as having "played a pivotal role in Android's history by introducing new
software iterations and hardware standards across the board", and became known for its "bloat-
free" software with "timely [...] updates". At its developer conference in May 2013, Google
announced a special version of the Samsung Galaxy S4, where, instead of using Samsung's own
Android customization, the phone ran "stock Android" and was promised to receive new system
updates fast. The device would become the start of the Google Play edition program, and was
followed by other devices, including the HTC One Google Play edition, and Moto G Google
Play edition. In 2015, Ars Technica wrote that "Earlier this week, the last of the Google Play
edition Android phones in Google's online storefront were listed as "no longer available for
sale"" and that "Now they're all gone, and it looks a whole lot like the program has wrapped up".
From 2008 to 2013, Hugo Barra served as product spokesperson, representing Android at press
conferences and Google I/O, Google’s annual developer-focused conference. He left Google in
August 2013 to join Chinese phone maker Xiaomi .Less than six months earlier, Google's then-
CEO Larry Page announced in a blog post that Andy Rubin had moved from the Android
division to take on new projects at Google, and that Sundar Pichai would become the new
Android lead. Pichai himself would eventually switch positions, becoming the new CEO of
Google in August 2015 following the company's restructure into the Alphabet conglomerate,
making Hiroshi Lockheimer the new head of Android.
In June 2014, Google announced Android One, a set of "hardware reference models" that would
"allow [device makers] to easily create high-quality phones at low costs", designed for
consumers in developing countries. In September, Google announced the first set of Android
One phones for release in India. However, Recode reported in June 2015 that the project was "a
disappointment", citing "reluctant consumers and manufacturing partners" and "misfires from the
search company that has never quite cracked hardware". Plans to relaunch Android One surfaced
in August 2015,with Africa announced as the next location for the program a week later. A
report from The Information in January 2017 stated that Google is expanding its low-cost
Android One program into the United States, although The Verge notes that the company will
presumably not produce the actual devices itself.
Google introduced the Pixel and Pixel XL smartphones in October 2016, marketed as being the
first phones made by Google, and exclusively featured certain software features, such as the
Google Assistant, before wider rollout. The Pixel phones replaced the Nexus series, with a new
generation of Pixel phones launched in October 2017.
FEATURES
User experience
A new "Assist" API allows information from a currently opened app, including text and a
screenshot of the current screen, to be sent to a designated "assistant" application for analysis and
processing. This system is used by the Google Search app feature "Google Now on Tap", which
allows users to perform searches within the context of information currently being displayed on-
screen. While the "Home" button was used in Android 5 to show available apps, the "Home"
button is used now (together with a voice command) to generate on-screen cards which display
information, suggestions, and actions related to the content. "Direct Share" allows Share menus
to display recently used combinations of contacts and an associated app as direct targets.
"Adoptable storage" allows a newly inserted SD card or other secondary storage media to be
designated as either "portable" or "internal" storage. "Portable" maintains the default behavior of
previous Android versions, treating the media as a secondary storage device for storage of user
files, and the storage media can be removed or replaced without repercussions, but is subject to
access restrictions by apps. When designated as "Internal" storage, the storage media is
reformatted with an encrypted ext4 file system, and is "adopted" by the operating system as the
primary storage partition. Existing data (including applications and "private" data folders) are
migrated to the external storage, and normal operation of the device becomes dependent on the
presence of the media. Apps and operating system functions will not function properly if the
adopted storage device is removed. If the user loses access to the storage media, the adopted
storage can be "forgotten", which makes the data permanently inaccessible. Samsung and LG
have, however, removed the ability to use an SD card as "internal" storage on their Galaxy S7
and G5 devices, with Samsung arguing that the feature could result in unexpected losses of data,
and prevents users from being able to transfer data using the card.
Interface
Android's default user interface is mainly based on direct manipulation, using touch inputs that
loosely correspond to real-world actions, like swiping, tapping, pinching, and reverse pinching to
manipulate on-screen objects, along with a virtual keyboard. Game controllers and full-size
physical keyboards are supported via Bluetooth or USB. The response to user input is designed
to be immediate and provides a fluid touch interface, often using the vibration capabilities of the
device to provide haptic feedback to the user. Internal hardware, such as accelerometers,
gyroscopes and proximity sensors are used by some applications to respond to additional user
actions, for example adjusting the screen from portrait to landscape depending on how the device
is oriented, or allowing the user to steer a vehicle in a racing game by rotating the device,
simulating control of a steering wheel.
Android devices boot to the home screen, the primary navigation and information "hub" on
Android devices, analogous to the desktop found on personal computers. Android home screens
are typically made up of app icons and widgets; app icons launch the associated app, whereas
widgets display live, auto-updating content, such as a weather forecast, the user's email inbox, or
a news ticker directly on the home screen. A homescreen may be made up of several pages,
between which the user can swipe back and forth. Third-party apps available on Google Play and
other app stores can extensively re-theme the home screen, and even mimic the look of other
operating systems, such as Windows Phone. Most manufacturers customize the look and features
of their Android devices to differentiate themselves from their competitors.
Along the top of the screen is a status bar, showing information about the device and its
connectivity. This status bar can be "pulled" down to reveal a notification screen where apps
display important information or updates. Notifications are "short, timely, and relevant
information about your app when it’s not in use", and when tapped, users are directed to a screen
inside the app relating to the notification. Beginning with Android 4.1 "Jelly Bean", "expandable
notifications" allow the user to tap an icon on the notification in order for it to expand and
display more information and possible app actions right from the notification.
An All Apps screen lists all installed applications, with the ability for users to drag an app from
the list onto the home screen. A Recents screen lets users switch between recently used apps.
Platform
Android Marshmallow introduces a redesigned application permissions model; apps are no
longer automatically granted all of their specified permissions at installation time. An opt-in
system is now used, in which users are prompted to grant or deny individual permissions (such
as the ability to access the camera or microphone) to an application when they are needed for the
first time. Applications remember the grants, which can be revoked by the user at any time. The
new permissions model is used only by applications developed for Marshmallow using its
software development kit (SDK), and older apps will continue to use the previous all-or-nothing
approach. Permissions can still be revoked for those apps, though this might prevent them from
working properly, and a warning is displayed to that effect.
Marshmallow introduces new power management schemes known as "Doze" and "App
Standby"; when running on battery power, a device will enter a low-power state if it is inactive
and not being physically handled. In this state, network connectivity and background processing
is restricted, and only "high-priority" notifications are processed. Additionally, network access
by apps is deferred if the user has not recently interacted with the app.[32] Apps may request a
permission to exempt themselves from these policies, but will be rejected from Google Play
Store as a violation of its "Dangerous Products" policy if their core functionality is not
"adversely affected" by them.
Android Marshmallow provides native support for fingerprint recognition on supported devices
via a standard API, allowing third-party applications to implement fingerprint-based
authentication. Fingerprints can be used for unlocking devices and authenticating Play Store and
Android Pay purchases. Android Marshmallow supports USB Type-C, including the ability to
instruct devices to charge another device over USB. Marshmallow also introduces "verified
links" that can be configured to open directly in their specified application without further user
prompts.User data for apps targeting Marshmallow can be automatically backed up to Google
Drive over Wi-Fi. Each application receives up to 25 MB of storage, which is separate from a
user's Google Drive storage allotment.
As of Marshmallow, the Android Compatibility Definition Document contains new security
mandates for devices, dictating that those that are capable of accessing encrypted data without
affecting performance must enable secure boot and device encryption by default. These
conditions comprise part of a specification that must be met in order to be certified for the
operating system, and be able to license Google Mobile Services software. The requirement for
mandatory device encryption was originally intended to take effect on Lollipop, but was delayed
due to performance issues.
Applications
Applications ("apps"), which extend the functionality of devices, are written using the Android
software development kit (SDK) and, often, the Java programming language. Java may be
combined with C/C++, together with a choice of non-default runtimes that allow better C++
support. The Go programming language is also supported, although with a limited set of
application programming interfaces (API).In May 2017, Google announced support for Android
app development in the Kotlin programming language.
The SDK includes a comprehensive set of development tools, including a debugger, software
libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials.
Initially, Google's supported integrated development environment (IDE) was Eclipse using the
Android Development Tools (ADT) plugin; in December 2014, Google released Android Studio,
based on IntelliJ IDEA, as its primary IDE for Android application development. Other
development tools are available, including a native development kit (NDK) for applications or
extensions in C or C++, Google App Inventor, a visual environment for novice programmers,
and various cross platform mobile web applications frameworks. In January 2014, Google
unveiled an framework based on Apache Cordova for porting Chrome HTML 5 web applications
to Android, wrapped in a native application shell.
Android has a growing selection of third-party applications, which can be acquired by users by
downloading and installing the application's APK (Android application package) file, or by
downloading them using an application store program that allows users to install, update, and
remove applications from their devices. Google Play Store is the primary application store
installed on Android devices that comply with Google's compatibility requirements and license
the Google Mobile Services software. Google Play Store allows users to browse, download and
update applications published by Google and third-party developers; as of July 2013, there are
more than one million applications available for Android in Play Store. As of July 2013, 50
billion applications have been installed. Some carriers offer direct carrier billing for Google Play
application purchases, where the cost of the application is added to the user's monthly bill. As of
May 2017, there are over one billion active users a month for Gmail, Android, Chrome, Google
Play and Maps.
Due to the open nature of Android, a number of third-party application marketplaces also exist
for Android, either to provide a substitute for devices that are not allowed to ship with Google
Play Store, provide applications that cannot be offered on Google Play Store due to policy
violations, or for other reasons. Examples of these third-party stores have included the Amazon
Appstore, GetJar, and SlideMe. F-Droid, another alternative marketplace, seeks to only provide
applications that are distributed under free and open source licenses.
Memory management
Since Android devices are usually battery-powered, Android is designed to manage processes to
keep power consumption at a minimum. When an application is not in use the system suspends
its operation so that, while available for immediate use rather than closed, it does not use battery
power or CPU resources. Android manages the applications stored in memory automatically:
when memory is low, the system will begin invisibly and automatically closing inactive
processes, starting with those that have been inactive for longest. Lifehacker reported in 2011
that third-party task killers were doing more harm than good.

Hardware
The main hardware platform for Android is the ARM (ARMv7 and ARMv8-A architectures),
with x86, MIPS and MIPS64, and x86-64 architectures also officially supported in later versions
of Android. The unofficial Android-x86 project provided support for the x86 architectures ahead
of the official support. MIPS architecture was also supported before Google did. Since 2012,
Android devices with Intel processors began to appear, including phones and tablets. While
gaining support for 64-bit platforms, Android was first made to run on 64-bit x86 and then on
ARM64. Since Android 5.0 "Lollipop", 64-bit variants of all platforms are supported in addition
to the 32-bit variants.
Requirements for the minimum amount of RAM for devices running Android 7.1 range from in
practice 2 GB for best hardware, down to 1 GB for the most common screen, to absolute
minimum 512 MB for lowest spec 32-bit smartphone. The recommendation for Android 4.4 is to
have at least 512 MB of RAM, while for "low RAM" devices 340 MB is the required minimum
amount that does not include memory dedicated to various hardware components such as the
baseband processor. Android 4.4 requires a 32-bit ARMv7, MIPS or x86 architecture processor
(latter two through unofficial ports), together with an OpenGL ES 2.0 compatible graphics
processing unit (GPU). Android supports OpenGL ES 1.1, 2.0, 3.0, 3.1 and as of latest major
version, 3.2 and Vulkan. Some applications may explicitly require a certain version of the
OpenGL ES, and suitable GPU hardware is required to run such applications.
Android devices incorporate many optional hardware components, including still or video
cameras, GPS, orientation sensors, dedicated gaming controls, accelerometers, gyroscopes,
barometers, magnetometers, proximity sensors, pressure sensors, thermometers, and
touchscreens. Some hardware components are not required, but became standard in certain
classes of devices, such as smartphones, and additional requirements apply if they are present.
Some other hardware was initially required, but those requirements have been relaxed or
eliminated altogether. For example, as Android was developed initially as a phone OS, hardware
such as microphones were required, while over time the phone function became optional.
Android used to require an autofocus camera, which was relaxed to a fixed-focus camera if
present at all, since the camera was dropped as a requirement entirely when Android started to be
used on set-top boxes.
In addition to running on smartphones and tablets, several vendors run Android natively on
regular PC hardware with a keyboard and mouse. In addition to their availability on
commercially available hardware, similar PC hardware-friendly versions of Android are freely
available from the Android-x86 project, including customized Android 4.4 Using the Android
emulator that is part of the Android SDK, or third-party emulators, Android can also run non-
natively on x86 architectures. Chinese companies are building a PC and mobile operating
system, based on Android, to "compete directly with Microsoft Windows and Google Android".
The Chinese Academy of Engineering noted that "more than a dozen" companies were
customizing Android following a Chinese ban on the use of Windows 8 on government PCs.
Other uses
Google has developed several variations of Android for specific use cases, including Android
Wear for wearable devices such as wrist watches, Android TV for televisions, and Android
Things for smart devices and Internet of things. Additionally, by providing infrastructure that
combines dedicated hardware and dedicated applications running on regular Android, Google
have opened up the platform for its use in particular usage scenarios, such as Android Auto for
cars, and Daydream, a Virtual Reality platform.
The open and customizable nature of Android allows device makers to use it on other electronics
as well, including laptops, netbooks, and desktop computers, cameras, headphones, home
automation systems, game consoles, media players, satellites, routers, printers, payment
terminals, automated teller machines, and robots. Additionally, Android has been installed and
run on a variety of less-technical objects, including calculators, single-board computers, feature
phones, electronic dictionaries, alarm clocks, refrigerators, landline telephones,coffee
machines,bicycles, and mirrors.
Ouya, a video game console running Android, became one of the most successful Kickstarter
campaigns, crowdfunding US$8.5m for its development, and was later followed by other
Android-based consoles, such as Nvidia's Shield Portable – an Android device in a video game
controller form factor.
In 2011, Google demonstrated "Android@Home", a home automation technology which uses
Android to control a range of household devices including light switches, power sockets and
thermostats. Prototype light bulbs were announced that could be controlled from an Android
phone or tablet, but Android head Andy Rubin was cautious to note that "turning a lightbulb on
and off is nothing new", pointing to numerous failed home automation services. Google, he said,
was thinking more ambitiously and the intention was to use their position as a cloud services
provider to bring Google products into customers' homes.
Parrot unveiled an Android-based car stereo system known as Asteroid in 2011, followed by a
successor, the touchscreen-based Asteroid Smart, in 2012. In 2013, Clarion released its own
Android-based car stereo, the AX1. In January 2014, at the Consumer Electronics Show (CES),
Google announced the formation of the Open Automotive Alliance, a group including several
major automobile makers (Audi, General Motors, Hyundai, and Honda) and Nvidia, which aims
to produce Android-based in-car entertainment systems for automobiles, "[bringing] the best of
Android into the automobile in a safe and seamless way."
Android comes preinstalled on a few laptops (a similar functionality of running Android
applications is also available in Google's Chrome OS) and can also be installed on personal
computers by end users. On those platforms Android provides additional functionality for
physical keyboards and mice, together with the "Alt-Tab" key combination for switching
applications quickly with a keyboard. In December 2014, one reviewer commented that
Android's notification system is "vastly more complete and robust than in most environments"
and that Android is "absolutely usable" as one's primary desktop operating system.
In October 2015, The Wall Street Journal reported that Android will serve as Google's future
main laptop operating system, with the plan to fold Chrome OS into it by 2017. Google's Sundar
Pichai, who led the development of Android, explained that "mobile as a computing paradigm is
eventually going to blend with what we think of as desktop today." Also, back in 2009, Google
co-founder Sergey Brin himself said that Chrome OS and Android would "likely converge over
time." Lockheimer, who replaced Pichai as head of Android and Chrome OS, responded to this
claim with an official Google blog post stating that "While we've been working on ways to bring
together the best of both operating systems, there's no plan to phase out Chrome OS [which has]
guaranteed auto-updates for five years". That is unlike Android where support is shorter with
"EOL dates [being..] at least 3 years [into the future] for Android tablets for education".
At Google I/O on May 2016, Google announced Daydream, a virtual reality platform that relies
on a smartphone and provides VR capabilities through a virtual reality headset and controller
designed by Google itself. The platform is built into Android starting with Android Nougat,
differentiating from standalone support for VR capabilities. The software is available for
developers, and was released in 2016.

.
CHAPTER - 3

SYSTEM DESIGN AND DEVELOPMENT

3.1 DESCRIPTION OF MODULES

 Image capturing module


 Image pre-processing
1) RGB to Grayscale
2) BITMAP Extraction
3) Histogram equalization
4) Edge selection
5) Defect cropping and prescription module
 Growth predictive analysis module

Report generation module

3.2 MODULE DESCRIPTION:


Image acquisition:
In this research, the weed and crop color images are acquired through the digital camera. The sample
images are captured in the fields. Images are obtained at different times of a day. Moreover, weeds and
crop with varying canopy size were selected to increase the difficulty of the classification problem. The
weed and crop images are taken at an angle 45 degree with the ground in natural lighting conditions with
digital camera. The camera is mounted in the height of 2.15m from the ground. The resolution of the
camera is set to 3648×2736 pixels during image capturing. In the experimental analysis, all the images
were resized to a resolution of 320×240 pixels in order to reduce the computation time [10]. Fig-2
illustrates sample weed and crop images taken from the fields.
RGB to Grayscale:

The gray transformation processing is to turn the color image to the gray image. The purpose of gray
transformation is to reduce the amount of color data in the image so as to speed up the following
processing. The color difference between plants and background in the color images should be kept as
well as possible in the gray image.

Grayscale image is an image that each pixel holds a single sample, only intensity information,
also known as black-and-white image.

What is GRAYSCALE? Why GRAYSCALE?

In photography, computing, and colorimetric, a grayscale or grayscale image is one in which the


value of each pixel is a single sample representing only an amount of light, that is, it carries
only intensity information. Images of this sort, also known as black-and-white or monochrome,
are composed exclusively of shades of gray, varying from black at the weakest intensity to white
at the strongest. Grayscale images are distinct from one-bit bi-tonal black-and-white images,
which in the context of computer imaging are images with only two colors, black and white (also
called bi-level or binary images). Grayscale images have many shades of gray in between.

Grayscale images can be the result of measuring the intensity of light at each pixel according to a
particular weighted combination of frequencies (or wavelengths), and in such cases they
are monochromatic proper when only a single frequency (in practice, a narrow band of
frequencies) is captured. The frequencies can in principle be from anywhere in
the electromagnetic spectrum (e.g. infrared, visible light, ultraviolet, etc.).

A colorimetric (or more specifically photometric) grayscale image is an image that has a defined


grayscale color space, which maps the stored numeric sample values to the achromatic channel
of a standard color space, which itself is based on measured properties of human vision.

If the original color image has no defined color space, or if the grayscale image is not intended to
have the same human-perceived achromatic intensity as the color image, then there is no unique
mapping from such a color image to a grayscale image.

Colorimetric (perceptual luminance-preserving) conversion to grayscale

A common strategy is to use the principles of photometry or, more broadly, colorimetric to


calculate the grayscale values (in the target grayscale color space) so as to have the same
luminance (technically relative luminance) as the original color image (according to its color
space). In addition to the same (relative) luminance, this method also ensures that both images
will have the same absolute luminance when displayed, as can be measured by instruments in
its SI units of candelas per square meter, in any given area of the image, given equal white
points. Luminance itself is defined using a standard model of human vision, so preserving the
luminance in the grayscale image also preserves other perceptual lightness measures, such
as L* which is determined by the linear luminance Y itself which we will refer to here as Ylinear to
avoid any ambiguity.

To convert a color from a color space based on a typical gamma-compressed (nonlinear) RGB


color model to a grayscale representation of its luminance, the gamma compression function
must first be removed via gamma expansion (linearization) to transform the image to a linear
RGB color space, so that the appropriate weighted sum can be applied to the linear color to
calculate the linear luminance Ylinear, which can then be gamma-compressed back again if the
grayscale result is also to be encoded and stored in a typical nonlinear colorspace.

For the common sRGB color space, gamma expansion is defined as

where Csrgb represents any of the three gamma-compressed sRGB primaries (Rsrgb, Gsrgb,


and Bsrgb, each in range [0,1]) and Clinear is the corresponding linear-intensity value
(Rlinear, Glinear, and Blinear, also in range [0,1]). Then, linear luminance is calculated as a
weighted sum of the three linear-intensity values.

Naive Bayes classifiers, a family of classifiers that are based on the popular Bayes’ probability
theorem, are known for creating simple yet well performing models, especially in the fields of
document classification and disease prediction.
In this first part of a series, we will take a look at the theory of naive Bayes classifiers and
introduce the basic concepts of text classification.

Introduction

Starting more than half a century ago, scientists became very serious about addressing the
question: “Can we build a model that learns from available data and automatically makes the
right decisions and predictions?” Looking back, this sounds almost like a rhetoric question, and
the answer can be found in numerous applications that are emerging from the fields of pattern
classification, machine learning, and artificial intelligence.

Data from various censoring devices combined with powerful learning algorithms and domain
knowledge led to many great inventions that we now take for granted in our everyday life:
Internet queries via search engines like Google, text recognition at the post office, barcode
scanners at the supermarket, the diagnosis of diseases, speech recognition by Siri or Google Now
on our mobile phone, just to name a few.

One of the sub-fields of predictive modeling is supervised pattern classification; supervised


pattern classification is the task of training a model based on labeled training data which then can
be used to assign a pre-defined class label to new objects. One example that we will explore
throughout this article is spam filtering via naive Bayes classifiers in order to predict whether a
new text message can be categorized as spam or not-spam. Naive Bayes classifiers, a family of
classifiers that are based on the popular Bayes’ probability theorem, are known for creating
simple yet well performing models, especially in the fields of document classification and
disease predictio
Figure 1.

Naive Bayes Classification

Naive Bayes classifiers are linear classifiers that are known for being simple yet very efficient.
The probabilistic model of naive Bayes classifiers is based on Bayes’ theorem, and the
adjective naive comes from the assumption that the features in a dataset are mutually
independent. In practice, the independence assumption is often violated, but naive Bayes
classifiers still tend to perform very well under this unrealistic assumption [1]. Especially for
small sample sizes, naive Bayes classifiers can outperform the more powerful alternatives [2].

Being relatively robust, easy to implement, fast, and accurate, naive Bayes classifiers are used in
many different fields. Some examples include the diagnosis of diseases and making decisions
about treatment processes [3], the classification of RNA sequences in taxonomic studies [4], and
spam filtering in e-mail clients [5].
However, strong violations of the independence assumptions and non-linear classification
problems can lead to very poor performances of naive Bayes classifiers.
We have to keep in mind that the type of data and the type problem to be solved dictate which
classification model we want to choose. In practice, it is always recommended to compare
different classification models on the particular dataset and consider the prediction performances
as well as computational efficiency.

In the following sections, we will take a closer look at the probability model of the naive Bayes
classifier and apply the concept to a simple toy problem. Later, we will use a publicly available
SMS (text message) collection to train a naive Bayes classifier in Python that allows us to
classify unseen messages as spam or ham.

Figure 2. Linear (A) vs. non-linear problems (B). Random samples for two different classes are
shown as colored spheres, and the dotted lines indicate the class boundaries that classifiers try to
approximate by computing the decision boundaries. A non-linear problem (B) would be a case
where linear classifiers, such as naive Bayes, would not be suitable since the classes are not
linearly separable. In such a scenario, non-linear classifiers (e.g., instance-based nearest neighbor
classifiers) should be preferred.
Posterior Probabilities

In order to understand how naive Bayes classifiers work, we have to briefly recapitulate the
concept of Bayes’ rule. The probability model that was formulated by Thomas Bayes (1701-
1761) is quite simple yet powerful; it can be written down in simple words as follows:

posterior probability=conditional probability prior probability evidence posterior


probability=conditional probability ⋅prior probability evidence

Bayes’ theorem forms the core of the whole concept of naive Bayes classification. The posterior
probability, in the context of a classification problem, can be interpreted as: “What is the
probability that a particular object belongs to class ii given its observed feature values?” A more
concrete example would be: “What is the probability that a person has diabetes given a certain
value for a pre-breakfast blood glucose measurement and a certain value for a post-breakfast
blood glucose measurement?”
P(diabetes∣xi),xi=[90mg/dl,145mg/dl]P(diabetes∣xi),xi=[90mg/dl,145mg/dl]

Let

 xixi be the feature vector of sample i,i∈{1,2,...,n}i,i∈{1,2,...,n},


 ωjωj be the notation of class j,j∈{1,2,...,m}j,j∈{1,2,...,m},
 and P(xi∣ωj)P(xi∣ωj) be the probability of observing sample xixi given that is belongs to
class ωjωj.

The general notation of the posterior probability can be written as

P(ωj∣xi)=P(xi∣ωj)⋅P(ωj)P(xi)P(ωj∣xi)=P(xi∣ωj)⋅P(ωj)P(xi)

The objective function in the naive Bayes probability is to maximize the posterior probability
given the training data in order to formulate the decision rule.

To continue with our example above, we can formulate the decision rule based on the posterior
probabilities as follows:
person has diabetes ifP(diabetes∣xi)≥P(not-diabetes∣xi),else classify person as healthy.person has
diabetes ifP(diabetes∣xi)≥P(not-diabetes∣xi),else classify person as healthy.

Class-conditional Probabilities

One assumption that Bayes classifiers make is that the samples are i.i.d.
The abbreviation i.i.d. stands for “independent and identically distributed” and describes random
variables that are independent from one another and are drawn from a similar probability
distribution. Independence means that the probability of one observation does not affect the
probability of another observation (e.g., time series and network graphs are not independent).
One popular example of i.i.d. variables is the classic coin tossing: The first coin flip does not
affect the outcome of a second coin flip and so forth. Given a fair coin, the probability of the
coin landing on “heads” is always 0.5 no matter of how often the coin if flipped.

An additional assumption of naive Bayes classifiers is the conditional independence of features.


Under this naive assumption, the class-conditional probabilities or (likelihoods) of the samples
can be directly estimated from the training data instead of evaluating all possibilities of xx. Thus,
given a dd-dimensional feature vector xx, the class conditional probability can be calculated as
follows:
P(x∣ωj)=P(x1∣ωj)⋅P(x2∣ωj)⋅…⋅P(xd∣ωj)=∏k=1dP(xk∣ωj)P(x∣ωj)=P(x1∣ωj)⋅P(x2∣ωj)⋅…
⋅P(xd∣ωj)=∏k=1dP(xk∣ωj)

Here, P(x∣ωj)P(x∣ωj) simply means: “How likely is it to observe this particular pattern xx given


that it belongs to class ωjωj?” The “individual” likelihoods for every feature in the feature vector
can be estimated via the maximum-likelihood estimate, which is simply a frequency in the case
of categorical data:
P^(xi∣ωj)=Nxi,ωjNωj(i=(1,...,d))P^(xi∣ωj)=Nxi,ωjNωj(i=(1,...,d))

 Nxi,ωjNxi,ωj: Number of times feature xixi appears in samples from class ωjωj.


 NωjNωj: Total count of all features in class ωjωj.

To illustrate this concept with an example, let’s assume that we have a collection of 500
documents where 100 documents are spam messages. Now, we want to calculate the class-
conditional probability for a new message “Hello World” given that it is spam. Here, the pattern
consists of two features: “hello” and “world,” and the class-conditional probability is the product
of the “probability of encountering ‘hello’ given the message is spam” — the probability of
encountering “world” given the message is spam.”

P(x=[hello,world]∣ω=spam)=P(hello∣spam)⋅P(world∣spam)P(x=[hello,
world]∣ω=spam)=P(hello∣spam)⋅P(world∣spam)

Using the training dataset of 500 documents, we can use the maximum-likelihood estimate to
estimate those probabilities: We’d simply calculate how often the words occur in the corpus of
all spam messages. E.g.,

P^(x=[hello,world]∣ω=spam)=20100⋅2100=0.004P^(x=[hello,
world]∣ω=spam)=20100⋅2100=0.004

However, with respect to the naive assumption of conditional independence, we notice a problem


here: The naive assumption is that a particular word does not influence the chance of
encountering other words in the same document. For example, given the two words “peanut” and
“butter” in a text document, intuition tells us that this assumption is obviously violated: If a
document contains the word “peanut” it will be more likely that it also contains the word “butter”
(or “allergy”). In practice, the conditional independence assumption is indeed often violated, but
naive Bayes classifiers are known to perform still well in those cases [6].

Prior Probabilities

In contrast to a frequentist’s approach, an additional prior probability (or just prior) is introduced


that can be interpreted as the prior belief or a priori knowledge.

posterior probability=conditional probability prior probability evidence posterior


probability=conditional probability prior probability evidence

In the context of pattern classification, the prior probabilities are also called class priors, which
describe “the general probability of encountering a particular class.” In the case of spam
classification, the priors could be formulated as
P(spam)="the probability that any new message is a spam message "P(spam)="the probability
that any new message is a spam message" and
P(ham)=1−P(spam).P(ham)=1−P(spam).

If the priors are following a uniform distribution, the posterior probabilities will be entirely
determined by the class-conditional probabilities and the evidence term. And since the evidence
term is a constant, the decision rule will entirely depend on the class-conditional probabilities
(similar to a frequentist’s approach and maximum-likelihood estimate).

Eventually, the a priori knowledge can be obtained, e.g., by consulting a domain expert or by


estimation from the training data (assuming that the training data is i.i.d. and a representative
sample of the entire population. The maximum-likelihood estimate approach can be formulated
as

P^(ωj)=NωjNcP^(ωj)=NωjNc

 NωjNωj: Count of samples from class ωjωj.


 NcNc: Count of all samples.

And in context of spam classification:

P^(spam)=# of spam messages in training data # of all messages in training dataP^(spam)=# of


spam messages in training data # of all messages in training data

Figure 3 illustrates the effect of the prior probabilities on the decision rule. Given an 1-
dimensional pattern xx (continuous attribute, plotted as “x” symbols) that follows a normal
distribution and belongs to one out of two classes (blue and green). The patterns from the first
class (ω1=blueω1=blue) are drawn from a normal distribution with mean x=4x=4 and a standard
deviation σ=1σ=1. The probability distribution of the second class (ω2=greenω2=green) is
centered at x=10 with a similar standard deviation of σ=1σ=1. The bell-curves denote the
probability densities of the samples that were drawn from the two different normal distributions.
Considering only the class conditional probabilities, the maximum-likelihood estimate in this
case would be
P(x=4∣ω1)≈0.4 and P(x=10∣ω1)<0.001P(x=4∣ω2)<0.001 and P(x=10∣ω2)≈0.4.P(x=4∣ω1)≈0.4 an
d P(x=10∣ω1)<0.001P(x=4∣ω2)<0.001 and P(x=10∣ω2)≈0.4.

Now, given uniform priors, that is P(ω1)=P(ω2)=0.5P(ω1)=P(ω2)=0.5, the decision rule would
be entirely dependent on those class-conditional probabilities, so that the decision rule would fall
directly between the two distributions
P(x∣ω1)=P(x∣ω2).P(x∣ω1)=P(x∣ω2).

However, if the prior probability was P(ω1)>0.5P(ω1)>0.5, the decision region of


class ω1ω1 would expand as shown in Figure 3. In the context of spam classification, this could
be interpreted as encountering a new message that only contains words which are equally likely
to appear in spam or ham messages. In this case, the decision would be entirely dependent
on prior knowledge, e.g., we could assume that a random message is in 9 out of 10 cases
not spam and therefore classify the new message as ham.
Figure 3. The effect of prior probabilities on the decision regions. The figure shows an 1-
dimensional random sample from two different classes (blue and green crosses). The data points
of both the blue and the green class are normally distributed with standard deviation 1, and the
bell curves denote the class-conditional probabilities. If the class priors are equal, the decision
boundary of a naive Bayes classifier is placed at the center between both distributions (gray bar).
An increase of the prior probability of the blue class (ω1ω1) leads to an extension of the decision
region R1 by moving the decision boundary (blue-dotted bar) towards the other class and vice
versa.
Evidence

After defining the class-conditional probability and prior probability, there is only one term


missing in order to compute posterior probability, that is the evidence.

posterior probability=conditional probability prior probability evidence posterior


probability=conditional probability prior probability evidence

The evidence P(x)P(x) can be understood as the probability of encountering a particular


pattern xxin dependent from the class label. Given the more formal definition of posterior
probability
P(ωj∣xi)=P(xi∣ωj)⋅P(ωj)P(xi),P(ωj∣xi)=P(xi∣ωj)⋅P(ωj)P(xi),

the evidence can be calculated as follows (ωCjωjC stands for “complement” and basically
translates to “not class ωjnot class ωj.” ):
P(xi)=P(xi∣ωj)⋅P(ωj)+P(xi∣ωCj)⋅P(ωCj)P(xi)=P(xi∣ωj)⋅P(ωj)+P(xi∣ωjC)⋅P(ωjC)

Although the evidence term is required to accurately calculate the posterior probabilities, it can
be removed from the decision rule “Classify
sample xixi as ω1ω1 if P(ω1∣xi)>P(ω2∣xi)P(ω1∣xi)>P(ω2∣xi) else classify the sample as ω2ω2,”
since it is merely a scaling factor:
P(xi∣ω1)⋅P(ω1)P(xi)>P(xi∣ω2)⋅P(ω2)P(xi)P(xi∣ω1)⋅P(ω1)P(xi)>P(xi∣ω2)⋅P(ω2)P(xi)

∝P(xi∣ω1)⋅P(ω1)>P(xi∣ω2)⋅P(ω2)∝P(xi∣ω1)⋅P(ω1)>P(xi∣ω2)⋅P(ω2)

Multinomial Naive Bayes - A Toy Example

After covering the basics concepts of a naive Bayes classifier, the posterior


probabilities and decision rules, let us walk through a simple toy example based on the training
set shown in Figure 4.
Figure 4. A simple toy dataset of 12 samples 2 different classes +,−+,− . Each sample consists of
2 features: color and geometrical shape.
Let

 ωjωj be the class labels: ωj∈{+,−}ωj∈{+,−}


 and xixi be the 2-dimensional feature
vectors: xi=[xi1xi2],xi1∈{blue,green,red,yellow},xi2∈{circle,square}.xi=[xi1xi2],xi1∈{blu
e,green,red,yellow},xi2∈{circle,square}.

The 2 class labels are ωj∈{+,−}ωj∈{+,−} and the feature vector for sample ii can be written as
xi=[xi1xi2]for i∈{1,2,...,n}, with n=12and xi1∈{blue,green,red,yellow},xi2∈{circle,square}xi=[
xi1xi2]for i∈{1,2,...,n}, with n=12and xi1∈{blue,green,red,yellow},xi2∈{circle,square}

The task now is to classify a new sample — pretending that we don’t know that its true class
label is “+”:

Figure 5. A new sample from class ++ and the features x=[blue, square]x=[blue, square] that is
to be classified using the training data in Figure 4.
Maximum-Likelihood Estimates

The decision rule can be defined as

Classify sample as + ifP(ω=+∣x=[blue, square])≥P(ω=-∣x=[blue, square])else classify sample


as−.Classify sample as + ifP(ω=+∣x=[blue, square])≥P(ω=-∣x=[blue, square])else classify sample
as−.

Under the assumption that the samples are i.i.d, the prior probabilities can be obtained via the
maximum-likelihood estimate (i.e., the frequencies of how often each class label is represented
in the training dataset):

P(+)=712=0.58P(-)=512=0.42P(+)=712=0.58P(-)=512=0.42

Under the naive assumption that the features “color” and “shape” are mutually independent,
the class-conditional probabilities can be calculated as a simple product of the individual
conditional probabilities.

Via maximum-likelihood estimate, e.g., P(blue∣−)P(blue∣−) is simply the frequency of observing


a “blue” sample among all samples in the training dataset that belong to class −−.
P(x∣+)=P(blue∣+)⋅P(square∣+)=37⋅57=0.31P(x∣−)=P(blue∣−)⋅P(square∣−)=35⋅35=0.36P(x∣+)=P(b
lue∣+)⋅P(square∣+)=37⋅57=0.31P(x∣−)=P(blue∣−)⋅P(square∣−)=35⋅35=0.36

Now, the posterior probabilities can be simply calculated as the product of the class-conditional


and prior probabilities:

P(+∣x)=P(x∣+)⋅P(+)=0.31⋅0.58=0.18P(−∣x)=P(x∣−)⋅P(−)=0.36⋅0.42=0.15P(+∣x)=P(x∣+)⋅P(+)=0.3
1⋅0.58=0.18P(−∣x)=P(x∣−)⋅P(−)=0.36⋅0.42=0.15

Classification

Putting it all together, the new sample can be classified by plugging in the posterior probabilities
into the decision rule:

If P(+∣x)≥P(-∣x)classify as +,else classify as −If P(+∣x)≥P(-∣x)classify as +,else classify as −


Since 0.18>0.150.18>0.15 the sample can be classified as ++. Taking a closer look at the
calculation of the posterior probabilities, this simple example demonstrates the effect of the prior
probabilities affected on the decision rule. If the prior probabilities were equal for both classes,
the new pattern would be classified as −− instead of ++. This observation also underlines the
importance of representative training datasets; in practice, it is usually recommended to
additionally consult a domain expert in order to define the prior probabilities.
Additive Smoothing

The classification was straight-forward given the sample in Figure 5. A trickier case is a sample
that has a “new” value for the color attribute that is not present in the training dataset,
e.g., yellow, as shown in Figure 6.

Figure 6. A new sample from class ++ and the features x=[yellow, square]x=[yellow,


square] that is to be classified using the training data in Figure 4
If the color yellow does not appear in our training dataset, the class-conditional probability will
be 0, and as a consequence, the posterior probability will also be 0 since the posterior probability
is the product of the prior and class-conditional probabilities.

P(ω1∣x)=0⋅0.42=0P(ω2∣x)=0⋅0.58=0P(ω1∣x)=0⋅0.42=0P(ω2∣x)=0⋅0.58=0

In order to avoid the problem of zero probabilities, an additional smoothing term can be added to
the multinomial Bayes model. The most common variants of additive smoothing are the so-
called Lidstone smoothing (α<1α<1) and Laplace smoothing (α=1α=1).
P^(xi∣ωj)=Nxi,ωj+αNωj+αd(i=(1,...,d))P^(xi∣ωj)=Nxi,ωj+αNωj+αd(i=(1,...,d))

where

 Nxi,ωjNxi,ωj: Number of times feature xixi appears in samples from class ωjωj.


 NωjNωj: Total count of all features in class ωjωj.
 αα: Parameter for additive smoothing.
 dd: Dimensionality of the feature vector x=[x1,...,xd]x=[x1,...,xd].

Naive Bayes and Text Classification

This section will introduce some of the main concepts and procedures that are needed to apply
the naive Bayes model to text classification tasks. Although the examples are mainly concerning
a two-class problem — classifying text messages as spam or ham — the same approaches are
applicable to multi-class problems such as classification of documents into different topic areas
(e.g., “Computer Science”, “Biology”, “Statistics”, “Economics”, “Politics”, etc.).

The Bag of Words Model

One of the most important sub-tasks in pattern classification are feature extraction and selection;


the three main criteria of good features are listed below:

 Salient. The features are important and meaningful with respect to the problem domain.
 Invariant. Invariance is often described in context of image classification: The features
are insusceptible to distortion, scaling, orientation, etc. A nice example is given by C.
Yao and others in Rotation-Invariant Features for Multi-Oriented Text Detection in Natural
Images [7].
 Discriminatory. The selected features bear enough information to distinguish well
between patterns when used to train the classifier.

Prior to fitting the model and using machine learning algorithms for training, we need to think
about how to best represent a text document as a feature vector. A commonly used model
in Natural Language Processing is the so-called bag of words model. The idea behind this model
really is as simple as it sounds. First comes the creation of the vocabulary — the collection of all
different words that occur in the training set and each word is associated with a count of how it
occurs. This vocabulary can be understood as a set of non-redundant items where the order
doesn’t matter. Let D1D1 and D2D2 be two documents in a training dataset:

 D1D1: “Each state has its own laws.”


 D2D2: “Every country has its own culture.”
Based on these two documents, the vocabulary could be written as \

V={each:1,state:1,has:2,its:2,own:2,laws:1,every:1,country:1,culture:1}V={each:1,state:1,has:2,i
ts:2,own:2,laws:1,every:1,country:1,culture:1}

The vocabulary can then be used to construct the dd-dimensional feature vectors for the
individual documents where the dimensionality is equal to the number of different words in the
vocabulary (d=|V|d=|V|). This process is called vectorization.
Table 1. Bag of words representation of two sample documents D1D1 and D2D2.
  each state Has its own laws every country culture

xD1xD1 1 1 1 1 1 1 0 0 0

xD2xD2 0 0 1 1 1 0 1 1 1

ΣΣ 1 1 2 2 2 1 1 1 1

Given the example in Table 1 one question is whether the 1s and 0s of the feature vectors are
binary counts (1 if the word occurs in a particular document, 0 otherwise) or absolute counts
(how often the word occurs in each document). The answer depends on which probabilistic
model is used for the naive Bayes classifier: The Multinomial or Bernoulli model — more on the
probabilistic models in Section Multi-variety Bernoulli Naive Bayes and Section Multinomial
Naive Bayes.

Tokenization

Tokenization describes the general process of breaking down a text corpus into individual
elements that serve as input for various natural language processing algorithms. Usually,
tokenization is accompanied by other optional processing steps, such as the removal of stop
words and punctuation characters, stemming or lemmatizing, and the construction of n-grams.
Below is an example of a simple but typical tokenization step that splits a sentence into
individual words, removes punctuation, and converts all letters to lowercase.

Table 2. Example of tokenization.


Stop Words

Stop words are words that are particularly common in a text corpus and thus considered as rather
un-informative (e.g., words such as so, and, or, the,”). One approach to stop word removal is to
search against a language-specific stop word dictionary. An alternative approach is to create
a stop list by sorting all words in the entire text corpus by frequency. The stop list — after
conversion into a set of non-redundant words — is then used to remove all those words from the
input documents that are ranked among the top n words in this stop list.

Table 3. Example of stop word removal.

Stemming and Lemmatization

Stemming describes the process of transforming a word into its root form. The original stemming
algorithm was developed my Martin F. Porter in 1979 and is hence known as Porter stemmer [8].

Table 4. Example of Porter Stemming.

Stemming can create non-real words, such as “thu” in the example above. In contrast to
stemming, lemmatization aims to obtain the canonical (grammatically correct) forms of the
words, the so-called lemmas. Lemmatization is computationally more difficult and expensive
than stemming, and in practice, both stemming and lemmatization have little impact on the
performance of text classification [9].
Table 4. Example of Lemmatization.

(The stemming and lemmatization examples were created by using the Python NLTK
library, http://www.nltk.org.)

N-Grams

In the n-gram model, a token can be defined as a sequence of n items. The simplest case is the
so-called unigram (1-gram) where each word consists of exactly one word, letter, or symbol. All
previous examples were unigrams so far. Choosing the optimal number n depends on the
language as well as the particular application. For example, Andelka Zecevic found in his study
that n-grams with 3≤n≤73≤n≤7were the best choice to determine authorship of Serbian text
documents [10]. In a different study, the n-grams of size 4≤n≤84≤n≤8 yielded the highest
accuracy in authorship determination of English text books 11] and Kanaris and others report
that n-grams of size 3 and 4 yield good performances in anti-spam filtering of e-mail messages
[12].

The Decision Rule for Spam Classification

In context of spam classification the decision rule of a naive Bayes classifier based on the
posterior probabilities can be expressed as

if P(ω=spam∣x)≥P(ω=ham∣x) classify as spam, else classify as


ham. if P(ω=spam∣x)≥P(ω=ham∣x) classify as spam, else classify as ham. 
As described in Section Posterior Probabilities the posterior probability is the product of the
class-conditional probability and the prior probability; the evidence term in the denominator can
be dropped since it is constant for both classes.

P(ω=spam∣x)=P(x∣ω=spam)⋅P(spam)P(ω=ham∣x)=P(x∣ω=ham)⋅P(ham)P(ω=spam∣x)=P(x∣ω=spa
m)⋅P(spam)P(ω=ham∣x)=P(x∣ω=ham)⋅P(ham)

The prior probabilities can be obtained via the maximum-likelihood estimate based on the
frequencies of spam and ham messages in the training dataset:

P^(ω=spam)=# of spam msg.# of all msg.P^(ω=ham)=# of ham msg.# of all msg.P^(ω=spam)=#


of spam msg.# of all msg.P^(ω=ham)=# of ham msg.# of all msg.

Assuming that the words in every document are conditionally independent (according to
the naiveassumption), two different models can be used to compute the class-conditional
probabilities: The Multi-variate Bernoulli model and the Multinomial model.

Multi-variate Bernoulli Naive Bayes

The Multi-variate Bernoulli model is based on binary data: Every token in the feature vector of a
document is associated with the value 1 or 0. The feature vector has mm dimensions
where mm is the number of words in the whole vocabulary (in Section The Bag of Words
Model; the value 1 means that the word occurs in the particular document, and 0 means that the
word does not occur in this document. The Bernoulli trials can be written as
P(x∣ωj)=∏i=1mP(xi∣ωj)b⋅(1−P(xi∣ωj))(1−b)(b∈0,1).P(x∣ωj)=∏i=1mP(xi∣ωj)b⋅(1−P(xi∣ωj))(1−b)
(b∈0,1).

Let P^(xi∣ωj)P^(xi∣ωj) be the maximum-likelihood estimate that a particular word (or


token) xixi occurs in class ωjωj.
P^(xi∣ωj)=dfxi,y+1dfy+2P^(xi∣ωj)=dfxi,y+1dfy+2

where

 dfxi,ydfxi,y is the number of documents in the training dataset that contain the
feature xixi and belong to class ωjωj.
 dfydfy is the number of documents in the training dataset that belong to class ωjωj.
 +1 and +2 are the parameters of Laplace smoothing (Section Additive Smoothing).

Multinomial Naive Bayes

Term Frequency

A alternative approach to characterize text documents — rather than binary values — is the term
frequency (tf(t, d)). The term frequency is typically defined as the number of times a given
term t (i.e., word or token) appears in a document d (this approach is sometimes also called raw
frequency). In practice, the term frequency is often normalized by dividing the raw term
frequency by the document length.

normalized term frequency=tf(t,d)ndnormalized term frequency=tf(t,d)nd

where

 tf(t,d)tf(t,d): Raw term frequency (the count of term tt in document dd).


 ndnd: The total number of terms in document dd.

The term frequencies can then be used to compute the maximum-likelihood estimate based on
the training data to estimate the class-conditional probabilities in the multinomial model:

P^(xi∣ωj)=∑tf(xi,d∈ωj)+α∑Nd∈ωj+α⋅VP^(xi∣ωj)=∑tf(xi,d∈ωj)+α∑Nd∈ωj+α⋅V

where

 xixi: A word from the feature vector xx of a particular sample.


 ∑tf(xi,d∈ωj)∑tf(xi,d∈ωj): The sum of raw term frequencies of word xixi from all
documents in the training sample that belong to class ωjωj.
 ∑Nd∈ωj∑Nd∈ωj: The sum of all term frequencies in the training dataset for class ωjωj.
 αα: An additive smoothing parameter (α=1α=1 for Laplace smoothing).
 VV: The size of the vocabulary (number of different words in the training set).
The class-conditional probability of encountering the text xx can be calculated as the product
from the likelihoods of the individual words (under the naive assumption of conditional
independence).
P(x∣ωj)=P(x1∣ωj)⋅P(x2∣ωj)⋅…⋅P(xn∣ωj)=∏i=1mP(xi∣ωj)P(x∣ωj)=P(x1∣ωj)⋅P(x2∣ωj)⋅…
⋅P(xn∣ωj)=∏i=1mP(xi∣ωj)

Term Frequency - Inverse Document Frequency (Tf-idf)

The term frequency - inverse document frequency (Tf-idf) is another alternative for


characterizing text documents. It can be understood as a weighted term frequency, which is
especially useful if stop words have not been removed from the text corpus. The Tf-idf approach
assumes that the importance of a word is inversely proportional to how often it occurs across all
documents. Although Tf-idf is most commonly used to rank documents by relevance in different
text mining tasks, such as page ranking by search engines, it can also be applied to text
classification via naive Bayes.

Tf-idf=tfn(t,d)⋅idf(t)Tf-idf=tfn(t,d)⋅idf(t)

Let tfn(d,f)tfn(d,f) be the normalized term frequency, and idfidf, the inverse document


frequency, which can be calculated as follows
idf(t)=log(ndnd(t)),idf(t)=log⁡(ndnd(t)),

where

 ndnd: The total number of documents.


 nd(t)nd(t): The number of documents that contain the term tt.

Performances of the Multi-variate Bernoulli and Multinomial Model

Empirical comparisons provide evidence that the multinomial model tends to outperform the
multi-variate Bernoulli model if the vocabulary size is relatively large [13]. However, the
performance of machine learning algorithms is highly dependent on the appropriate choice of
features. In the case of naive Bayes classifiers and text classification, large differences in
performance can be attributed to the choices of stop word removal, stemming, and token-length
[14]. In practice, it is recommended that the choice between a multi-variate Bernoulli or
multinomial model for text classification should precede comparative studies including different
combinations of feature extraction and selection steps.

Variants of the Naive Bayes Model

So far, we have seen two different models for categorical data, namely, the multi-variate
Bernoulli (Section Bernoulli Bayes) and multinomial (Section Multinomial Bayes) models —
and two different approaches for the estimation of class-conditional probabilities. In Section
*Continuous Variables, we will take a brief look at a third model: Gaussian naive Bayes.

Continuous Variables

Text classification is a typical case of categorical data, however, naive Bayes can also be used on
continuous data. The Iris flower data set would be a simple example for a supervised
classification task with continuous features: The Iris dataset contains widths and lengths of petals
and sepals measured in centimeters. One strategy for dealing with continuous data in naive
Bayes classification would be to discretize the features and form distinct categories or to use a
Gaussian kernel to calculate the class-conditional probabilities. Under the assumption that the
probability distributions of the features follow a normal (Gaussian) distribution, the Gaussian
naive Bayes model can be written as follows

P(xik∣ω)=12πσ2ω−−−−√exp(−(xik−μω)22σ2ω),P(xik∣ω)=12πσω2exp⁡(−(xik−μω)22σω2),

where μμ (the sample mean) and σσ (the standard deviation) are the parameters that are to be
estimated from the training data. Under the naive Bayes assumption of conditional independence,
the class-conditional probability can than be computed as the product of the individual
probabilities:
P(xi∣ω)=∏k=1dP(xik∣ω)P(xi∣ω)=∏k=1dP(xik∣ω)

Eager and Lazy Learning Algorithms

Being an eager learner, naive Bayes classifiers are known to be relatively fast in classifying new
instances. Eager learners are learning algorithms that learn a model from a training dataset as
soon as the data becomes available. Once the model is learned, the training data does not have to
be re-evaluated in order to make a new prediction. In case of eager learners, the computationally
most expensive step is the model building step whereas the classification of new instances is
relatively fast.

Lazy learners, however, memorize and re-evaluate the training dataset for predicting the class
label of new instances. The advantage of lazy learning is that the model building (training) phase
is relatively fast. On the other hand, the actual prediction is typically slower compared to eager
learners due to the re-evaluation of the training data. Another disadvantage of lazy learners is
that the training data has to be retained, which can also be expensive in terms of storage space. A
typical example of a lazy learner would be a k-nearest neighbor algorithm: Every time a new
instance is encountered, the algorithm would evaluate the k-nearest neighbors in order to decide
upon a class label for the new instance, e.g., via the majority rule (i.e., the assignment of the
class label that occurs most frequently amongst the k-nearest neighbors).
CHAPTER – 4

METHODOLOGY
The Input design is mainly concerned with an input screen in the software. In the input
design, user-oriented inputs are converted into a computer based system format. User can also
select desired options from the menu, provides all possible facilities. Also the important input
format is designed in such a way that accidental errors are avoided. The user has to input only
just the minimum data required, the also helps in avoiding the errors that the users may make.
Accurate designing of the input format is very important in developing efficient software. The
input screen of this application consists of choose an image from gallery or take a new picture,
materials form and choose material quality. The major inputs to the form are:

 Choose a image from gallery or take a new picture.


 Number of floors and number of rooms
 Square feet.
 Choose material quality – Low quality, Medium quality, high quality.

Outputs from computer systems are required primarily to communicate the results of processing
to users. The outputs are needed to be generated as a
CHAPTER -6

LITERATURE SURVEY & CONCLUSION

1. IOT application system with crop growth models in facility agriculture


The concept of Internet of Things (IOT) have been put into practice widely. This paper puts
forward the idea of embedding crop growth models (CGMs) into the IOT application system in
facility agriculture to make the system more intelligent and adaptive. Besides, this paper shares
our practical experience and proposes engineering challenges in further practical deployment.

Published in: Computer Sciences and Convergence Information Technology (ICCIT), 2011 6th
International Conference on

2. Grafting energy-harvesting leaves onto the sensornet tree


We study the problem of augmenting battery-powered sensornet trees with energy-harvesting
leaf nodes. Our results show that leaf nodes that are smaller in size than today's typical battery-
powered sensors can harvest enough energy from ambient sources to acquire and transmit sensor
readings every minute, even under poor lighting conditions. However, achieving this
functionality, especially as leaf nodes scale in size, requires new platforms, protocols, and
programming. Platforms must be designed around low-leakage operation, offer a richer power
supply control interface for system software, and employ an unconventional energy storage
hierarchy. Protocols must not only be low-power, but they must also become low-energy, which
affects initial and ongoing synchronization, and periodic communications. Systems
programming, and especially bootup and communications, must become low-latency, by
eliminating conservative timeouts and startup dependencies, and embracing high-concurrency.
Applying these principles, we show that robust, indoor, perpetual sensing is viable using off-the-
shelf technology.

Published in: Information Processing in Sensor Networks (IPSN), 2012 ACM/IEEE 11th


International Conference on

3. Leaf parameter estimation based on shading distribution in leaf scale hyperspectral


images
Low altitude hyper spectral observation systems provide us with leaf scale optical properties
which are not affected by atmospheric absorption and spectral mixing due to the long distance
between the sensors and objects. However, it is difficult to acquire Lambert coefficients as
inherent leaf properties because of the shading distribution of leaf scale hyper spectral image. In
this paper, we propose an estimation method of Lambert coefficients by making good use of the
shading distribution. The surface reflection of a set of leaves is modeled by a combination of
dichromatic reflection under direct sunlight and reflection under the shadow of leaves. Lambert
coefficient is derived from the first eigenvector of diffuse cluster. Experimental results show that
chlorophyll indices based on the estimated Lambert coefficients are consistent with the growth
stages of paddy fields.

Published in: Hyper spectral Image and Signal Processing: Evolution in Remote Sensing
(WHISPERS), 2013 5th Workshop on

4. Determining optimal storage of field sampled cotton leaves for hyper spectral analysis
Abstract:

Quite often a hyper spectral sensor must be confined to a lab environment to measure leaves
when collecting data for ground truth. In such a situation it may be advantageous to collect
samples and bring them back to the lab to measure hyper spectral signatures. This paper explores
the feasibility of such a data collection procedure for precision agriculture or other applications
where the research involves collecting plant hyper spectral signatures, and attempts to discover
whether it is best to store these plant samples in a cooler or not during transport to the lab. The
results show the optimum storage method depends on the amount of time that elapses between
collecting the samples and measuring their reflectance. If this time is less than about 1 hour and
30 minutes, then it is best not to use a cooler to store leaf samples.

Published in: Hyper spectral Image and Signal Processing: Evolution in Remote Sensing
(WHISPERS), 2013 5th Workshop on

5. Retrieval of LEAF pigment content using wavelet-based prospect inversion from leaf
reflectance spectra
The leaf optical model PROSPECT is widely used to retrieve leaf biochemical parameters, such
as leaf chlorophyll content (Chl), carotenoid content (Car), leaf mass per area (LMA) and
equivalent water thickness (EWT). Most methods for retrieving leaf pigment content are based
on reflectance spectra and they may suffer from ill-posed problems in the inversion process. This
study proposes a new inversion method by integrating the continuous wavelet analysis into the
PROSPECT model inversion process. Instead of inputting reflectance directly to the inversion
process as for most studies, this method uses the wavelet transformed spectra from various scales
to construct the merit function for inversion. The performance of the new method was evaluated
with data from small-plot experiments of wheat and rice crops. Our experimental results
demonstrated that the wavelet-transformed spectra led to better inversion performance as
compared to the reflectance spectra and vegetation indices (VIs). The optimal scales of wavelet
decomposition are different for retrieving Chl and Car. This inversion method has great potential
for predicting leaf pigment content of different crops without the need of calibration models.

Published in: Hyper spectral Image and Signal Processing: Evolution in Remote Sensing
(WHISPERS), 2016 8th Workshop on

CONCLUSION:

In this research, segmentation method and classification based on area thresholding method

are developed. Excess green gray transformation (ExG) and area thresholding algorithms are

combined to obtain the exactly classified images. The system shows an effective and reliable

classification of images captured by a camera. The image segmentation algorithm is very useful

method in the image processing and it is very helpful for the subsequent processing. When the

plants are separated from each other in the images, the results have been shown to be better.

Also the lighting conditions are important to be able to make a reliableanalysis.


CHAPTER -7

1) Wenjiang Huang, Qingsong Guan, Juhua Luo, Jingcheng Zhang, Jinling Zhao, Dong
Liang, Linsheng Huang, and Dongyan Zhang, “New Optimized Spectral Indices for
Identifying and Monitoring Winter Wheat Diseases”, IEEE journal of selected topics in
applied earth observation and remote sensing,Vol. 7, No. 6, June2014
2) Dr.K.Thangadurai, K.Padmavathi, “Computer Visionimage Enhancement For Plant
Leaves Disease Detection”, 2014 World Congress on Computing and
CommunicationTechnologies.
3) Monica Jhuria, Ashwani Kumar, and Rushikesh Borse, “Image Processing For Smart
Farming: Detection Of Disease And Fruit Grading”, Proceedings of the 2013 IEEE Second
International Conference on Image Information Processing(ICIIP-2013
4) Zulkifli Bin Husin, Abdul Hallis Bin Abdul Aziz, Ali Yeon Bin Md Shakaff Rohani Binti
S Mohamed Farook, “Feasibility Study on Plant Chili Disease Detection Using Image
Processing Techniques”, 2012 Third International Conference on Intelligent Systems
Modelling andSimulation.
5) Mrunalini R. Badnakhe, Prashant R. Deshmukh, “Infected Leaf Analysis and Comparison
by Otsu Threshold and k-Means Clustering”, International Journal of Advanced Research in
Computer Science and Software Engineering, Volume 2, Issue 3, March2012.
6) H. Al-Hiary, S. Bani-Ahmad, M. Reyalat, M. Braik and Z. ALRahamneh, “Fast and
Accurate Detection and Classification of Plant Diseases”, International Journal of Computer
Applications (0975 – 8887)Volume 17– No.1, March2011
7) Chunxia Zhang, Xiuqing Wang, Xudong Li, “Design of Monitoring and Control Plant
Disease System Based on DSP&FPGA”, 2010 Second International Conference on
Networks Security, Wireless Communications and TrustedComputing.
8) A. Meunkaewjinda, P. Kumsawat, K. Attakitmongcol and A. Srikaew, “Grape leaf
disease detection from color imagery using hybrid intelligent system”, Proceedings of ECTI-
CON2008.

You might also like