Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Butwal Multiple Campus

Tribhuvan University
Institute of Science and Technology

NEPALI CHARACTER RECOGNITION

A PROJECT REPORT

Submitted to:

Butwal Multiple Campus

Department of Computer Science and Information Technology

Butwal, Rupandehi

In partial fulfillment of the requirements for the Bachelor’s Degree in Computer


Science and Information Technology (B.Sc. CSIT)

Submitted by:

Abinash Bhattarai [4687/071]


Asmin Budha [4690/071]
Mahesh Bhattarai [4706/071]
Surya Pd. Khanal [4727/071]

September, 2018

1
BUTWAL MULTIPLE CAMPUS
TRIBHUVAN UNIVERSITY

Supervisor’s Recommendation

I hereby recommend that this project report prepared under my supervision by Mr. Abinash Bhattarai, Mr.
Asmin Budha, Mr. Mahesh Bhattarai and Mr. Surya Pd. Khanal in partial fulfillment of the requirement for
the degree of B.Sc. in Computer Science and Information Technology of Tribhuvan University be processed
for evaluation.

…………………
Er. Ananta Pandey
Projector Supervisor

2
Letter of approval

This is to certify that this project prepared by Mr. Abinash Bhattarai, Mr. Asmin Budha, Mr. Mahesh
Bhattarai and Mr. Surya Pd. Khanal entitled “NEPALI CHARACTER RECOGNITION” in partial
fulfillment of the requirements for the degree of B.Sc. in Computer Science and Information Technology
has been well studied. In our opinion it is satisfactory in the scope and quality as a project for the required
degree.

………………………………………… …………………………………………..
Mr. Sunil Kumar Yadav Dr. Shakhisaran Subedi
Program Coordinator Campus Chief
Butwal Multiple Campus Butwal Multiple Campus

…………………………………… …………………………………………..
Er. Ananta Pandey Mr. Binod Sharma
Supervisor External Examiner
Butwal Multiple Campus Tribhuvan University

3
STUDENT’S DECLARATION

We hereby declare that project report entitled “Nepali Character Recognition” submitted in the partial
fulfillment of the requirement for Bachelor’s Degree in Computer Science and Informational Technology of
Tribhuvan University, is our original work and not submitted for the award of any other degree, diploma,
fellowship, or any other similar title or prize.

…………………………………
Abinash Bhattarai (4687/071)

…………………………………
Asmin Budha (4690/071)

…………………………………
Mahesh Bhattarai (4706/071)

…………………………………
Surya Pd. Khanal (4727/071)

September, 2018

4
ACKNOWLEDGEMENT

Our forthright gratefulness goes to our supervisor Er. Ananta Pandey, Lecturer, Department of Computer
Science, Butwal Multiple Campus, for whole hearted support and for providing us the opportunity to
undertake this project. We would like to extend our sincere gratitude to Mr. Bhuwan Panthi, Mr. Madhu
Pandey, Mr. Kamal Thapa and Er. Solam Jung Rana, Lecturers, Department of Computer Science,
Butwal Multiple Campus, for their kind and co-operative support, valuable time, and guidance as well as
suggestions. Their useful suggestions for this whole work and co-operative behavior are sincerely
acknowledged.

We are also thankful to Mr. Sunil Kumar Yadav, HOD, Department of Computer Science, Butwal Multiple
Campus for his support.

At the end we would like to express our sincere thanks to all our friends and others who helped us directly
or indirectly during the preparation of this project.

Thanking You,

Abinash Bhattarai [S.N. 4687]


Asmin Budha [S.N. 4690]
Mahesh Bhattarai [S.N. 4706]
Surya Pd. Khanal [S.N. 4727]

5
ABSTRACT

Nepali Character Recognition is an android application which recognizes Nepali Handwritten Character
using Neural Network. Pattern recognition is one of that uses neural network and performance of an Optical
Character Recognition that highly depends on extracted features. The performance of different feature
extraction techniques using a neural network to predict Nepali handwritten character have been described in
this project. In the neural network of the proposed system, feedforward neural network is being used to
predict the hypothesis based on a value of parameters and backpropagation algorithm is used to adjust the
weights. A large number of Datasets of handwritten Devanagari character collected from different online
sources was used to train and test for this classifier model. Nepali Handwritten Datasets are categorized into
three sets (Vowels, Consonants, and Numerals) and accuracy for each set is being tested separately. We
applied some basic algorithm for normalization, binarization, noise reduction, and cropping in pre-
processing and different feature extraction techniques have been used. Based on the extracted feature it
classified the characters. The training set was used to train our model and check accuracy on our cross-
validation dataset and accuracy for respective models having a different feature extraction technique was
pointed out.

