Beruflich Dokumente
Kultur Dokumente
On
Thesis Submitted in the partial fulfillment of the requirements for the degree of
M.TECH IT (Courseware Engineering)
Submitted By
SWATI MUKHERJEE
Examination Roll number:-M48CWE10-03
Certificate of Recommendation
This is to certify that Swati Mukherjee has completed her dissertation entitled Recognition of
Handwritten Bengali Character Based on Character Features, under the supervision and
guidance of Arunasish Acharya, School of Education Technology, Faculty Council for UG and
PG studies in Engineering and Technology, JADAVPUR UNIVERSITY, Kolkata. We are
satisfied with her work, which is being presented for the partial fulfillment of the degree of
Master of Technology in IT (Courseware Engineering), Jadavpur University, Kolkata700032.
Certificate of Approval*
The foregoing thesis is hereby approved as a creditable study of M.Tech IT (Courseware
Engineering) and presented in a manner satisfactory to warrant its acceptance as a prerequisite to
the degree for which it has been submitted. It is understood that by this approval the undersigned
do not necessarily endorse or approve any statement made, opinion expressed or conclusion
therein but approve this thesis only for the purpose for which it is submitted.
_____________________________
_____________________________
_____________________________
Signature of Examiners
*Only in case the thesis is approved.
I hereby declare that this thesis contains literature survey and original research work by the
undersigned candidate, as part of Master of Technology in IT (Courseware Engineering
studies).
All information in this document have been obtained and presented in accordance with academic
rules and ethical conduct.
I also declare that, as required by these rules and conduct, I have fully cited and referenced all
material and results that are not original to this work.
: SWATI MUKHERJEE
: M48CWE10-03
Thesis Title
ACKNOWLEDGEMENTS
I feel extremely glad in presenting my final year project at School Of Education Technology,
Jadavpur University, Kolkata, in the partial fulfillment of the requirements for the M.Tech
IT(Courseware Engineering).
I would specially like to thank my guide, Mr. Arunashis Acharya, for his vigilant supervision and
his constant encouragement. He spent his precious time in reviewing the project work and
provided many insightful comments and constructive criticism. Without his enthusiasm and
intelligence this work would not have been possible.
I would also like to express my grateful thanks to Prof. Samar Bhattacharya, Director of School
of Education Technology, for his support, encouragement and timely advices. I am really
indebted to Prof. Pramatha Nath Basu, Dr. Ranjan Parekh, Dr.Matangini Chattopadhyay,
Mrs. Saswati Mukherjee for their continuous support during the entire course of the project.
Their advice and support was inspirational and motivational.
There are a lot of people who contributed towards the completion of the project and I am really
thankful to all of them.I do wish to Thank to all of my classmates of M. Tech. IT (Courseware
Engineering) and MMD department, who inspired and motivated me to complete my project
work successfully, departmental support staff and all of these who were associated with this
project contributed in some form or the other.
Lastly, most important I would like to thank my parents. Without love, patience, support, and joy
that they have provided, I would be unable to complete this project.
Date:
Place: Jadavpur, Kolkata
________________________________
Swati Mukherjee
Roll No-000811902003
M.Tech IT (Courseware Engineering)
School of Education Technology
Jadavpur University
Kolkata - 700032
CONTENTS
Executive Summery.3
Chapter 1: Introduction..4
1.1 Problem Statement ...7
1.2 Brief of Problem to be Solved...7
1.3 Objectives..7
1.4 Assumptions..7
1.5 Organization of the Thesis.. .8
Chapter 7: References...49
Appendix I Codes of the Project.......53
Appendix II Output of the Project.......70
Executive Summary
This thesis proposes two new approaches for extracting features in context of Handwritten Bengali
character recognition. First approach is to compute shadow based features where each character image
is enclosed within a minimal square, divided into four quadrants. Each quadrant is further divided into
eight octants. Then lengths of projections of character images on three sides of each octant are then
computed. Lengths of all such projections on each of the 3x8=24x4 sides of all octants are summed up
to produce 24x4=96 shadow based features of the character image are obtained. The second approach
is to compute the Diagonal Distance features from four corners of the minimal square containing the
character image. Here a set of 4 features of each character image are obtained. Thus a summation of
all features of each character image, 100 features are obtained to feed to the Neural Network to
classify properly.
CHAPTER 1
INTRODUCTION
Handwritten Character recognition has attracted voluminous research in recent times and received
extensive attention in academic and production fields. It is important area in image processing and
pattern recognition. India is a multi-lingual and multi-script country, where eighteen official scripts are
accepted and have over hundred regional languages.
Today, many researchers have been done to recognize Bengali characters. But the problem of
interchanging data between human beings and computing machines is a challenging one. Even today,
many algorithms have been proposed by many researchers so-that these Bengali characters can be
easily recognize. But the efficiency of these algorithms is not satisfactory.
Mainly, users do Handwritten Character Recognition for interpretation of data, which describes
handwritten drawing. Handwritten character recognition can be differentiated into two categories i.e.
Online Handwritten character recognition and Offline Handwritten character recognition. On-line
handwritten character recognition deals with automatic conversion of characters, which are written on
a special digitizer, tablet PC or PDA where a sensor picks up the pen-tip movements as well as penup/pen-down switching. Off-line handwritten character recognition deals with a data set, which is
obtained from a scanned handwritten document. The main objective of handwritten Bengali character
recognition (HBCR) is to recognize the Bengali characters in desirable format from image format so
that they can be easily edited.
Many researchers have been done to solve handwritten character recognition problem in related areas
such as Image Processing, Pattern Recognition, Artificial Intelligence, and cognitive science etc.
Further researches are being done to improve accuracy and efficiency. Recognition of Offline
Handwritten Bengali characters is a goal of many research efforts in the pattern recognition field.
Many techniques have been applied for recognition of handwritten Bengali characters but still it is the
case of less efficiency and accuracy of recognition.
Artificial Intelligence concepts like neural networks are used to perform the work as human mind can
do. This explores the idea of how humans recognize text in general and are used to develop machines
that simulated this process. Developing these intelligent machines for recognizing characters is not an
easy task; this is because a character can be written in different ways. Also there are so many
imperfections and variation of handwriting such as alignment, noise and angles, which make
handwritten character recognition difficult to implement with a machine. All these imperfections of
handwritten characters cannot be removed easily, so this problem is separated in sub- problems. This
means that a single process or single machine is not capable of performing the entire process. It can be
done by a series of processes that return some desirable result. Then a final process will combine the
results from all the sub-process to produce a final result. For recognition of handwritten characters,
some sub-processes are followed i.e. scanning a document, pre-processing, feature extraction,
Classification etc. The output of previous process is used as input in next process.
For example, the first sub-process i.e. scanning of document scans the information and produces some
output that is taken by next sub-process i.e. preprocessing which eliminates all the noise such as ink
spots that have no meaning, binarization, skew correction ,slant removal can be done to the document.
Then next sub-process extracts all the features of characters and produces the pixels according to
feature of character. Then output of this process is used to train the neural network and produces the
final result. Thus, recognition of handwritten characters is not a single process; it is the combination of
many processes such as scanning of characters called as digitization, pre-processing, segmentation,
feature extraction, classification and post-processing. By the combination of these processes, the
desired output is obtained.
For recognition of handwritten characters, HBCR machine depends on learning process in which back
propagation algorithm takes input from user. In this learning process, training and testing of characters
is done. A library is made in which the information of text segments is stored which are used for future
comparisons. This library helps in acceptance and rejection of characters. For example: Character is
written 50 times in library in which 40 fonts are used for training of neural network and rest are used
for testing the network. The importance of neural networks has grown dramatically during the last
fifteen years. A large number of universities and companies are using neural networks and products
based on neural network are available in market.
Neural network works as human brain, thus the architecture of neural network machine is same as the
architecture of human brain. There are hundreds or even thousands of neurons in custom integrated
circuits. In conjunction, the growing interest in learning machines, non-linear dynamics and parallel
computation spurred renewed attention in artificial neural networks. There are so many real world
applications such as pattern recognition, system identification, noise removal etc. in which neural
network is extensively applied. There are also positive results when it is used in character recognition.
Many non-Indian and Indian scripts are recognized accurately and efficiently with the help of neural
networks.
There are too many applications, which can be solved easily using neural networks that are difficult to
solve using traditional methods. A neural network is consisted of three layers i.e. input layer, hidden
layer and the output layer. Each layer consists of small-interconnected processing units. These units
are interconnected with each other via a weighted link. Every unit has individual function but the
combination of these units display complex behaviors. A neural network is a massively paralleldistributed processor that has a natural propensity for storing experimental knowledge and making it
available for use. Neural network behaves like human brain. Neural network acquires knowledge as
human brain acquires knowledge from learning process. Neural network has many advantages over
traditional systems. For example: - It is insensible to noise and easier to handle, because it involves
less human work than other traditional statistical analysis. Neural network can solve problems that do
not have an algorithmic solution or problems whose algorithmic solutions are too complex to find. It
has fewer errors because it can respond to anything and small changes in the input normally do not
cause a change in the output. This behavior of neural network shows its importance.
In the literature survey includes about Indian language scripts as well as
Bengali script and also discussed the previous work on handwritten Bengali character recognition.
Different types of approaches and algorithm related to OCR and classification based on MLP related
to this topic are also discussed.
1.1Problem Statement
Design of an enhanced technique for recognition of handwritten bengali character based on character
features.
1.3 Objectives
The present work has the following objectives
i.
Design an OCR system for recognizing Handwritten Bengali character based on character
feature.
ii.
iii.
1.4 Assumptions
Image preprocessing involves the following steps are assumed.
(i) The input image should contain only segmented handwritten Bengali character .Character
Extraction from a scanned document.
(ii) Skew detection & correction
(iii) Background noise removal
(iv) Skeletonization
This thesis is assumed that the input image is available after undergoing all the process. These can be
incorporated into thesis.
1.5Organization of Thesis
The first Chapter introduces the project work and it covers Problem statement, objective,
assumptions & scope of the project.
The second Chapter includes the Literature Survey of the project.
The third Chapter describes the concepts involved and problem analysis of the work.
The fourth Chapter includes the detail description of implementation with block diagrams of the
project.
Result & Interpretation are discussed in Chapter five.
Conclusion and future scope of the work has been included in the Chapter six.
Chapter seven contains references/ bibliography of the project.
The Appendix I contains the codes.
The Appendix II contains the sample output of the project.
CHAPTER 2
LITERATURE SURVEY
Indian language scripts are fundamentally non-cursive in nature, where the aksharas (characters) are
written independently, separated by space or pen-lifts. However, these scripts often contain a large
number of characters that have complex spatial layout of strokes. Indian scripts have compound
characters, which are combinations of multiple consonants and vowels. The handwriting synthesis
process should hence model all the possible variations of characters and their combinations to be able
to generate any given text. This makes the problem of synthesis; extremely complex in the case of
Indian language scripts. There are many other properties of the Indian scripts that are not seen in
Roman[40].
Bangali, the second most popular language in India and the fifth most popular language in the world,
is an ancient Indo-Aryans language. Bangali is one of the most widely spoken languages in the
world.More than 200 million people in the eastern part of Indian subcontinent speak in this language.
Bangali script alphabet is used in texts of Bangali, Assamese and Manipuri languages. Bangali is a
very rich and old language; the matter of regret is its computerization has not yet gone much far. In
fact, dedicated research and development for Bangali computerization has just been started from the
last decade.Bangali scripts are moderately complex patterns. Unlike simple juxtaposition in Roman
scripts, each word in Bangali scripts is composed of several characters joined by a horizontal line
(called Maatra or head-line) at the top [26]. Often there may be different composite characters and
vowel and consonant signs (Kaar and Falaa symbols)[27-28]. Among the characters, the vowels
often take modified shapes in a word. Such characters are called modifiers or allographs (in Bangla
Kaar).Consonant modifiers are possible (calledFalaa). In a single syllable of a word, several
consonant characters may combine to form a compound character that partly retains the shape of the
constituent characters (e.g. + Da, Ka + Ta, Va + Ra-falaa, Na +Daa + Ra-falaa) [27-29]. Each syllable
in a Bengali word can be divided into three horizontal layers [41]. All the basic alphabets, compound
characters and numerals have almost same width whereas the modifiers and punctuations vary in their
width and height. Most of the characters of Bengali alphabet set have the property of intersection of
two lines in different positions. Many characters have one or more corner or sharp angle property.
Some characters carry isolated dot along with them [30].
Character recognition is a process, which associates a symbolic meaning with object (letters, symbols
and numbers) drawn on an image. It may be classified as offline and online. In case of online character
recognition, there is real time recognition of characters. Offline character recognition, the
typewritten/handwritten character is typically scanned in form of a paper document and made
available in the form of a binary or gray scale image to the recognition algorithm. The major
difference between Online and Offline Character Recognition is that Online Character Recognition has
real time contextual information but offline data does not [31-33].
Optical Character Recognition (OCR) is still an active area of research, especially
for handwritten
text. Success of the commercially available OCR system is yet to be extended to handwritten text. It is
mainly due to the fact that numerous variations in writing styles of individuals make recognition of
handwritten characters difficult. Past work on OCR of handwritten alphabet and numerals has been
mostly found to concentrate on Roman script [24], related to English and some European languages,
and scripts related to Asian languages like Chinese[25], Korean, and Japanese. Among Indian scripts,
Devnagri, Tamil, Oriya and Bengali have started to receive attention for OCR related research in the
recent years. Out of these, Bengali is the second most popular script and language in the Indian
subcontinent and the fifth most popular language in the world. As a script, it is used for Bengali,
Ahamia and Manipuri languages. Bengali, which is also the national language of Bangladesh, is the
fifth most popular language in the world. So is the importance of Bengali both as a script and as a
language. But evidences of research on OCR of handwritten Bengali characters, as observed in the
literature, are a few in numbers. Not only because of numerous variation of writing styles of different
individuals but also for the complex nature of Bengali alphabet, automatic recognition of handwritten
Bengali characters still poses some potential problems to the researchers. Compared to Roman
alphabet, basic Bengali alphabet consists of a much larger number of characters. The number of
characters in basic Bengali alphabet is 50. And some characters therein resemble pair wise so closely
that the only sign of small difference left between them is a period or a small line.
OCR is one of the oldest ideas in the history of pattern recognition using computers. In recent time,
Bengali character recognition becomes the field of practical usage. In character recognition, the
process starts with reading of a scanned image of a series of characters, determines their meaning, and
finally translates the image to a computer written text document.
10
Many researches have been done on character recognition in last 56 years. Some books [1-3] and
many surveys [4, 5] have been published on the character recognition. Most of the work on character
recognition has been done on Japanese, Latin, Chinese characters in the middle of 1960s.
Preprocessing operations include binarization, contour smoothing, noise reduction, skew detection of a
digital image so that subsequent algorithms along the road to final classification can be made simple
and more accurate. Reference [6] presents a good work on preprocessing and segmentation .Here preprocessing stage consists of 4 steps - compression, skew correction, binarization, noise removal. In
this paper the nearest neighbor interpolation method is used for scaling down the original image for
fast processing and accurate results.
During pre-processing the input RGB image in converted to gray scale image.[7] consider the OTHUs
algorithm for gray scale conversion with good flexibility. In this paper the OTSU methods is used for
gray scale to binary image conversion. The principal idea is to convert images of text documents such
as those obtained from scanning a document into editable texts. This report does not address the preprocessing steps such as skew correction and noise reduction, so the documents are assumed to preprocess by another tool in the pipeline. For training and recognition, the input is then first converted to
a binary image, and then into to a 25x25 pixel2 image; the only feature extracted from the images is a
625-bit long vector, which is then trained or classified using a Kohonen neural network. The OCR
shows excellent performance for documents with single typeface. The work in progress is extending it
to handle multiple typefaces. 98% character recognition accuracy is reported.
The work of J.U. Mahmud, Md. F. Raihan and C. M Rahman [8] is concerned with a complete optical
character recognition (OCR) system for Bengali character. Recognition is done for both isolated and
continuous printed multi font Bengali characters. Pre-processing steps includes segmentation in
various levels, noise removal and scaling. Free man chain code has been calculated from scaled
character which is further processed to obtain a discriminating set of feature vectors for the recognizer.
The unknown samples are classified using feed forward neural network based recognition scheme. It
has been found from experimental results that success rate is approximately 98% for isolated
characters and 96% for continuous character.
Segmentation is an operation that seeks to decompose an image of sequence of characters into sub
images of individual symbols. Character segmentation is a key requirement that determines the utility
11
of conventional Character Recognition systems. It includes line, word and character segmentation.
Character segmentation is a necessary preprocessing step for character recognition in many
handwritten word recognition systems. Dipankar Das and Rubaiyat yashmin shows [9] the projection
based heuristic technique for segmenting the Bengali handwritten numerals. The results, based on this
approach are quite satisfactory for the next classifier stage. In this approach the character matrices
from each numerals are extracted, normalized then passed through an ANN classifier for classification.
It is observed that the accuracy level of this approach is 100%.
A fuzzy technique for segmentation of handwritten Bengali word images is presented in [10]. It works
in two steps. In first step, the black pixels constituting the Matra (i.e., the longest horizontal line
joining the tops of individual characters of a Bengali word) in the target word image is identified by
using a fuzzy feature. In second step, some of the black pixels on the Matra are identified as segment
points (i.e., the points through which the word is to be segmented) by using three fuzzy features. On
experimentation with a set of 210 samples of handwritten Bengali words, collected from different
sources, the average success rate of the technique is shown to be
95.32%.
Segmentation work [11] based on certain characteristics of Bengali handwriting methods; different
zones across the height of the word are detected. These zones provide certain structural information
about the constituent characters of the respective word. In Bengali handwritten texts often there is
overlap between rectangular hulls of successive characters, as such the characters are seldom vertically
separable. This method of recursive contour following in one of the zones across the height of the
word is used to find out the extents within which the main portion of the character lies. If the
successive characters are not touching in the zone of contour following, the algorithm gives fairly
good results. Another good work on segmentation for Bengali handwritten characters using
superimposed matrices[12].In this system, the Bengali text, accepted as an image file, is first
segmented into lines and words and then each word is segmented into characters. Then the boundary
of each character is determined. The characters are scaled to a standard size using an image scaling
algorithm and are stored in a 32X32 matrix. This matrix is then compared with a knowledge base
where all recognized characters given by various persons are stored in superimposed form. Finally,
depending on the similarity of the character with the stored one, the system recognizes the character to
12
use in the output. This system is suitable to convert handwritten texts into printed documents and the
system achieves 100% accuracy.
After pre-processing and segmentation of Bengali handwritten document, features of the characters are
extracted. This step is heart of the system. This step helps in classifying the characters based on their
features. In fact, the variation depends on font styles, document noise, photometric effect, document
skew and poor image quality. The large variation in shapes makes it difficult to determine the number
of features that are convenient prior to model building. Though many kinds of features have been
developed and their test performances on standard database have been reported to classify and
recognize the character. Bengali is the second most popular script and language in the Indian
subcontinent and the fifth most popular language in the world. The work presented by S. Basu et al.
[13] involves the design of a Multi Layer Perceptron (MLP) based classifier for recognition of
handwritten Bengali alphabet using a 76 element feature set. The feature set developed for
representing handwritten characters of Bengali alphabet includes 24 shadow features, 16 centroid
features and 36 longest-run features. Recognition performances of the MLP designed to work with this
feature set are experimentally observed as 86.46% and 75.05% on the samples of the training and the
test sets respectively. The work has useful application in the development of a complete OCR system
for handwritten Bengali text. Some pixel-based and shape-based features are chosen for the purpose of
recognition of both printed and handwritten Bengali numerals [14]. Such mixed numerals may appear
in documents like application forms, postal mail, bank checks etc. The pixel-based features are
normalized pixel density over 4 X 4 blocks in which the numeral bounding-box is partitioned. The
shape-based features are normalized position of holes, end-points, intersections and radius of curvature
of strokes found in each block. Multi-layer neural network architecture was chosen as classifier of the
mixed class of handwritten and printed numerals. For the mixture of twenty three different fonts of
printed numerals of various sizes and 10,500 handwritten numerals, an overall recognition accuracy of
97.2% has been achieved.
In [15] Zone centroid and Image centroid based Distance metric feature extraction is proposed. The
character centroid is computed and is further divided in to n equal zones. Average distance from the
character centroid to the each pixel present in the zone is computed. Similarly zone centroid is
computed and average distance from the zone centroid to each pixel present in the zone is computed.
13
This procedure is repeated for all the zones/grids/boxes present in the numeral image. There could be
some zones that are empty, and then the value of that particular zone image value in the feature vector
is zero. Finally 2*n such features are extracted. Nearest neighbor and Feed forward back propagation
neural network classifiers are used for subsequent classification and recognition purpose. Oriented
features in the word are extracted with the Gabor filters. In [16] it is estimated that the Gabor filter
parameters form the grayscale images. After filtering the images and comparing with Bengali text
images (sample file contains the fonts) the output text is created. The system achieves an average
conversion rate of 65%for the writing being correctly classified within the top five positions. [17]
deals with a recognition system for unconstrained off-line Bengali handwritten numerals. To take care
of variability involved in the writing style of different individuals, a robust scheme is presented here.
The scheme is mainly based on new features obtained from the concept of water overflow from the
reservoir as well as topological and structural features of the numerals. The scheme is tested obtained
an overall recognition accuracy of about 92.8% from 12000 data.
A work on multi-stage character recognition system for an Indian script, namely, Bengali (also called
Bengali) using fuzzy features and multilayer perceptron (MLP)is represented by Samik Surul[18].The
fuzzy features are extracted from Hough transform of a character pattern pixels. First define a number
of fuzzy sets on the Hough transform accumulator cells. The fuzzy sets are then combined by t-norms
to generate feature vectors from each character. A set of fuzzy linguistic vectors is next generated from
these feature vectors. The MLPs used for classification have the fuzzy features as inputs. The MLP
outputs also represent the belongingness of an input pattern to different fuzzy character pattern classes.
To improve the recognition accuracy of Bengali characters, divide all the patterns into three distinct
sets. Each set of characters is once again divided into a number of mutually exclusive character pattern
classes. During recognition, the class of each pattern is first determined, followed by recognition of the
actual character within that class. Recognition accuracy of the system is more than 98%. Ray &
Chatterjee [22] presented a recognition system based on a nearest neighbor classifier-employing
feature extracted by using a string connectivity criterion. A complete OCR for printed Bengali is
reported in the work by Chaudhuri & U Pal [23], in which a combination of template and featurematching approach is used. A histogram-based thresholding approach is used to convert the image into
binary images. For a clear document the histogram shows two prominent peaks corresponding to white
and black regions. The threshold value is chosen as the midpoint of the two-histogram peaks. Skew
14
angle is determined from the skew of the headline. Text lines are partitioned into three zones and the
horizontal and vertical projection profiles are used to segment the text into lines, words, and
characters. Primary grouping of characters into the basic, modified and compound characters is made
before the actual classification. A few stroke features are used for this purpose along with a tree
classifier where the decision at each node of the tree is taken on the basis of presence/absence of a
particular feature. The compound character recognition is done in - two stages: In the first stage the
characters are grouped into small sub-sets by the above tree classifier. At the second stage, characters
in each group are recognized by a run-based template matching approach. Some character level
statistics like individual character occurrence frequency, bigram and trigram statistics etc. are utilized
to aid the recognition process. For single font, clear documents 99.10% character level recognition
accuracy is reported. In[19]features are obtained by computing local chain code histograms of input
character shape. Comparative recognition results are obtained between computation of the above
feature based on the contour and one-pixel skeletal representations of the input character image. Also,
the classification results are obtained after down sampling the histogram feature by applying Gaussian
filter in both these cases. Multilayer perceptron (MLP) trained by back propagation (BP) algorithm are
used as classifiers in the present study. Near exhaustive studies are done for selection of its hidden
layer size. An analysis of the misclassified samples shows an interesting error pattern and this has been
used for further improvement in the recognition results. Final recognition accuracies on the training
and the test sets are respectively 94.65% and 92.14%.
An Artificial Neural Network (ANN) is an information-processing paradigm that is inspired by the
way biological nervous systems[39], such as the brain, process information. The key element of this
paradigm is the novel structure of the information processing system. It is composed of a large number
of highly interconnected processing elements (neurons) working in unison to solve specific problems.
ANNs, like people, learn by example.
An ANN is configured for a specific application, such as pattern recognition or data classification
through a learning process. Learning in biological systems involves adjustments to the synaptic
connections that exist between the neurons. This is true of ANNs as well. An Artificial Neural
Network is a network of many very simple processors units, each possibly having a small amount of
local memory. The units are connected by unidirectional communication channels connections,
15
which carry numeric as opposed to symbolic data. The units operate only on their local data and on the
inputs they receive via the connections.
The work presented by Alessandro L. Koerich [20] tackles the problem of unconstrained handwritten
character recognition using different classification strategies. For such an aim, He built four multilayer
perceptron classifiers (MLP) and used into three different classification strategies: combination of two
26class classifiers; a 26metaclass classifier and a 52class classifier. The Experimental results
showed that better recognition performance is achieved by the metaclass classifier in which the
uppercase and the lowercase representations of the characters are merged into single classes. The
recognition rate for 52-class classifier ranges in between 62.98% and 96.66% where as for the
metaclass classifier ranges in between 84.97 %and 98.96%.
The work presented by Mirosaw Kordos et al. [21] describes a new algorithm named as variable step
search algorithm which is based on a simple search procedure that changes one network parameter at a
time. Visualization of learning trajectories and MLP error surfaces is used for the algorithm design and
optimization. The algorithm is compared to three other MLP training algorithms: LevenbergMarquardt (LM), scaled conjugate gradient (SCG), and training based on numerical gradient. It has
been shown that the proposed variable step search algorithm is fast, can find very good solutions, does
not require multistart and has low memory requirements. It is also very simple to program since it does
not require calculation of derivatives and matrices, therefore it is quite surprising that in empirical tests
it usually outperforms both LM and SCG.
16
CHAPTER 3
17
The primary alphabet of Bengali script is quite large compared to the alphabet sets of English and
other western languages. The alphabet of the modern Bengali script consists of 11 vowels and 39
consonants. These characters are called basic characters. The basic characters of Bengali script are
shown in Fig.3.1. There are 10 numerals in Bengali script. These are shown in Fig.3.2.
Fig. 3.1 Basic character in Bangla script. (The first 11 characters are vowels while
Others are consonants.)
18
The concept of upper and lower case (as in English) is absent here.
each word in Bangali scripts is composed of several characters joined by a horizontal line
(called Maatra or head-line) at the top.
Except very few characters and symbols (e.g. Ae, Oy, O, Ow, Kha, Ga, Ungo, Nio etc), almost
all Bengali alphabets and symbols have a horizontal line at the upper part called maatra Some
are shown in Fig.3.3.The characters with maatra remain connected together through their
maatra and other characters and symbols (e.g. Khondota, Bishorgo, Ungo, Ae, Oy etc) remain
isolated in the word Some are shown in Fig.3.4.
The vowel A (
A(
19
Fig 3.5(a)Modified vowel.Fig 3.5(b) vowels may take different modified shapes
Fig. 3.5(c)consonant modifier
In Fig. 3.5(a) modified vowel shapes and their attachment with a consonant character is shown. If the
first character of the word is a vowel then it retains its basic shape. For two consecutive vowels in a
word, the second one also retains its basic shape. Some vowels may take different modified shapes
when attached to some consonant characters. They also change the shape of some consonant
characters to which they are attached (see Fig. 3.5(b)).
20
21
Online Character
Recognition
Offline Character
Recognition
Optical Character
Recognition
Handwritten
Character
Recognition
Printed
Character
Recognition
Optical Character
Recognition
Magnetic Character
Recognition
Handwritten
Character
Recognition
Printed
Character
Recognition
22
and are stored in order [24]. It is generally accepted that the on-line method of recognizing
handwritten text has achieved better results than its off-line counterpart.
3.3.2 Offline Character Recognition
In case of Offline character recognition, the typewritten/handwritten character is typically scanned in
form of a paper document and made available in the form of a binary or gray scale image to the
recognition algorithm. Offline character recognition is a more challenging and difficult task as there is
no control over the medium and instrument used. The artifacts of the complex interaction between the
instrument medium and subsequent operations such as scanning and binarization present additional
challenges to the algorithm for the offline character recognition.
23
Scanned Document
Data Acquisition
Binarization
Noise Removal
Pre-Processing
Skeletonization
Skew Detection & Correction
Line Segmentation
Word Segmentation
Segmentation
Character Segmentation
Feature Extraction
Classification
Recognition
24
25
3.4.4 Skeletonization
Skeletonization is also called thinning. Skeletonization refers to the process of reducing the width of a
line like object from many pixels wide to just single pixel. This process can remove irregularities in
letters and in turn, makes the recognition algorithm simpler because they only have to operate on a
character stroke, which is only one pixel wide. It also reduces the memory space required for storing
the information about the input characters and no doubt, this process reduces the processing time too.
26
The image before skew correction is shown in Fig. 3.8.The image after skew correction is
shown in Fig. 3.9.
3.4.6 Segmentation
It is an operation that seeks to decompose an image of sequence of characters into sub images of
individual symbols. Character segmentation is a key requirement that determines the utility of
conventional Character Recognition systems. It includes line, word and character segmentation.
Different methods used can be classified based on the type of text and strategy being followed
like recognition-based segmentation and cut classification method[41].
Line segmentation
In a Bangla printed script, the text lines are almost of same height, provided that the script is
written in a specific font size. If the script is composed by a type-machine, surely the font size
will be uniform everywhere. Between two text lines, there is a narrow horizontal band with
either no pixel or very few pixels. Hence, applying horizontal projection profile (HPP) and
detecting the valleys in it, text line bands can be retrieved [34-37].
27
Word segmentation
From the extracted text lines, words get separated. Usually, applying vertical projection profile
(VPP) and detecting some specific threshold exceeding horizontal gaps, words are separated
from a text line [34-36]. Computer composed scripts may contain different font sizes and
different styles (i.e. bold, italic etc) and adversely affect the threshold value for identifying
isolated words. Hence, identifying an effective threshold value is very difficult. It may change
twice or more even a single text line. On the other hard, since the style of type-machine
composed scripts is very specific, it is much easier to calculate the threshold value of the gap
between two consecutive words in a line.
Character segmentation
Segmentation of characters from the isolated words is the most challenging part of the script
segmentation phase [34-36]. Since, in computer composed scripts some characters in a container
word may partially overlap with one another, it becomes very difficult to isolate those characters
properly. Especially the modifiers (both vowels and consonants) most of the time coincide with
the modifying characters. These kinds of non-trivial combinations of characters make the whole
process of character segmentation extremely challenging. Besides, some symbols, like ChandraBindu, often come between two consecutive characters in a word; then isolating those becomes a
tough job. This problem can be overcome by applying contour tracing mechanism [38] or by
implementing greedy search technique [34] for letter segmentation.
3.4.6 Feature Extraction
The segmented Bangla characters are converted into a real valued vector called feature form of
0s and 1s that characterizes the essential information content of the pattern. Each character has
some features, which play an important role in pattern recognition. Handwritten Bengali
characters have many particular features. Feature extraction describes the relevant shape
information contained in a pattern so that the task of classifying the pattern is made easy by a
formal procedure. Feature extraction stage in OCR system analyses these character segment and
selects a set of features that can be used to uniquely identify that character segment. Mainly, this
stage is heart of OCR system because output depends on these features. Feature extraction is the
name given to a family of procedures for measuring the relevant shape information contained in
28
a pattern so that the task of classifying the pattern is made easy by a formal procedure. Among
the different design issues involved in building a recognizing system, perhaps the most
significant one is the selection of set of features.
3.4.8 Classification
Classification stage is the main decision making stage of the system and uses the features
extracted in the previous stage to identify the text segment according to preset rules.
Classification is concerned with making decisions concerning the class membership of a pattern
in question. The task in any given situation is to design a decision rule that is easy to compute
and will minimize the probability of misclassification relative to the power of feature extraction
scheme employed. Patterns are thus transformed by feature extraction process into points in d
dimensional feature space. A pattern class can then be represented by a region or sub-space of
the feature space. Classification then becomes a problem of determining the region of feature
space in which an unknown pattern falls.
29
features of the character image are obtained. The second approach is to compute the Diagonal
Distance features from four corners of the minimal square containing the character image. Here a
set of 4 features of each character image are obtained. The features are computed from 64x64
pixel size binary images of alphabetic characters. This feature set is the input of MLP based
classifier to classify the given input character.
Classification consists of two phases training phase and testing phase. Here MLP based
classifier is used to recognize handwritten Bengali character. An MLP consists of one input
layer, one output layer and a number of hidden or intermediate layers. Here 35 different training
sets, each of which consists of 15 alphabetic character samples are used for training and other 5
different alphabetic character samples of each character are used for testing phase.
30
CHAPTER 4
31
extractionn algorithm
m and proposed Shadow
w based featture extractiion algorithhm and Diaggonal
distance feature extraaction algoriithm.
Pre-proocessing
Feature Extraction
E
Classificaation using
MLP
M Based Classifieer
Original
character
existing inn the
Library
Scchool Of Ed
ducation Techhnology, Jaddavpur Univversity
3
32
Scanned Image
Feature Extraction
Shadow based Feature (96)
(Proposed)
Classification
Training Class
Testing
33
Data Acquisition
The input images are acquired from documents containing Bengali text by using scanner as an
input device. Scanned images are then stored in some picture file such as BMP, JPG etc.
RGB to gray conversion
In the pre-processing 1st stage is to convert the input RGB image into gray scale image.
Binarization
Binarization is the process of converting a gray scale image (0 to 255 pixel values) into binary
image (0 and 1 pixel values) by selecting a threshold value in between 0 to 255(here threshold
value is 128).
Feature extraction
Each character has some features, which play an important role in pattern recognition. Each
character have many particular features. Feature extraction describes the relevant shape
information contained in a pattern so that the task of classifying the pattern is made easy by a
formal procedure. Feature extraction stage in HBCR system analyses these Bengali character
segment and selects a set of features that can be used to uniquely identify that character segment.
Mainly, this stage is heart of HBCR system because output depends on these features. Feature
extraction is the name given to a family of procedures for measuring the relevant shape
information contained in a pattern so that the task of classifying the pattern is made easy by a
formal procedure.
Here some feature extractions techniques are implemented along with two new feature extraction
approaches are also implemented. All theses implemented feature extraction techniques are
discussed below with diagram.
34
Firstly we have to know how to calculate length of projection of each octant of the character
image-
Fig4.3(a)
Fig4.3(b)
Fig4.3(c)
1. The projection length of the hypotenuse is calculated by combining the light projection from
two directions -i.e. base and perpendicular shown in the fig4.3 (a).
2. The projection length of the base is calculated by the light projection from hypotenuse is
shown in the fig4.3 (b).
3. The projection length of the perpendicular is calculated by the light projection from
hypotenuse is shown in the fig4.3 (c).
Fig 4.3. An illustration for shadow based features. Each character image is enclosed within
a minimal square & divided into 4 quadrants. Each quadrant is further divided into eight
octants.
35
36
37
Centroid of the
pixels containing
38
Fig 4.7(a) character image enclosed within a minimal square is now divided into nine
overlapping square regions.
39
1
1
1
1
0
0
0
0
0
0
1
0
4
0
0
0
0
2
4
2
2
0
0
2
4 4
2 0
2 0
1 0
1 0
0 0
Sum =
Length of the
Longest Bar
4
2
2
1
1
2
12
Fig4.7(b) An illustration for computation of the row wise longestrun feature.(Every pixel
position in each row of the image is marked with the length of the longest bar that fits
consecutive black pixels along the same row)
Step1. The handwritten data is converted into digital form by scanning.
Step2. The image of that data is fed to the pre-processing phase.
Step3. The digital image converted into the gray scale image. Each character image is enclosed
within a minimal square.
Step4. Convert a gray scale image (0 to 255 pixel values) into binary image (0 and 1 pixel
values) by selecting a threshold value in between 0 to 255(here threshold value is 128).
Step5. Each binary character image enclosed within a minimal square is now divided into nine
overlapping square regions is shown in the fig 4.7(a)..
Step6. Coordinates(x,y) of top left corners of all nine overlapping square regions are {(x,y) | x=0,
h/4, 2h/4 and y=0, w/4, 2w/4}, where h and w denote the height and the width of the minimal
square.
Step7. Row-wise longest-run feature is computed by considering the sum of the lengths of the
longest bars that fit consecutive black pixels along each of all the rows of a square region is
illustrated in fig4.7(b).
40
Step8.The three other longest-run features are computed in the same way but along the column
wise and two major diagonal wise directions within the rectangle separately.
Step9.Each square region, 4 longest-run features are computed row wise, column wise and along
two of its major diagonals.
Step10. 9x4=36 longest-run features are computed from each character image.
Step11.36 features are obtained to feed into the MLP based classifier as input to classify
properly.
Classification
Classification consists of two phases training phase and testing phase. Here MLP based
classifier is used to recognize handwritten Bengali character. An MLP consists of one input
layer, one output layer and a number of hidden or intermediate layers. The output from every
neuron in a layer of the MLP is connected to all inputs of each neuron in the immediate next
layer of the same. Neurons in the input layer of the MLP are all basically dummy neurons as they
are used simply to pass on the input to the next layer just by computing an identity function each.
The numbers of neurons in the input and the output layers of an MLP are chosen depending on
the problem to be solved. The number of neurons in other layers and the number of layers in the
MLP are all determined by a trial and error method at the time of its training. An ANN requires
training to learn an unknown input-output relationship to solve a problem. A single layer MLP,
i.e., an MLP with one hidden layer is chosen here. This is mainly to keep the computational
requirement of the same low without affecting its function approximation capability. According
to Universal Approximation theorem [43], a single hidden layer is sufficient to compute a
uniform approximation to a given training set.
41
Training phase
The program trains the network to recognize the characters. This network takes input-output
vector pairs during training. The network trains its weight array to minimize the selected
performance measure, i.e., error using back propagation algorithm. Here a database consists of
35 different training sets, each of which has 15 alphabetic character samples and is formed by
collecting optically scanned handwritten Bengali characters.
The following are taken as inputs from the user:
a) The input pattern file
b) No. of neurons in each hidden layer
c) Error value for convergence
The output of training program is a file which contains modified weights of different connection
of the network. This file is used as the input to testing program. This file also contains the values
of numbers of neurons in input layer, Hidden layers, output layer, value of learning rate and
momentum factor so that used is no require to enter the values during testing.
Following parameters are used for training of Neural Networks:
No. of neurons in input Layer: 100
No of neurons in Hidden Layer: 50
No of epochs: 5000
No. of neurons in output Layer: 35
Transfer Function Used for Layer 1: Logsig
Transfer Function Used for Layer 2: Logsig
Adaption Learning Function: Traingdx
Performance Function: MSE
Network Type = Feedforword Back propagation
Goal=0.001
Testing phase
Each set of character images contain 5 characters for testing purpose. Beside these character
images, other character images can be used for testing.
School Of Education Technology, Jadavpur University
42
After training is complete, a test pattern is given to the neural network and the results are
compared with the desired result. Difference between the two values gives the error. Percentage
accuracy is found as follows:
% Accuracy = No of characters found correctly *100
Total no of patterns
43
CHAPTER 5
Handwritten Bengali Character sets are taken. These steps are followed to obtain best accuracy
of input handwritten Bengali character image. First of all, training of system is done by using
different data set or sample. And then system is tested for few of the given sample, and accuracy
is measured. The data set was partitioned into two parts. The first part is used for training the
system and the second was for testing purpose. For each character, the proposed feature were
computed and stored for training the network to classify. The results obtained from the proposed
algorithms are displayed in the table.5.1.and table 5.2 contains the comparision of the
recognition accuracy of proposed algorithm with the algorithm of S.Basu et.al[13]. In fig 5.is
showing the Curves variation of the Recognition performance of the proposed algorithm with the
algorithm of S. Basu et.al[13]. This variance is very small but it is there.
MLP based classifier consists of three network layer one input layer, one hidden layer and one output
layer are taken. If number of neurons in the hidden layer is increased, then a problem of allocation of
required memory is occurred. Also, if the value of error tolerance is high, desired results are not
obtained, so changing the value of error tolerance i.e. say, high accuracy rate is obtained. Also the
network takes more number of cycles to learn when the error tolerance value is less rather than in the
case of high value of error tolerance in which network learns in less number of cycles and so the
learning is not very fine.
44
S (JA)
15
80
45
Table 5.2: Comparison of Recognition Accuracies of shadow feature of S.Basu et.al[13] &
proposed algorithms
% of Recognition Accuracy of
% of Recognition Accuracy in
Letters
shadow feature of S.Basu
Proposed Algorithm
et.al[13]
A (A)
75
75
B (AA)
80
80
I (AI)
40
100
K (AU)
60
100
h (BA)
66
100
I (BHA)
60
60
Q (CA)
75
75
R (CHA)
75
100
c (DA)
60
80
X (DDA)
66
100
Y (DDHA)
75
100
d (DHA)
80
100
t (DRHA)
75
75
H (E)
75
75
N (GA)
75
75
O (GHA)
60
80
L (KA)
60
80
M (KHA)
60
80
m (LA)
60
80
j (MA)
60
80
f (PA)
60
80
g (PHA)
60
80
l (RA)
50
100
p (SA)
60
80
n (SHA)
50
50
a (TA)
60
80
b (THA)
60
80
V (TTA)
60
80
W (TTHA)
60
100
E (U)
80
80
F (UU)
60
60
q (HA)
60
80
C (I)
60
80
D (II)
60
80
S (JA)
75
80
46
fig5. Showing the Curves variation of the Recognition performance of the proposed
algorithm with the algorithm of S. Basu et.al[13]
CHAPTER 6
47
Conclusion
Handwritten Bengali character recognition based on character feature is discussed here. Shadow
based feature algorithm and diagonal distance feature algorithm are implemented and the
recognition accuracy compared with the state-of-the-art. An MLP based classifier is used. There are
lots of ways to implement this project but recognition is done based on character feature.
Recognition approaches heavily depend on the nature of the data to be recognized. Since handwritten
Bengali characters could be of various shapes and size, the recognition process needs to be much
efficient and accurate to recognize the characters written by different users.
Future Scope
Recognition accuracy can be increased by taking more training character sets. This recognition
system can be extended for the recognition of Bengali compound characters, words, sentence and
documents, neumerals and other multingual script.
CHAPTER 7
School Of Education Technology, Jadavpur University
REFERENCES
48
[1] H. Bunke and P. S. P. Wang, Handbook of Character Recognition and Document Image
Analysis,
World Scientific Publishing Company, 1997.
[2]Stephen V. Rice, George Nagy and Thomas A. Nartker, Optical Character Recognition: An
Illustrated Guide to the Frontier, Kluwer Academic Publications, 1999.
[3]S. Mori, H. Nishida and H. Yamada, Optical Character Recognition, John Wiley & Sons,
1999.
[4]S. Mori, C. Y. Suen and K. Yamamoto, Historical review of OCR research and
development. Proceedings of the IEEE, Vol. 80(7), pp. 1029-1058, 1992.
[5]U. Pal and B. B. Chaudhuri, Indian script character recognition, Pattern Recognition, Vol.
37(9), pp. 1887-1899, 2004.
[6] K.H.Aparna and V.S. Chavravarthy,A complete OCR system development of Tamil
Magazin documents Tamil Internet 2003, Chennai, August, 22-24, 2003.
[7]Adnan Md. Shoeb Shatil , Research Report on Bangla Optical Character Recognition Using
Kohonen network Center for Research on Bangla, 29 Jul 2009
[8]J.U. Mahmud, Md. F. Raihan and C. M Rahman, A Complete OCR System for Continuous
Bengali Characters Proc. of the Conf. on. Convergent Technologies,2003.
[9]Dipankar Das and Rubaiyat yashmin, Segmentation and Recongnition of Unconstrained
Bengla Handwritten Numeral, Asian journal of Information Technology 5(2)-155-159, 2006
[10]Subhadip Basu , Ram Sarkar , Nibaran Das, Mahantapas Kundu , Mita Nasipuri,Dipak
Kumar Basu , A Fuzzy Technique for Segmentation of Handwritten Bangla Word Images,
Proceedings of the International Conference on Computing: Theory and Applications
(ICCTA'07).
[11]A. Bishnu and B. B. Chaudhuri, Segmentation of Bangla handwritten text into characters by
recursive contour following, Proc. 5th ICDAR, pp.402-405,1999.
[12]Ahmed Shah Mashiyat,Ahmed Shah Mehadi and Kamrul Hasan Talukder,Bangla off-line
Handwritten Character Recognition Using Superimposed
Matrices 7th International
Conference on Computer and Information Technology (ICCIT 2004),26-28 December, 2004
49
50
51
[37] U. Pal, S. Sinha and B. B. Chaudhuri, Multi-Script Line Identification from Indian
Documents,Proc. 7th ICDAR, 2003.
[38] A. Bishnu and B. B. Chaudhuri, Segmentation of Bangla Handwritten Text into Characters
by Recursive Contour Following, Proc. of ICDAR,1999, pp. 402-405.
[39] Anil k. Jain, Jianchang Mao, K.M. Mohiuddin, Artificial Neural Network: A Tutorial,
IEEE 0018-9162/96, March 1996.
[40] C. V. Jawahar, A. Balasubramanian, " Synthesis of Online Handwriting in Indian
Languages in Proc.of the Tenth International Workshop on Frontiers in Handwriting
Recognition, 2006.
[41] Arif Billah Al-Mahmud Abdullah and Mumit Khan, A Survey on Script Segmentation for
Bangla OCR
[42]Anuradha B, Koteswarrao B 2006 An efficient Binarization technique for old documents.
Proc. Of International conference on Systemics,Cybernetics, and Inforrmatics(ICSCI2006),
Hyderabad, pp771-775.
[43] N. Das, R. Sarkar, S. Basu, M. Kundu, M. Nasipuri, D.K. Basu, A Soft Computing
Paradigm for Handwritten Digit Recognition with application to Bangla Digits, Proc. of
International Conference on Modelling and Simulation ( MS07 India), vol. 2, pp. 771-774,
Kolkata, Dec. 3-5, 2007.
[44] A. Hushizume et al., A method of detecting the orientation of aligned components, PRL,
4(2): 125-132, 1986
[45] L. OGorman, The document spectrum for page layout analysis, IEEE Trans. on PAMI,
15(11): 11621173, 1993.
52
I=imread('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\SA\310.bmp');
53
54
fprintf(fid,'%f\t',a2(i));
fprintf(fid,'%f\t',b2(i));
fprintf(fid,'%f\t',e2(i));
fprintf(fid,'%f\t',a3(i));
fprintf(fid,'%f\t',b3(i));
fprintf(fid,'%f\t',e3(i));
fprintf(fid,'%f\t',a4(i));
fprintf(fid,'%f\t',b4(i));
fprintf(fid,'%f\t',e4(i));
end
%fclose(fid);
for i=1:9
fprintf(fid,'%f\t',r(i));
fprintf(fid,'%f\t',c(i));
fprintf(fid,'%f\t',d1(i));
fprintf(fid,'%f\t',d2(i));
end
%fid=fopen('outputs\27_3.txt','w');
for i=1:4
fprintf(fid,'%f\t',d(i));
end
for i=1:8
fprintf(fid,'%f\t',L(i));
fprintf(fid,'%f\t',s(i));
fprintf(fid,'%f\t',s1(i));
end
for i=1:8
fprintf(fid,'%f\t',Cx(i));
fprintf(fid,'%f\t',Cy(i));
end
4A. Sample Code for Shadow Feature Extraction of one Octant (of the total Image) :
function [L,s,s1]=shadow_feature1(I)
K=I;
55
56
d1=0;
for row=1:32
col=row;
if K(row,col)==0
d1=d1+1;
continue;
else
break;
end;
end;
d1=d1/32;
%disp(d1);
%from top-right corner
d2=0;
for row=1:32
col=65-row;
if K(row,col)==0
d2=d2+1;
continue;
else
break;
end;
end;
d2=d2/32;
%from bottom-left corner
d3=0;
for row=64:-1:33
col=65-row;
if K(row,col)==0
d3=d3+1;
continue;
else
break;
end;
end;
d3=d3/32;
%from bottom-right corner
d4=0;
for row=64:-1:33
col=row;
if K(row,col)==0
d4=d4+1;
continue;
else
break;
end;
end;
d4=d4/32;
57
58
%crl=crl+1;
lrl1(col)=lrl1(col)+1;
else
break;
end
end
else
continue;
end
end
end
r=r+max(lrl1);
end
for col=cl:cr
for i=1:64
lrl2(i)=0;
end
for row=rt:rb
crl=0;
if I(row,col)==0
continue;
end
%if i==48
%
break;
%end
if I(row,col)==I(row+1,col)
lrl2(row)=lrl2(row)+2;
x=row+2;
for j=x:rb
if I(row,col)==I(j,col)
%crl=crl+1;
lrl2(row)=lrl2(row)+1;
else
break;
end
end
else
continue;
end
end
c=c+max(lrl2);
end
for col=cl:cr
for i=1:64
lrl3(i)=0;
end
row=rt;
if I(row,col)==0
continue;
end
%if i==48
%
break;
%end
if I(row,col)==I(row+1,col+1)
59
lrl3(row)=lrl3(row)+2;
x=row+2;
for j=x:rb
y=col+1;
if I(row,col)==I(j,y)
%crl=crl+1;
lrl3(row)=lrl3(row)+1;
else
break;
end
end
else
continue;
end
d1=d1+max(lrl3);
row=row+1;
end
for col=cr:-1:cl
for i=1:64
lrl4(i)=0;
end
row=rb;
if I(row,col)==0
continue;
end
%if i==48
%
break;
%end
if I(row,col)==I(row+1,col+1)
lrl4(row)=lrl4(row)+2;
x=row-2;
for j=x:-1:rt
y=col-1;
if I(row,col)==I(j,y)
%crl=crl+1;
lrl4(row)=lrl4(row)+1;
else
break;
end
end
else
continue;
end
d2=d2+max(lrl4);
row=row-1;
end
r=r/(32*32);
c=c/(32*32);
d1=d1/(32*32);
d2=d2/(32*32);
4E. Sample Code for obtaining shadow based features of each octant (of th of the total
Image):
function [L,s,s1]=extended_shadow1(I)
K=I;
60
61
6. Sample Code of constructing array for training & testing the Neural Network:
function [M_BA]=array_construct_BA();
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\17.txt','r');
M1=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\18.txt','r');
M2=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\22.txt','r');
M3=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\59.txt','r');
M4=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\199.txt','r');
M5=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\200.txt','r');
M6=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\202.txt','r');
M7=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\203.txt','r');
M8=fscanf(fid,'%e',[176,176]);
fclose(fid);
62
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\595.txt','r');
M9=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\596.txt','r');
M10=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\598.txt','r');
M11=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\599.txt','r');
M12=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\1218.txt','r');
M13=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\1221.txt','r');
M14=fscanf(fid,'%e',[176,176]);
fclose(fid);
fid=fopen('C:\Documents and
Settings\swati_m\Desktop\Mats\Matlab\Final\Classify\Ba\1231.txt','r');
M15=fscanf(fid,'%e',[176,176]);
fclose(fid);
M_BA=[M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15];
63
M_CA=array_construct_CA();
M_CHA=array_construct_CHA();
M_DA=array_construct_DA();
M_DDA=array_construct_DDA();
M_DDHA=array_construct_DDHA();
M_DHA=array_construct_DHA();
M_DRHA=array_construct_DRHA();
M_E=array_construct_E();
M_GA=array_construct_GA();
M_GHA=array_construct_GHA();
M_KA=array_construct_KA();
M_KHA=array_construct_KHA();
M_LA=array_construct_LA();
M_MA=array_construct_MA();
M_PA=array_construct_PA();
M_PHA=array_construct_PHA();
M_RA=array_construct_RA();
M_SA=array_construct_SA();
M_SHA=array_construct_SHA();
M_TA=array_construct_TA();
M_THA=array_construct_THA();
M_TTA=array_construct_TTA();
M_TTHA=array_construct_TTHA();
M_U=array_construct_U();
M_UU=array_construct_UU();
M_HA=array_construct_HA();
64
M_I=array_construct_I();
M_II=array_construct_II();
M_new=[M_A M_AA M_AI M_AU M_BA M_BHA M_CA M_CHA M_DA M_DDA M_DDHA M_DHA
M_DRHA M_E M_GA M_GHA M_HA M_I M_II M_KA M_KHA M_LA M_MA M_PA M_PHA
M_RA M_SA M_SHA M_TA M_THA M_TTA M_TTHA M_U M_UU];
T=[ones(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) ones(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) ones(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) zeros(1,15) ones(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) ones(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
ones(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) ones(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) ones(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15)
zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15) zeros(1,15);
65
66
67
68
fprintf(fid,'\nClassCon=[');
while i<=siz(1)
for j=1:siz(2)
fprintf(fid,'%1.6f\t',b(i,j));
end
i=i+1;
if i<=siz(1)
fprintf(fid,'\n\t\t');
end
end
fprintf(fid,']');
fclose(fid);
display(b);
plot(b);
69
70
71
ClassCon=[0.000004
0.000002
0.001739
0.000000
0.000048
0.007578
0.971304
0.000729
0.010591
0.000079
0.047503
0.002410
0.000944
0.000007
0.000011
0.000266
0.000011
0.000013
0.000008
0.000734
0.000001
0.000054
0.000001
0.000001
0.000000
0.000048
0.000007
0.000012
0.000009
0.000498
0.000060
0.021542
0.000574
0.000377
72