Keywords- OCR, Nepali Handwritten datasets, Neural Network, Forward Propagation, Backpropagation,
Zoning, Adam Optimizer, ReLU Activation Function, Sigmoid Activation Function.

6
Table of Contents

Chapter 1: Introduction

1.1) Background_…………………………………………………………………….13
1.2) Problem Definition……………………………………………………………....14
1.3) Objective…………………………………………………………………………14
1.4) Scope and Limitation……………………………………………………………14

Chapter 2: Literature Review

Chapter 3: Requirement Analysis and Feasibility Analysis

3.1) Requirement Analysis…………………………………………………………16-17

3.1.1) User Requirement………………………………………………………16

3.1.2) Functional Requirement………………………………………………..16

3.1.3) Non-functional Requirement…………………………………………..17

3.2) Feasibility Study……………………………………………………………….....18

3.2.1) Technical Feasibility……………………………………………………..18

3.2.2) Economic Feasibility……………………………………………………..18

3.2.3) Operational Feasibility……………………………………………………18

Chapter 4: System Planning

4.1) Planning……………………………………………………………………….…..19

4.2) System development Model…………………………………………………........19

Chapter 5: System Design

5.1) System Architecture……………………………………………………………....20

5.2) System Design…………………………………………………………………21-23

5.2.1) Use Case Diagram…………………………………………………….....21

5.2.2) System Phases……………………………………………………………22

7
5.3.3) Prototype Design…………………………………………………………23

Chapter 6: Implementation and testing

6.1) Algorithms studied and implemented………………………………...……….24-31

6.1.1) Preprocessing…………………………………………………………24-25

a) Noise Removal……………………………………………………….24

b) Binarization…………………………………………………………..25

c) Size Normalization…………………………………………………...25

6.1.2) Segmentation……………………………………………………………..25

a) Dilation………………………………………………………………..25

b) Contours……………………………………………………………….25

c) Merge overlapping rectangles …………………………………………25

6.1.3) Feature Extraction………………………………………………………26-27

a) Zoning…………………………………………………………………..26

b) Horizontal Peak Extent…………………………………………………27

6.1.4) Classification and Recognition…………………………………………..27-31

a) ReLU Activation Function………………………………………………28

b) Sigmoid or Logistic Activation Function………………………………..29

c) Forward Propagation…………………………………………………….29

d) Backward Propagation…………………………………………………..30

e) Adam Optimization Algorithm………………………………………….31

6.2) Tools used…………………………………………………………...………………32

6.3) Testing……………………………………………………………………………33-36

6.3.1) Unit testing………………………………………………………….........34

8
a) Preprocessing…………………………………………………………34

b) Segmentation……………………………………………………........34

c) Feature Extraction…………………………………………………….34

d) Neural Network Architecture…………………………………………34

6.3.2) Integration testing…………………………………………………………35

6.3.3) System Testing……………………………………………………...……..35

6.3.4) Alpha testing………………………………………………………..……...36

6.3.5) Beta testing…………………………………………………………………36

Chapter 7: Comparison and Conclusion

7.1) Recognition accuracy of zoning feature extraction technique………….........37

7.2) Recognition accuracy of horizontal peak extent technique………………….37

Chapter 8: Future Plan and Conclusion ……………………………………….……......38

Appendices………………………………………………………………………………39

References……………………………………………………………………………….40

9
List of Figures

Figure: 1 Evolutionary prototype model……………………………………………18

Figure:2 System Architecture……………………………………………………….19

Figure:3 Use Case Diagram for NCR……………………………………………..…20

Figure:4 Phases in NCR..…………………………………………………………….20

Figure:5 Classification Process in NCR...……………………………………………22

Figure:6 Noise Removal……………………………………………..……………….23

Figure:7 Binarization………….…………………………….…..………………........24

Figure:8 Zones of Input Character……………………………………………………25

Figure:9 Horizontal Peak Extent-based Feature.………………………………..........26

Figure:10 ReLU Activation Function.…………….………………………………….27

Figure:11 Sigmoid Activation Function………...…………………………………….28

Figure :12 Neural Network……………………………………………………………31

Figure:13 Testing……………………………………………………………………..32

10
List of Tables

Table 1: Unit Testing …………………………………………….………………………........34

Table 2: Integration Testing…………………………………………………………………....34

Table 3: Alpha Testing…………………………………………………………………………35

Table 4: Recognition Accuracy Using Various Feature Extraction Techniques………..……...36

11
Abbreviations
Adam Adaptive Moment Estimation

ANN Artificial Neural Network

GDMA Gradient Descent with Momentum & Adaptive Learning Rate

HOD Histogram Oriented Gradients

ML Machine Learning

MLP Multi-Layer Perceptron

NCR Nepali Character Recognition

OCR Optical Character Recognition

ReLU Rectified Linear Unit

RF Random Forest

RMSprop Root Mean Square prop

RNN Recurrent Neural Network

SDK Software Development Kit

12
Chapter 1: Introduction

1.1 Background

Optical Character Reader is the mechanical or electronic conversion of images of typed, handwritten, or
printed text into machine-encoded text, whether from a scanned document or a photo. It is widely used as a
form of information entry from printed paper data records, passports documents, invoices, bank statements,
computerized receipts, business cards, mail, printouts of static data, or any suitable documents. OCR
software processes a digital image by locating and recognizing characters, such as letters, numbers, and
symbols. Some OCR software will simply export the text, while other programs can convert the characters
to editable text directly in the image. Advanced OCR software can export the size and formatting of the text
as well as the layout of the text found on a page. For example, if you scan a multipage document into a
digital image, such as *.png or *.jpg file, you can load the document into an OCR program, which will
recognize the text and convert the document to an editable text file. Some OCR programs allow you to scan
a document and convert it to a word processing document in a single step. While OCR technology was
originally designed to recognize printed text, it can be used to recognize and verify handwritten text as well.

The different application fields of OCR are as follows:


• Data Entry
• Automatic Number plate recognition
• Extracting Business Card Information to Contact List

Nepal is multilingual country. Many languages are spoken like Nepali, Maithili, Newari, Bhojpuri etc.
among them mostly spoken language is Nepali which is written in Devanagari Script. Many Research has
been done in the field of Optical Character Recognition (OCR) in Latin scripts and they have also been
successfully able to predict with higher accuracy but research in Devanagari scripts are fewer.
Handwriting recognition has been a popular area of research since few decades under the purview of pattern
recognition and image processing [1]. Character recognition system can be of two types: Online and Offline,
where online character recognition software is available on the internet and is used directly online by people
who need OCR performed on files of various formats, but offline character recognition depends on the
documents [2].
This proposed paper model a Neural Network to classify the handwritten Nepali Characters. This system
consists of three stages- Pre-processing, Feature Extraction, and Classification. In pre-processing, an input
image is pre-processed using different techniques like cropping, noise removal, binarization, and
normalization and then sent for feature extraction. There are different feature extraction techniques like
Zoning, diagonalizing, projection histograms, contour profiles, Horizontal Peak Extent etc. In our proposed
system, zoning and horizontal peak extent techniques are used to extract features then passed to next stage.
Classification is the last stage in which Neural Network is used as a classification algorithm.

13
1.2 Problem Statement

Many people in today’s generation are exposed to currently developing technology. For a country to develop,
use of technology is very important. Development of technology is in rapid stage in our country. Our national
language Nepali is used all over the country. Our government sectors are digitizing rapidly. We need to store
different handwritten notes into the system. Since our government sectors operate in Nepali language, any
OCR that recognizes Nepali character is not available easily. Hence Nepali Character Recognizer can be
used to complete these tasks. It makes our government sector more open to visually impaired people also.
Many tourists visit our country for enjoyment, research, adventure and visit remote places or historical
places. In historical places many messages are written in Nepali language which is not understandable by
tourists. In remote areas people speak less English, so interaction with tourists is less and they find difficulty
in understanding our culture. If we can develop a Nepali Character Recognizer then it may help tourists to
understand our culture properly. They can scan Nepali texts and search them on Google and search for
meaning or use text to speech feature also.

1.3 Objectives
The objective of this research is to study character recognition patterns, character recognition algorithms,
tools and eliminate deficiency in identifying character patterns.
Some of the objectives are listed below:
✓ To study different optical character recognition algorithms with different tools available.
✓ To identify character recognition patterns by study and analysis of Nepali characters and digits 0-9
for structural and statistical features.
✓ To collect handwritten data samples and recognize each character and digit using different character
recognition tools.
✓ To develop the algorithm to implement the above model and to test and Performance evaluation by
analyzing results of model.

1.4 Scope and Limitation

The study is concerned with character recognition, for conversion of the scanned image file into editable
and searchable text file. Proposed study focuses on analyzing and recognizing isolated offline Nepali
characters and digits. The system can create paperless environment by digitizing the handwritten characters.
Improve of human computer interface for computer illiterate people by providing various computing
services on inputs. It has wider scope in banks, schools and hospitals for data entry purpose. It can be
implemented on smart phones, tablets and a computer.
Some limitations are listed below:
• The model supports only Nepali language.
• Accuracy of model is directly dependent on the quality of input image.
• The model can identify only individual character. It can’t identify a word.
• It does not contain any word dictionary so spell check is not possible

14
Chapter 2: Literature Review

Handwriting recognition is very difficult task to perform. It is a sequence of feature extraction and
classification. Different researchers have proposed various feature extraction and classification techniques
in their research. They all have focused on the improved performance. The feature extraction algorithms
may rely on morphology of characters for better classification. Classification is one of the major steps in
OCR and design of good classifier is also a challenging task. Mostly supervised learning is used for the
classification of characters. The recognition accuracy depends on feature extraction techniques since the
recognition rely on feature extracted.

“Nepali OCR Using Hybrid Approach of Recognition” proposed by N. Pant [3] recognize characters as well
as words. To minimize the overhead of component level segmentation and minimize the errors due to
inaccurate dissection, they have proposed hybrid approach which combines the Holistic Method and
Dissection Technique. First input is segmented into words and classified using Holistic approach if
confidence level is low words are segmented into characters and then classified. In this proposed system,
Histogram Oriented Gradients (HOG) descriptors is used to define feature vector and Random Forest (RF)
algorithm as a classifier with accuracy of 78.87% and 94.80% for character level recognition and word level
recognition respectively.

Kaur et al. [4] have proposed a “Handwritten Gurumukhi Character Recognition by using Recurrent Neural
Network”, where they have used three types of feature extraction techniques namely as zoning, intersection
and open-end point and horizontal peak extent with Recurrent Neural Network (RNN) algorithm for
classification. In their proposed system, they have experimented using above mentioned feature extraction
techniques and also combination of them and RNN architecture used by them is standard Multi-Layer
Perceptron (MLP) plus added loops. The highest accuracy achieved by them is 87.34% with combination of
Zoning and Intersection and open-end point techniques.

Hussain et al. [5] have proposed a paper “A Zoning based Feature Extraction method for Recognition of
Handwritten Assamese Characters”, which uses zoning feature extraction technique for recognition of
handwritten Assamese Characters. They have preprocessed and obtained binary image of an image then
after zoning deviation is calculated from unknown character with other known characters to find nearest
match.

G. Jaiswal [6] have proposed “Handwritten Devanagari Character Recognition Model Using Neural
Network”, a Devanagari Character Recognition System using Zone and count metric-based feature
extraction algorithm with Artificial Neural Network (ANN) algorithm for classification. They have used
Multilayer feed forward neural network-based classifier and back propagation for weight adjustment. In
their system, ANN have Input layer of 35 input nodes, 1 Hidden layer of 50 internal nodes and output layer
of 58 output nodes (12 vowel class, 36 consonant classes, 10 numeric classes). With Gradient Descent with
Momentum & Adaptive Learning Rate (GDMA) as a learning algorithm for learning weights in network
they are able to achieve accuracy of 75% - 80%.
Most of the above-mentioned research has mentioned the importance of feature extraction in Handwritten
Character Recognition hence we have a proposed system which uses different feature extraction techniques
like zoning and horizontal peak extent and uses Artificial Neural Network (ANN) algorithm for
classification.

15
Chapter 3: Requirement Analysis and Feasibility Analysis

3.1 Requirement Analysis


3.1.1 User requirement
The user requirement for this system is to make the system fast, flexible, less prone to error, reduce expenses
and save the time.

3.1.2 Functional requirement


The functional requirements specify the services that the system should provide, how the system should
react to particular inputs and how the system should behave in particular situations. In some cases, the
functional requirements may also explicitly state what the system should not do. The functional requirements
of ‘Nepali Character Recognition’ are as follows:

a) User may either select image from gallery or capture image.


b) Handwritten image needs to be converted into machine editable text.

16
3.1.3 Non-Functional Requirement

a) User friendly
This application is user-friendly enough to meet the computer knowledge and skill of general users. User
friendliness is achieved through providing easy navigation via usage of standardized and generalized
navigation, using standardized wording or avoiding jargons and so on.

b) Availability
As concerned to availability system is error free and rate of systems failure rate is slow. The System is
available all the time as requires by system users.

c) Reliability
With a reliable source and tools, the outcome would be reliable as well.

d) Speed
Since it is web server based so the recognition time is fast.

e) Android
This application must run all the android platform version that are available in the market from Android 4.0
(Ice Cream Sandwich) and further.

f) Usability
A simple and standardize UI deign with all the necessary features would be sufficient and efficient. For
normal users to get along with application

g) Performance
The performance of the application is determined by various factor like response time, throughput, Resource
utilization, etc.

17
3.2 Feasibility Study

3.2.1 Technical feasibility

• Smart phones with back camera are easily available.


• SDKs for android are easily available.
• Android studio can be easily installed to develop the application.
• The tools, modules, libraries required for the development of this application are open source, freely
available and easy to use.

3.2.2 Economic feasibility

• The proposed system is economically feasible. To support this feasibility, following points are
considered.
• No need to buy any special hardware for the application as it can run on android mobiles.
• The application can be simply developed using PCs with android installed.

3.2.3 Operational feasibility

• To ensure the system is operationally feasible, following points are considered.


• Application can also be tested using emulator.
• Application can be tested on android phone at each stage of development so by checking at each
development stage we can ensure application will be operationally feasible.

18
Chapter 4: System Planning

4.1 Planning
Planning is required before developing any application. Planning helps in completing the project within the
time. This also helps to make requirements to be meet in the final product. For developing Nepali Character
Recognition, plan on selecting the suitable model for the project is made. The time schedule within which
the application is to be completed is prepared also the estimated cost for the product was roughly prepared.

4.2 System Development Model

Nepali Character Recognition application is based on the evolutionary prototyping model. Firstly, a
prototype is created to simulate the application. Then the application can be further improved adding other
feature for the same prototype.

Initial Rapid Design Develop


requirements prototype

Refine
Prototype
requirements
evaluation

Figure 1: Evolutionary prototype model

19
Chapter 5: System Design

5.1 System Architecture


When user opens app, two option are provided either to select image from gallery or capture imager from
camera. After selection, Image is shown on the screen. Now preprocessing and text classification is done
and result is shown to the user.

Open App Select/Capture Image

Internal/
external
storage

Preprocess Image Show Image

Text Classification

Figure 2: System Architecture

20
5.2 Design
5.2.1 Use Case Diagram

Upload
Image

Cancel
User

Initialize
Convert Image
Grayscale

Preprocessing
Image

Grayscale
to binary

Segmentation

Normalization
Admin
Feature
Extraction

Recognition

Figure 3: Use Case diagram for NCR

21
5.2.2 System Phases

Image Input

Preprocessing

Segmentation

Feature Extraction

Classification and Recognition

Figure 4: Phases in NCR

22
5.2.3 Prototype Design

Training Recognition (Testing)

Training Pre-processing Pre-processing


Test Data
Data

Feature Extraction Feature Extraction

Classification Classification

Figure 5: Classification process in NCR

23
Chapter 6: Implementation and Testing

6.1 Algorithm studied and Implemented


In this project, OpenCV is used for preprocessing. Feature Extraction algorithms like Zoning and Horizontal
Peak Extent are compared. Machine Learning library like Keras, NumPy, Pandas, TensorFlow etc. are used
for creating Neural Network model and prototype designing.

6.1.1 Preprocessing:
The images provided by the users have many noises and errors so they must be first removed and forwarded
to the system so the acquired image should be preprocessed before applying to system. It helps in feature
extraction and classification phase for obtaining good results. There is different pre-processing technique
available that varies from one script to another and goals as well. We use some basic preprocessing technique
such as size normalization, noise removal and binarization. It is used to remove all unwanted bit patterns
which reduce recognition accuracy.

a) Noise removal:
Noisy image pixels are removed with the help of filtering. Median filtering is mostly used to remove salt
and pepper noise. Here, Non-linear median filtering technique is used for noise removal. For the digital
image f(x; y), median filtered image is obtained as,
g(x; y) = median{f(i, j) | (i, j) ϵ w} [6]
where w is the neighborhood centered around location (x,y) in the image.

Figure 6: Noise Removal

24
b) Binarization:
RGB image is converted into gray scale and then into binary image using global thresholding technique.

Figure 7: Binarization

c) Size Normalization:
Size normalization is the technique of converting all the variable size input images to fixed size images. Size
normalization is done so that we do not require padding of pixels at the time of feature extraction. All the
input images are normalized to the predefined size of 36x36 pixels [6].

6.1.1 Segmentation:
a) Dilation:

1. A kernel is convolved with the image


2. A pixel element in the original image is ‘1’ if atleast one pixel under the kernel is ‘1’.
3. It increases the white region in the image or size of foreground object increases

b) Contours:
Contours can be explained simply as a curve joining all the continuous points (along the boundary), having
same color or intensity. The contours are a useful tool for shape analysis and object detection and
recognition. Based on these contours point, a rectangle box is created for every object by taking end points.
c) Merge overlapping rectangles:
If two or more rectangles overlaps, they are merged into single rectangles having extreme points.

25
6.1.2 Feature Extraction:
As we use address bar to identify our homes same does the system. Here address bar is represented by
features which indicates correct characters to be recognized. Hence the Feature extraction stage is important
stage of this model. The system extracts different features of the images provided using common feature
extraction techniques explained below. The most important aspect of handwriting recognition scheme is the
selection of good feature set, which is reasonably invariant with respect to shape variations caused by various
writing styles [6]. Proper and sufficient feature selection may help in classification and reduce huge
workload.
We have used different feature extraction techniques to recognize Nepali characters like:
a. Zoning
b. Horizontal Peak Extent

a) Zoning:
Zoning is used to extract the feature based on it neighboring pixels. In zoning, an image is divided into NxM
zones then a sum of a black pixel is calculated for each zone which acts as features for next stage. In our
case, 36x36 image is divided into 6x6 identical zones that is total of 36 zones. In each zones sum of a black
pixel is calculated.

Algorithm:
Let’s say we want to divide into zones with row-size=row and column-size=col
Step 1: Divide image into n no. of equal size zones, each containing m×m pixels.
Step 2: For each zone, find the sum of all black pixels in that zone. This sum act as a feature for that zone.
Step 3: Zones having no foreground pixels are set to a value i.e. equals to zero.

Z1 Z2 Z3 Z4 Z5 Z6
Z7 Z8 Z9 Z10 Z11 Z12
Z13 Z14 Z15 Z16 Z17 Z18
Z19 Z20 Z21 Z22 Z23 Z24
Z25 Z26 Z27 Z28 Z29 Z30
Z31 Z32 Z33 Z34 Z35 Z36

Figure 8: Zones of input character

26
b) Horizontal Peak Extent:
Horizontal Peak Extent is used to extract the features based on pixels residing in a same horizontal row by
row. In each row, a sum of successive foreground pixel is calculated then the largest value is swapped with
each foreground pixel in that row. This largest value act as a feature. We have used 36 x 36 image so a total
of 36 features can be extracted.

Algorithm:
Step 1: Divide image into n no. of equal size zones, each containing m×m pixels.
Step 2: Find the sum of successive foreground pixel extents in horizontal direction in each row of zone.
Step 3: Find the largest value in each row and alternate it with each foreground pixel in row.
Step 4: Calculate the sum by thinking about the highest successive foreground pixel value of each row; it
will be the featured value of that zone.
Step 5: Zones having no foreground pixels are set to a value i.e. equals to zero.

SUM=43
Figure 9: Horizontal peak extent-based features

6.1.3 Classification and recognition:


This phase is also known as decision-making phase. It uses the extracted features of the image. The main
aim of this phase is to recognize input data. It uses Artificial Neural Network for classification purpose. A
neural network is a computational model widely used in situation where the problem is complex and data is
subject to statistical variation [7]. Artificial neural network is a non-linear, parallel, distributed, highly
connected network having capability of adaptivity, self-organization, fault tolerance and evidential response,
which closely resembles with physical nervous system [8]. Each neuron has some activation function which
calculates some value and passed into next layer of neurons. Neural Network is an architecture which
depends upon on other algorithms and activation function. Algorithm and activation function used in our
neural network model are explained below.

27
a) ReLU (Rectified Linear Unit) Activation Function:

ReLU is half rectified (from bottom). f(z) is zero when z is less than zero and f(z) is equal to z when z is
above or equal to zero.

Range: [ 0 to infinity)

The function and its derivative both are monotonic.

All the negative values become zero immediately which decreases the ability of the model to fit or train
from the data properly. That means any negative input given to the ReLU activation function turns the value
into zero immediately in the graph, which in turns affects the resulting graph by not mapping the negative
values appropriately.

Figure 10: ReLU activation function

28
b) Sigmoid or Logistic activation function:
The Sigmoid Function curve looks like a S-shape. The main reason why we use sigmoid function is because
it exists between (0 to 1). Therefore, it is especially used for models where we have to predict the
probability as an output. Since probability of anything exists only between the range of 0 and 1, sigmoid
is the right choice.

Figure 11: Sigmoid activation function

c) Forward propagation:
The input X provides the initial information that then propagates to the hidden units at each layer and finally
produce the output Ŷ.

Algorithm:
• a(1) = x
• z(2) = Θ(1)a(1)
• a(2) = g(z(2)) (add a0(2))
• ………
• z(L) = Θ(L-1)a(L-1)
• a(L) = g(z(L))

29
d) Back propagation algorithm:
Artificial neural networks use backpropagation as a learning algorithm to compute a gradient descent with
respect to weights. Desired outputs are compared to achieved system outputs, and then the systems are tuned
by adjusting connection weights to narrow the difference between the two as much as possible. The
algorithm gets its name because the weights are updated backwards, from output towards input.

Algorithm:
Step 1: Training set {(x(1), y(1)),….,(x(m),y(m))}
Step 2: Set Δij(l) = 0 (for all l, i, j).
Step 3: for i= 1 to m
• Set a(1) =x(i)
• Perform forward propagation to compute a(l) for l=2, 3,…, L
• Using y(i) , compute δ(L) = a(L)-y(i)
• Compute δ(L-1), δ(L-2),……, δ(2) where δ(k)=( Θ(k))T δ(k+1).*g’(z(k)) and g’(z(k))=a(k).*(1-a(k))
• Δij(l) = Δij(l) + aj(l) δ(L+1)
Step 4: Dij(l) = (1/m) Δij(l) + λ Θij(l) if j != 0
Dij(l) = (1/m) Δij(l) if j = 0

where,

30
e) Adam (adaptive moment estimation) optimization algorithm:
Adam is an optimization algorithm that can be used instead of the classical stochastic gradient descent
procedure to update network weights iterative based in training data. It realizes the benefits of both AdaGrad
and RMSProp. Instead of adapting the parameter learning rates based on the average first moment (the mean)
as in RMSProp, Adam also makes use of the average of the second moments of the gradients (the uncentered
variance).

Algorithm:
Step 1: Vdw=0, Sdw=0, Vdb=0, Sdb=0.
Step 2: On iteration t.
Step 3: Compute dw, db using current mini-batch.
Step 4: Vdw= β1Vdw+(1- β1)dw.
Step 5: Vdb= β1Vdb +(1- β1)db.
Step 6: Sdw= β2Sdw+(1- β2)dw2.
Step 7: Sdb= β1Sdb +(1- β2)db2.
Step 8: Vdwcorrected= Vdw/(1- β1t).
Step 9: Vdbcorrected= Vdb/(1- β1t).
Step 10: Sdwcorrected= Sdw/(1- β2t).
Step 11: Sdbcorrected= Sdb/(1- β2t).
Step 12: W= W- α Vdwcorrected/(( Sdwcorrected+ ε)^0.5).
Step 13: b= b- α Vdbcorrected/(( Sdbcorrected+ ε)^0.5).
Step 14: Repeat.

31
Combining above activation functions and algorithms. We have used 3 layers Neural Network architecture
having 36 neurons in input layer, 128 neurons in hidden layer and 58 neurons in output layer. We have used
a sigmoid function in output layer and ReLU activation function in other layers. Adam Optimization
Algorithm is used for training a neural network.

Figure 12: Neural Network

6.2 Tools
• Android Studio 3.0, Android SDK manager Version 7.1.1 with build-tools, platform tools, android
SDK tools (25), and android SDK platform-tools have been used. The Android Developer Tools
provide a first-class development environment for building Android apps. This integrated
development environment is set up with the latest version of the Android platform and System image
so you can immediately begin building apps and running them on the Android emulator.
• Spyder IDE for prototype design and testing have been used.
• Django is used for backend server to classify image.
• Adobe Photoshop for making .jpeg, .png etc. images for this project.
• StarUML: From this tool, Activity Diagram, Class Diagram, Sequence Diagram etc. are made.
• Microsoft Word, Microsoft excel, Microsoft PowerPoint.

32
6.3 Testing
Testing is an integral part of the software development. Testing is done at each stage of the software
development process to ensure that the developed modules work properly. Testing is done to ensure that the
developed product meet the user requirements.

Testing can be done at various stages. Testing is done to check whether our product is error free or not. Any
error discovered during testing can be corrected at its initial stage so that the system can operate as desired.
A successful test is that finds error in the developed modules.

During the development stage of the Nepali Character Recognition, various tests are done. These tests can
be diagrammatically shown.

System test

Integration test

Unit test

Figure 13: Testing

33
6.3.1 Unit Testing
This test is done to determine the working of the individual modules. Nepali Character Recognition android
app includes various modules that are tested at the development process. These modules include
a) Pre-processing
b) Segmentation
c) Feature Extraction
d) Neural Network Architecture
Different modules with their testing results are shown.

a) Pre-processing
In pre-processing, image is checked for any noises, size denormalization etc. For any ML model, at first
image size needs to be normalized so that for any input image it extracts same number of features. Then,
image is converted into Binary Image as RGB image is slower to process and binary image gives better
result. At last we have to remove noises, which may result in less accuracy of our model. For noise removal,
we have used median filtering.

b) Segmentation
In image there may be several unwanted regions and only the wanted region where character is located need
to be determined. But finding rectangle box with contours may also find irrelevant boxes. So, to delete
unwanted boxes we can find the ratio of height and width of rectangle box and only take those boxes whose
ratio may be a character. Also the overlapping boxes can be merged together so that rectangle representing
same characters are only one.

c) Feature Extraction
Accuracy of any ML model depends upon on its input feature. So, for wise selection of Feature Extraction
we have selected two algorithms and tested them separately for their accuracy.

d) Neural Network Architecture


There is no any fixed neural network architecture for certain problem domain. So, test on different
architecture have to be done and find out architecture which gives higher accuracy.

34
Table 1: Unit Testing
Pre-processing Segmentation Feature Neural Network Accuracy
Extraction Architecture
Size True Zoning 36>128>58 86.42
Normalization, with
Binarization regularization=0.08
Size True Zoning 36>128>58 87.26
Normalization, with
Binarization, regularization=0.02
Median Filtering
Size True Horizontal peak- 36>128>58 83.83
Normalization, extent with
Binarization regularization=0
Size True Horizontal peak- 36>128>58 84.25
Normalization, extent with
Binarization, regularization=0.08
Medial Filtering

6.3.2 Integration Testing


Integration testing is performed by merging different modules together. After successful completion of the
unit test, ML model is created which is deployed into server and pre-processing, segmentation and feature
extraction part is deployed into app. Now, integration of all these parts is tested in integration test to ensure
that the communication between the module is proper and is correct.

Table 2: Integration Testing


Select/Capture Single/Multiple Expected Output Result
Image Character
Select Single क क
Select Single ० ०
Select Single १ १
Capture Single घ घ
Capture Single ग ग
Capture Single ख भ

6.3.3 System testing


System testing is used to test the overall interaction of components. It involves the load, performance,
reliability and security testing. So, the overall performance of the application ca be tested. The purposed
system is also tested by using this technique to make this project more reliable.

35
6.3.4 Alpha testing
For testing the application, Nepali Character Recognition is installed in some of the devices randomly at
class and the test result is presented as;

The system is tested on different android devices and the result is as;

Table 3: Alpha Testing

Device Expected output Result


Gionee P5 Mini App need to recognize the True
character with desired
accuracy.
Samsung galaxy s3 True.

Samsung J7 True

Redmi Note 3 True


Gionee A1 True

6.3.5 Beta testing


The product has already passed through the first-level, internal pilot-test called the alpha test and the major
defects have been removed. But the application may still have some minor problems that require user
participation. It will be released to selected user for identifying others defects.

36
Chapter 7: Comparison and Conclusion

The outcome of our proposed system is provided here. The results are based on two feature extraction
method that is zoning and horizontal peak extent. We have used 10 fold cross-validation and 200 epochs
with a batch size of 32 to train our model.

7.1 Recognition accuracy of zoning feature extraction technique:


We have achieved maximum accuracy of 87.26% using zoning feature extraction method. Regularization of
0.08 have been used.

7.2 Recognition accuracy of horizontal peak extent technique:


After trying out parameter tuning, maximum of 84.25% accuracy with regularization of 0.0 using horizontal
peak extent have been able to achieve.

Table 4: Recognition accuracy using various feature extraction techniques


Feature Extraction Accuracy (in Percentage)
Zoning 87.26%
Horizontal Peak Extent 84.25%

37
Chapter 8: Future Plan and Conclusion

Nepali Character Recognition is an android application that recognizes only Nepali character. This model
will be extended further to develop a complete application that recognizes whole sentences at a time. In
future this application will be built on ios and web platform for broader use of this technology. In future this
technology can facilitate different sectors like government bodies, tourism, banking etc. for automated data
entry purpose. We will work on the model to increase accuracy rate and to make the model more efficient
for running in any platform.

38
Appendices:

39
References:
[1] Santosh K.C, Cholwich Nattee “A Comprehensive Survey On On-Line Handwriting Recognition
Technology And Its Real Application To The Nepalese Natural Handwriting”, Kathmandu University
Journal Of Science, Engineering And Technology Vol. 5, January, 2009, Pp 31-55.
[2] Md. Shahiduzzaman, “Bangla Hand Written Character Recognition ”, International Journal of Science
and Research (IJSR) ISSN 2319-7064, 2013.
[3] N. Pant, “Nepali OCR Using Hybrid Approach of Recognition”, Proceedings of the 2011 International
Conference on Image Information Processing, IEEE, pp. 14, (2016).
[4] H. Kaur, S. Rani, “Handwritten Gurumukhi Character Recognition by using Recurrent Neural Network”,
An International Journal of Engineering Sciences, 2016.
[5] E. Hussain, A. Hannan, K. Kashyap, “A Zoning based Feature Extraction method for Recognition of
Handwritten Assamese Characters”, InternatIonal Journal of Computer Science and technology, Vol. 6,
2015.
[6] G. Jaiswal, “Handwritten Devanagari Character Recognition Model Using Neural Network”,
International Journal of Engineering Development and Research (IJEDR), Vol 2, 2014.
[7] Ahmed Asif Chowdhury, Ejaj Ahmed, Shameem Ahmed, Shohrab Hossain, Chowdhury Mofizur
Rahman,“Optical Character Recognition of Bangla Characters using neural network. A better approach”,
2nd International Conference on Electrical Engineering (ICEE), Jan 2002.
[8] A.K. Pant., S. Panday, S.R. Joshi,“Off-line Nepali handwritten character recognition using Multilayer
Perceptron and Radial Basis Function neural networks”, Third Asian Himalayas International
Conference on Internet, 2012.

40

You might also like