• No results found

OCR & TTS in Matlab

N/A
N/A
Protected

Academic year: 2021

Share "OCR & TTS in Matlab"

Copied!
58
0
0

Loading.... (view fulltext now)

Full text

(1)

CHAPTER ONE

CHAPTER ONE

INTRODUCTION

INTRODUCTION

1.1

1.1 Project

Project Overview

Overview ::

 This project wil

 This project will demonstrate a kind of editil demonstrate a kind of editing of both image, text , andng of both image, text , and voice technologies. The user will be able to

voice technologies. The user will be able to output the text that is containedoutput the text that is contained in an image or written in t

in an image or written in the editor he editor and read this teand read this text by using the speechxt by using the speech recognition. Also the ability of having an

recognition. Also the ability of having an edited text in a le format of editingedited text in a le format of editing and save this le

and save this le in a specic place in a specic place under the name under the name of recent of recent documentsdocuments that you got from this editor.

that you got from this editor.  This project wil

 This project will explorl explore these ideas by developing Opte these ideas by developing Optical haracterical haracter !ec

!ecognition "O!ognition "O!# # softwarsoftware, and e, and then demonstratithen demonstrating that ng that software software throughthrough a basic implementation of a

a basic implementation of a text to $peech conversion system . The systemtext to $peech conversion system . The system will load an image of any type of for

will load an image of any type of format, mat, extract the teextract the text founded in thisxt founded in this image

image , and then read this te, and then read this text and sore this editext and sore this edited text in a le. Also td text in a le. Also thehe user can write or copy and paste a text on the editor directly.

user can write or copy and paste a text on the editor directly.

1.2

1.2 Problem

Problem ::

%ecause of the high speed of information technology in the world , %ecause of the high speed of information technology in the world , there is a strong connection between technology and the other elds

there is a strong connection between technology and the other elds in ourin our life. Technology , software and hardware , are used in many places by

life. Technology , software and hardware , are used in many places by di&erent

di&erent age slides age slides of the of the community, community, adults and adults and children, children, but the but the mainmain problem is that there is a specic slide of

problem is that there is a specic slide of people gets a di'culty in dealingpeople gets a di'culty in dealing with technology

with technology. This slide is . This slide is blind people. $o our prblind people. $o our project came to help thisoject came to help this slide of community by m

slide of community by making a conversion of aking a conversion of edited text inedited text into speech to beto speech to be listened by the blind people.

(2)

Also the another aim of

Also the another aim of making our project is that there is manymaking our project is that there is many images contained text which sometimes the user need it to his

images contained text which sometimes the user need it to his di&erentdi&erent purpose. (n this case , our project helps the user to get this text , contained purpose. (n this case , our project helps the user to get this text , contained in an image ,

in an image , by using the techni)ue of by using the techni)ue of Optical haracter !eOptical haracter !ecognition "O!#.cognition "O!#.

1.3

1.3 Objectives

Objectives ::

 A full

 A full reali*reali*ation of this ation of this concept would involve a few distinct steps +concept would involve a few distinct steps +

•  T To develop a text fro develop a text from an image by O! systom an image by O! system.em. •

•  T To develop text ro develop text recognition softwarecognition software that can be gotten from an ime that can be gotten from an imageage

or even directory written into text editor system. or even directory written into text editor system.

•  T To develop a read the teo develop a read the text contained in the texxt contained in the text editor by using $peecht editor by using $peech

!eco

!ecognition gnition $ystem.$ystem.

•  T To develop the above system o develop the above system to exist on a prto exist on a programmable O! suchogrammable O! such

that it operates independently of an

that it operates independently of an external computiexternal computing source, andng source, and interacts with its software inputs and outputs independently.

interacts with its software inputs and outputs independently.

 $uch a

 $uch a system would be integrated in the users ssystem would be integrated in the users sources, use speakerources, use speakerss in the computer as output

in the computer as output sources, and would issue control les to softwaresources, and would issue control les to software already installed in the computer. There are di&erent signicant factors to be already installed in the computer. There are di&erent signicant factors to be considered

considered while designing both Optical haracter !ecognition and Text towhile designing both Optical haracter !ecognition and Text to speech systems that will produce clear text and speech outputs.

speech systems that will produce clear text and speech outputs.

1.

1. I!tro"#c

I!tro"#ctio!

tio! T

To

o OCR

OCR ::

 The goal of Optical haracter !

 The goal of Optical haracter !ecognition "O!# is to claecognition "O!# is to classify opticalssify optical patterns "often contained in a

patterns "often contained in a digital image# corresponding to alphanumericdigital image# corresponding to alphanumeric or other characters. The process of O! involves several steps including or other characters. The process of O! involves several steps including segmentation, feature ex

segmentation, feature extraction, and classication. -ach of traction, and classication. -ach of these steps is athese steps is a eld unto itself, and

eld unto itself, and is described briey here in the context of a /atlabis described briey here in the context of a /atlab implementation of O!.

(3)

Also the another aim of

Also the another aim of making our project is that there is manymaking our project is that there is many images contained text which sometimes the user need it to his

images contained text which sometimes the user need it to his di&erentdi&erent purpose. (n this case , our project helps the user to get this text , contained purpose. (n this case , our project helps the user to get this text , contained in an image ,

in an image , by using the techni)ue of by using the techni)ue of Optical haracter !eOptical haracter !ecognition "O!#.cognition "O!#.

1.3

1.3 Objectives

Objectives ::

 A full

 A full reali*reali*ation of this ation of this concept would involve a few distinct steps +concept would involve a few distinct steps +

•  T To develop a text fro develop a text from an image by O! systom an image by O! system.em. •

•  T To develop text ro develop text recognition softwarecognition software that can be gotten from an ime that can be gotten from an imageage

or even directory written into text editor system. or even directory written into text editor system.

•  T To develop a read the teo develop a read the text contained in the texxt contained in the text editor by using $peecht editor by using $peech

!eco

!ecognition gnition $ystem.$ystem.

•  T To develop the above system o develop the above system to exist on a prto exist on a programmable O! suchogrammable O! such

that it operates independently of an

that it operates independently of an external computiexternal computing source, andng source, and interacts with its software inputs and outputs independently.

interacts with its software inputs and outputs independently.

 $uch a

 $uch a system would be integrated in the users ssystem would be integrated in the users sources, use speakerources, use speakerss in the computer as output

in the computer as output sources, and would issue control les to softwaresources, and would issue control les to software already installed in the computer. There are di&erent signicant factors to be already installed in the computer. There are di&erent signicant factors to be considered

considered while designing both Optical haracter !ecognition and Text towhile designing both Optical haracter !ecognition and Text to speech systems that will produce clear text and speech outputs.

speech systems that will produce clear text and speech outputs.

1.

1. I!tro"#c

I!tro"#ctio!

tio! T

To

o OCR

OCR ::

 The goal of Optical haracter !

 The goal of Optical haracter !ecognition "O!# is to claecognition "O!# is to classify opticalssify optical patterns "often contained in a

patterns "often contained in a digital image# corresponding to alphanumericdigital image# corresponding to alphanumeric or other characters. The process of O! involves several steps including or other characters. The process of O! involves several steps including segmentation, feature ex

segmentation, feature extraction, and classication. -ach of traction, and classication. -ach of these steps is athese steps is a eld unto itself, and

eld unto itself, and is described briey here in the context of a /atlabis described briey here in the context of a /atlab implementation of O!.

(4)

1.$

1.$ T

Te%t&to&'

e%t&to&'(eec)

(eec) 'o*tw+re

'o*tw+re ::

A Text0To0$peech "TT$# recognition is computer based system that A Text0To0$peech "TT$# recognition is computer based system that should be able to

should be able to read any text aloud, whether it was straight bring in read any text aloud, whether it was straight bring in thethe computer by an operator or scanned

computer by an operator or scanned and submitted to an and submitted to an Optical haracterOptical haracter !ec

!ecognition system. (n the context of ognition system. (n the context of TT$ synthesis, it is very complicated toTT$ synthesis, it is very complicated to recor

record and accumulate all the d and accumulate all the words of the language.words of the language.  $o it

 $o it is in e&ect more appropriate to dene TT$ as the is in e&ect more appropriate to dene TT$ as the automaticautomatic production of speech by using the

production of speech by using the concept of grapheme and phonemes textconcept of grapheme and phonemes text of the sentences to complete.

of the sentences to complete.

1.,

1., Project

Project -et)o"oloies

-et)o"oloies ::

1.,.1

1.,.1

OCR -et)o"olo/

OCR

-et)o"olo/ ::

O! software

O! software has been around as long as computers have to connect the has been around as long as computers have to connect the printed world with

printed world with the electronic one. Tthe electronic one. Traditional document imaging raditional document imaging methodsmethods use templates and

use templates and algorithms in a algorithms in a two0dimensional environment to recogni*etwo0dimensional environment to recogni*e objects and patterns. O! methods today recogni*e a spectrum of colors, objects and patterns. O! methods today recogni*e a spectrum of colors, and they can distinguish

and they can distinguish between the background and the forefront inbetween the background and the forefront in documents. They de0skew, de0speckle and use

documents. They de0skew, de0speckle and use 102 image correction in order102 image correction in order to work with lower

to work with lower resolution images taken from mediums such as faxes, theresolution images taken from mediums such as faxes, the internet and cell phone

internet and cell phone cameras.cameras.

O! software uses two di&erent kinds of

O! software uses two di&erent kinds of optical character recognition+optical character recognition+ feature extraction and matrix matching. 3eature extraction recogni*es feature extraction and matrix matching. 3eature extraction recogni*es shapes using statistical and

shapes using statistical and mathematical techni)ues to detect edges,mathematical techni)ues to detect edges, corners and ridges in a text font to

corners and ridges in a text font to identify the letters in a word, sentenceidentify the letters in a word, sentence and paragraph. O! software achieves the best results when the image has and paragraph. O! software achieves the best results when the image has the following conditions+

the following conditions+

• (s a clean, straight image.(s a clean, straight image.

• 4ses a very distinguishable font such 4ses a very distinguishable font such as Arial or 5elvetica.as Arial or 5elvetica.

• 4ses black letters on a clear ba4ses black letters on a clear background for better results.ckground for better results.

(5)

5owever, these conditions are not always possible. The best O!

5owever, these conditions are not always possible. The best O! techni)uestechni)ues can still read words accurately in

can still read words accurately in less ideal circumstances using matrixless ideal circumstances using matrix matching.

matching.

One example of O! is shown below. A portion of a scanned

One example of O! is shown below. A portion of a scanned image ofimage of text, borr

text, borrowed from the web, owed from the web, is shown ais shown along with the long with the corrcorresponding "humanesponding "human recogni*ed# characters from that text.

recogni*ed# characters from that text.

0i#re 1.1 :

0i#re 1.1 : 'c+!!e" im+e o* te%t +!" its corres(o!"i! reco!ie"'c+!!e" im+e o* te%t +!" its corres(o!"i! reco!ie" re(rese!t+tio!.

re(rese!t+tio!.

1.,.2

1.,.2 T

Te%t

e%t to

to '(eec)

'(eec) -et)o"ol

-et)o"olo/

o/ ::

A Text0To0$peech "TT$# recognition is computer based system that A Text0To0$peech "TT$# recognition is computer based system that should be able to

should be able to read any text aloud, whether it was straight bring in read any text aloud, whether it was straight bring in thethe computer by an operator or scanned

computer by an operator or scanned and submitted to an and submitted to an Optical haracterOptical haracter !ec

!ecognition system. (n the context of ognition system. (n the context of TT$ synthesis, it is very complicated toTT$ synthesis, it is very complicated to recor

record and accumulate all the d and accumulate all the words of the language. $o words of the language. $o it is in e&ect moreit is in e&ect more appropriate to dene TT$ as the automatic production of

appropriate to dene TT$ as the automatic production of speech by using thespeech by using the concept of grapheme and phonemes text of

(6)

0i#re 1.2 :

0i#re 1.2 : TT' '/stem.TT' '/stem.

1.

1. '(eec)

'(eec) '/!t)esis

'/!t)esis ::

$ynthesi*ed speech can be created by concatenating part of

$ynthesi*ed speech can be created by concatenating part of recorrecordedded speech which is stored in a database. The power of a speech synthesi*er is speech which is stored in a database. The power of a speech synthesi*er is moderator by its similarity to the human being

moderator by its similarity to the human being voice, and by its avoice, and by its ability to bebility to be understood. The mainly signicant )ualities of a

understood. The mainly signicant )ualities of a speech synthesis system arespeech synthesis system are naturalness and (ntelligibility.

naturalness and (ntelligibility.

7aturalness expre

7aturalness expresses how sses how intimately the output sounds intimately the output sounds like humanlike human speech, whereas intelligibil

speech, whereas intelligibility is the easiness with which ity is the easiness with which the output isthe output is understood. The perfect speech synthesi*er is providing both natural and understood. The perfect speech synthesi*er is providing both natural and intelligible speech hence speech synthesis systems us

intelligible speech hence speech synthesis systems usually try to ually try to maximi*emaximi*e both characteristics. There are di&erent signicant factors to

both characteristics. There are di&erent signicant factors to be consideredbe considered while designing a Text to speech system that will produce clear speech. while designing a Text to speech system that will produce clear speech.

(7)

0i#re 1.3 : 0lowc)+rt o* Te%t to '(eec) Reco!itio!.

1..1 Te%t To '(eec) '/stem :

 TT$ $ynthesi*er is a computer based system that should be

understand any text clearly whether it was establish in the computer by an operator or scanned and submitted to an Optical haracter !ecognition "O!# system. The intention of a text to speech system is to convert an random given wording into a speak waveform. /ost important workings of text to speech system are Text processing and $peech production. The two primary methods for producing synthetic speech waveforms are

concatenative synthesis and formant synthesis. 8e are used oncatenative synthesis for our TT$. oncatenative synthesis is stand on the concatenation

(8)

of piece of recorded words. 4sually concatenative synthesis constructs the most normal sounding synthesi*ed words.

1..2 '(eec) e!er+tio! Com(o!e!t :

9iven order of phonemes, the idea of the speech generation

component is to synthesi*e the acoustic waveform $peech generation has been attempted by concatenating the recorded words . !ecent state of art language synthesis produces natural sounding speech by using huge amount of speech pieces. $torage of huge number of pieces and their retrieval in real time is feasible due to availability of cheap memory and computation power.  The problem related to the unit selection speech synthesis system are

consider in three things that are choice of unit si*e, generation of speech database and criteria for selection of a unit.

1..3 '(eec) '/!t)esis Process :

 This TT$ system is able to read any written text. This procedure is called text normali*ation, preprocessing and tokeni*ation. (n this system, we have developed a phonetic based text to speech synthesis system. 8e can improve the speech )uality using matlab language . The following gure shows the block diagram for TTs system .

(9)

0i#re 1.$ : 0low c)+rt *or TT' wit) e%+m(le.

1.6 '(eec) '/!t)esis Tec)!olo/ :

!esearch in the area of speech synthesis has been going on for

decades. As we found out with our research, numerous models and theories exist for the best way implementing a speech synthesis system. Although the models seemed intuitive from a high level perspective they )uickly grew in complexity as we got closer to implementation.

1.7 -AT8A4 Overview :

/atlab is widely used in all areas of applied mathematics, in education and research at universities, and in the industry. /atlab stands for /ATrix :A%oratory and the software is built up around vectors and matrices. This makes the software particularly useful for linear algebra but matlab is also a great tool for solving algebraic and di&erential e)uations and for numerical integration. /atlab has powerful graphic tools and can produce nice pictures

(10)

in both ;2 and 12. (t is also a programming language, and is one of the easiest programming languages for writing mathematical programs. /atlab also has some tool boxes useful for signal processing, image processing, optimi*ation, etc.

/atlab is a high0performance language for technical computing. (t integrates computation, visuali*ation, and programming in an easy0to0use environment where problems and solutions are expressed in familiar

mathematical notation. Typical uses include+

• /ath and computation • Algorithm development

• /odeling, simulation, and prototyping

• 2ata analysis, exploration, and visuali*ation • $cientic and engineering graphics

• Application development, including 9raphical 4ser (nterface

building.

/atlabis an interactive system whose basic data element is an array that does not re)uire dimensioning. This allows you to solve many technical computing problems, especially those with matrix and vector formulations, in a fraction of the time it would take to write a program in a scalar

noninteractive language such as  or 3ortran.

/atlab was originally written to provide easy access to matrix software developed by the LINPACK and EISPACK  projects, which together represent the state0of0the0art in software for matrix computation.

/atlab has evolved over a period of years with input from many users. (n university environments, it is the standard instructional tool for

introductory and advanced courses in mathematics, engineering, and science. (n industry, /atlab is the tool of choice for high0productivity research, development, and analysis.

(11)

/atlab features a family of application0specic solutions called toolboxes. <ery important to most users of matlab, toolboxes allow you to learn and apply speciali*ed technology. Toolboxes are comprehensive collections of matlab functions "/0les# that extend the matlab environment to solve particular classes of problems. Areas in which toolboxes are

available include signal processing, control systems, neural networks, fu**y logic, wavelets, simulation, and many others.

1.19 Histor/ o* -+tl+b :

leve /oler, the chairman of the computer science department at the 4niversity of 7ew /exico, started developing matlab in the late =>?6s. 5e designed it to give his students access to LINPACK  and EISPACK  without them having to learn 3ortran. (t soon spread to other universities and found a strong audience within the applied mathematics community. @ack :ittle, an engineer, was exposed to it during a visit /oler made to $tanford

4niversity in =>1. !ecogni*ing its commercial potential, he joined with /oler and $teve %angert. They rewrote matlab in  and

founded /ath8orks in =>B to continue its development. These rewritten libraries were known as JACKPAC. (n ;666, matlab was rewritten to use a newer set of libraries for matrix manipulation, LAPACK .

/atlab was rst adopted by researchers and practitioners in control engineering, :ittleCs specialty, but )uickly spread to many other domains. (t is now also used in education, in particular the teaching of linear

algebra and numerical analysis, and is popular amongst scientists involved in image processing.

1.11 '8 'erver Overview :

9enerically, any database management system "2%/$# that can respond to )ueries from client machines formatted in the $D: language. 8hen capitali*ed, the term generally refers to either of two database

(12)

management products from $ybase and /icrosoft. %oth companies o&er client0server 2%/$ products called $D: $erver.

1.12 T)e Histor/ o* '8 'erver :

(%/ invented a computer language back in the =>?6s designed

specically for database )ueries called $-D4-:, which stood for $tructured -nglish Duery :anguage. Over time the language has been added to, so that it is not just a language for )ueries but can also be used to build databases and manage security of the database engine. (%/ released $-D4-: into the public domain, where it became known as $D:.

%ecause of this heritage you can pronounce it as Ese)uelE or spell it out as E$0D0:E when talking about it. <arious versions of $D: are used in todayCs database engines. /icrosoft $D: $erver uses a version called Transact0$D:. Although you will use Transact0$D: in this book and learn the basics of the language, the emphasis in this book is on installing, maintaining, and

connecting to $D: $erver. $ams Fublishing also has a book titled Teach  Gourself Transact0$D: in ;= 2ays, which has more details on the language

and its usage.

/icrosoft initially developed $D: $erver "a database product that understands the $D: language# with $ybase orporation for use on the (%/ O$H; platform. 8hen /icrosoft and (%/ split, /icrosoft abandoned O$H; in favor of its new network operating system, 8indows 7T Advanced $erver. At that point, /icrosoft decided to further develop the $D: $erver engine for 8indows 7T by itself. The resulting product was /icrosoft $D: $erver B.;, which was updated to B.;=. After /icrosoft and $ybase parted ways, $ybase further developed its database engine to run on 8indows 7T "$ybase $ystem =6 and now $ystem ==#, and /icrosoft developed $D: $erver I.6Jthen $D:

(13)

$erver I.K, which also ran on top of 8indows 7T. $D: $erver ?.6 now runs on 8indows 7T as well as on 8indows >K and 8indows >.

Although you can run $D: $erver ?.6 on a 8indows >x system, you do not get all the functionality of $D: $erver. 8hen running it on the 8indows >x platform, you lose the capability to use multiple processors, 8indows 7T security, 7T3$ "7ew Technology 3ile $ystem# volumes, and much more. 8e strongly urge you to use $D: $erver ?.6 on 8indows 7T rather than on 8indows >x. 8indows 7T has other advantages as well. The 7T platform is designed to support multiple users. 8indows >x is not designed this way, and your $D: $erver performance degrades rapidly as you add more users.

$D: $erver ?.6 is implemented as a service on either 7T 8orkstation or 7T $erver "which makes it run on the server side of 8indows 7T# and as an application on 8indows >KH>. The included utilities, such as the $D: $erver -nterprise /anager, operate from the client side of 8indows 7T $erver or 7T 8orkstation. Of course, just like all other applications on 8indows >x, the tools run as applications.

A service is an application 7T can start when booting up that adds

functionality to the server side of 7T. $ervices also have a generic application programming interface "AF(# that can be controlled programmatically.

 Threads originating from a service are automatically given a higher priority than threads originating from an application.

1.13 '8 'erver 2996 R2 :

/icrosoft $D: $erver ;66 !; is the most advanced, trusted, and scalable data

platform released to date. %uilding on the success of the original $D: $erver ;66

(14)

release, $D: $erver ;66 !; has made an impact on organi*ations worldwide with its groundbreaking capabilities, empowering end users through self0 service business intelligence "%(#, bolstering e'ciency and collaboration between database administrators "2%As# and application developers, and scaling to accommodate the most demanding data workloads.

 This chapter introduced the new $D: $erver ;66 !; features,

capabilities, and editions from a 2%As perspective. (t also discusses why 8indows $erver ;66 !; is recommended as the underlying operating system for deploying $D: $erver ;66 !;. :ast, $D: $erver ;66.

CHAPTER T;O

PRO<ECT ANA8='I'

(15)

 There are two steps in building a classier, training and testing. These steps can be broken down further into sub0steps +

1. Tr+i!i! :

a. Fre0processing L Frocesses the data so it is in a suitable form for use. b. 3eature extraction L !educe the amount of data by extracting relevant informationJ4sually results in a vector of scalar values.

c. /odel -stimation L from the nite set of feature vectors, need to estimate a model "usually statistical# for each class of the training data.

2. Testi! :

a. Fre0processing.

b. 3eature extraction L "both same as above#.

c. lassication L ompare feature vectors to the various models and nd the closest match. One can use a distance measure.

0i#re 2.1 : T)e (+tter! cl+ssi>c+tio! (rocess.

2.2

OCR ? Pre&(rocessi! :

These are the pre-processing steps often performed in OC !

• Binarization " #s$a%%& presented 'ith a gra&sca%e image( )inari*ation is then simp%& a

matter of choosing a thresho%d +a%$e.

• Morphological Operators " emo+e iso%ated spec,s and ho%es in characters( can $se the

(16)

• Segmentation " Chec, connecti+it& of shapes( %a)e%( and iso%ate. Can $se at%a) 6.1s

bwlabel and regionprops f$nctions. /iffic$%ties 'ith characters that arent connected( e.g. the %etter i( a semico%on( or a co%on  or !.

egmentation is )& far the most important aspect of the pre-processing stage. t a%%o's the recogni*er to etract feat$res from each indi+id$a% character. n the more comp%icated case of  hand'ritten tet( the segmentation pro)%em )ecomes m$ch more diffic$%t as %etters tend to )e connected to each other.

2.3 OCR ? 0e+t#re e%tr+ctio! :

i+en a segmented iso%ated character( the $sef$% feat$res for recognition are !

1. Moment based features :

Thin, of each character as a otepad. The 2-/ moments of the character are!

From the moments we can compute features like:

1. Tota% mass n$m)er of pie%s in a )inari*ed character 2. Centroid - Center of mass

3. %%iptica% parameters

i. ccentricit& ratio of maor to minor ais ii. Orientation ang%e of maor ais

(17)

5. :$rtosis

6. ;igher order moments

2. ;o$gh and Chain code transform 3. <o$rier transform and series

2. OCR & -o"el Estim+tio! :

i+en %a)e%ed sets of feat$res for man& characters( 'here the %a)e%s correspond to the partic$%ar  c%asses that the characters )e%ong to( 'e 'ish to estimate a statistica% mode% for each character  c%ass. <or eamp%e( s$ppose 'e comp$te t'o feat$res for each rea%i*ation of the characters 0 thro$gh 9. =%otting each character c%ass as a f$nction of the t'o feat$res 'e ha+e!

(18)

0i#re 2.3 : 0lowc)+rt o* reco!ii! wor"s

The Optica% Character ecognition dea%s 'ith recognition of optica%%& processed characters. e%ia)%& interpreting tet from rea%-'or%d photos is a cha%%enging pro)%em d$e to +ariations in en+ironmenta% factors e+en it )ecomes easier $sing the )est open so$rce OC engine.

(19)

CHAPTER THREE

PRO<ECT DE'IN

T)e (roject Desi! wit) t)e UI @r+()ic+l

User I!ter*+ce :

0i#re 3.1 : T)e m+i! UI o* t)e (roject.

(20)

0i#re 3.2 : 8o+"i! +! im+e *rom com(#ter i!to t)e +((lic+tio!.

T)e m+tl+b co"e :

[filename, pathname] =

uigetfile({'*.jpg';'*.bmp';'*.gif';'*.tif'}, 'Pick an

Image File';

if (filename==!

 

"a#n$lg('%&u $i$ n&t electe$ an file ' ; ) fille

i n&t electe$

en$

img=im#ea$([pathname,filename];

h = "aitba#(!,'Pleae "ait...';

tep = !!;

f&# tep = +tep

) c&mputati&n take place he#e

"aitba#(tep  tep

en$

cl&e(h

et(han$le.btn-&ne#t,'/nable','&n';

et(han$le.path,'/nable','&n';

et(han$le.imageInf&,'/nable','&n';

et(han$le.img0$ipla,'1iible','&n';

et(han$le.te2t,'3t#ing',[filename];

et(han$le.te2t,'F&nt3i4e',5;

et(han$le.path,'3t#ing',[pathname];

a2e(han$le.img0$ipla;

imagec(img;

a$$#e = cat(6,pathname,filename;

imagen=im#ea$(a$$#e;

) 3h&" image

imh&"(imagen;

(21)

Reco!ie Te%t :

I! 0ol"er B letters!#mbers

"

0i#re 3.3 : Reco!ie te%t (+tter!.

Cre+te Tem(l+tes :

)-7/89/ 9/:P89/3

)ette#

clc;

cl&e all;

8=im#ea$('lette#0numbe#<8.bmp';=im#ea$('lette#0num

be#<.bmp';

-=im#ea$('lette#0numbe#<-.bmp';>=im#ea$('lette#0num

be#<>.bmp';

/=im#ea$('lette#0numbe#</.bmp';F=im#ea$('lette#0num

be#<F.bmp';

?=im#ea$('lette#0numbe#<?.bmp';@=im#ea$('lette#0num

be#<@.bmp';

I=im#ea$('lette#0numbe#<I.bmp';A=im#ea$('lette#0num

be#<A.bmp';

B=im#ea$('lette#0numbe#<B.bmp';=im#ea$('lette#0num

be#<.bmp';

(22)

:=im#ea$('lette#0numbe#<:.bmp';C=im#ea$('lette#0num

be#<C.bmp';

D=im#ea$('lette#0numbe#<D.bmp';P=im#ea$('lette#0num

be#<P.bmp';

E=im#ea$('lette#0numbe#<E.bmp';7=im#ea$('lette#0num

be#<7.bmp';

3=im#ea$('lette#0numbe#<3.bmp';9=im#ea$('lette#0num

be#<9.bmp';

=im#ea$('lette#0numbe#<.bmp';1=im#ea$('lette#0num

be#<1.bmp';

G=im#ea$('lette#0numbe#<G.bmp';H=im#ea$('lette#0num

be#<H.bmp';

%=im#ea$('lette#0numbe#<%.bmp';=im#ea$('lette#0num

be#<.bmp';

)l&"e# cae lette#

a=im#ea$('lette#0numbe#<a.png';b=im#ea$('lette#0num

be#<b.png';

c=im#ea$('lette#0numbe#<c.png';$=im#ea$('lette#0num

be#<$.png';

e=im#ea$('lette#0numbe#<e.png';f=im#ea$('lette#0num

be#<f.png';

g=im#ea$('lette#0numbe#<g.png';h=im#ea$('lette#0num

be#<h.png';

i=im#ea$('lette#0numbe#<i.png';j=im#ea$('lette#0num

be#<j.png';

k=im#ea$('lette#0numbe#<k.png';l=im#ea$('lette#0num

be#<l.png';

m=im#ea$('lette#0numbe#<m.png';n=im#ea$('lette#0num

be#<n.png';

&=im#ea$('lette#0numbe#<&.png';p=im#ea$('lette#0num

be#<p.png';

J=im#ea$('lette#0numbe#<J.png';#=im#ea$('lette#0num

be#<#.png';

=im#ea$('lette#0numbe#<.png';t=im#ea$('lette#0num

be#<t.png';

u=im#ea$('lette#0numbe#<u.png';=im#ea$('lette#0num

be#<.png';

"=im#ea$('lette#0numbe#<".png';2=im#ea$('lette#0num

be#<2.png';

(23)

=im#ea$('lette#0numbe#<.png';4=im#ea$('lette#0num

be#<4.png';

)Cumbe#

&ne=im#ea$('lette#0numbe#<.bmp';

t"&=im#ea$('lette#0numbe#<6.bmp';

th#ee=im#ea$('lette#0numbe#<K.bmp';f&u#=im#ea$('lett

e#0numbe#<5.bmp';

fie=im#ea$('lette#0numbe#<L.bmp';

i2=im#ea$('lette#0numbe#<M.bmp';

een=im#ea$('lette#0numbe#<N.bmp';eight=im#ea$('let

te#0numbe#<O.bmp';

nine=im#ea$('lette#0numbe#<.bmp';

4e#&=im#ea$('lette#0numbe#<!.bmp';

)*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q

lette#=[8  - > / F ? @ I A B  :...

C D P E 7 3 9  1 G H % ];

numbe#=[&ne t"& th#ee f&u# fie...

i2 een eight nine 4e#&];

l&"e#cae = [a b c $ e f g h i j k ...

l m n & p J #  t u  " 2  4];

cha#acte#=[lette# numbe# l&"e#cae];

template=mat6cell(cha#acte#,56,[65 65 65 65 65 65 65

...

65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 65 ...

65 65 65 65 65 65 65 65 ...

65 65];

ae ('template','template'

clea# all

(24)

Re+" 8etter :

)functi&n #ea$0lette#

functi&n lette#=#ea$0lette#(imagn,num0let#a

) -&mpute the c&##elati&n bet"een template an$ input

image

) an$ it &utput i a t#ing c&ntaining the lette#.

) 3i4e &f 'imagn' mut be 56 2 65 pi2el

) /2ample+

) imagn=im#ea$('>.bmp';

) lette#=#ea$0lette#(imagn

)l&a$ template

gl&bal template

c&mp=[ ];

f&# n=+num0let#a

em=c&##6(template{,n},imagn;

c&mp=[c&mp em];

)paue(

en$

$=fin$(c&mp==ma2(c&mp;

)*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q*Q

if $==

 

lette#='8';

eleif $==6

 

lette#='';

eleif $==K

 

lette#='-';

eleif $==5

 

lette#='>';

eleif $==L

 

lette#='/';

eleif $==M

 

lette#='F';

eleif $==N

(25)

 

lette#='?';

eleif $==O

 

lette#='@';

eleif $==

 

lette#='I';

eleif $==!

 

lette#='A';

eleif $==

 

lette#='B';

eleif $==6

 

lette#='';

eleif $==K

 

lette#=':';

eleif $==5

 

lette#='C';

eleif $==L

 

lette#='D';

eleif $==M

 

lette#='P';

eleif $==N

 

lette#='E';

eleif $==O

 

lette#='7';

eleif $==

 

lette#='3';

eleif $==6!

 

lette#='9';

eleif $==6

 

lette#='';

eleif $==66

 

lette#='1';

eleif $==6K

 

lette#='G';

eleif $==65

 

lette#='H';

eleif $==6L

 

lette#='%';

eleif $==6M

 

lette#='';

)*Q*Q*Q*Q*

(26)

eleif $==6N

 

lette#='';

eleif $==6O

 

lette#='6';

eleif $==6

 

lette#='K';

eleif $==K!

 

lette#='5';

eleif $==K

 

lette#='L';

eleif $==K6

 

lette#='M';

eleif $==KK

 

lette#='N';

eleif $==K5

 

lette#='O';

eleif $==KL

 

lette#='';

eleif $==KM

 

lette#='!';

)********

eleif $==KN

 

lette#='a';

eleif $==KO

 

lette#='b';

eleif $==K

 

lette#='c';

eleif $==5!

 

lette#='$';

eleif $==5

 

lette#='e';

eleif $==56

 

lette#='f';

eleif $==5K

 

lette#='g';

eleif $==55

 

lette#='h';

eleif $==5L

 

lette#='i';

eleif $==5M

(27)

 

lette#='j';

eleif $==5N

 

lette#='k';

eleif $==5O

 

lette#='l';

eleif $==5

 

lette#='m';

eleif $==L!

 

lette#='n';

eleif $==L

 

lette#='&';

eleif $==L6

 

lette#='p';

eleif $==LK

 

lette#='J';

eleif $==L5

 

lette#='#';

eleif $==LL

 

lette#='';

eleif $==LM

 

lette#='t';

eleif $==LN

 

lette#='u';

eleif $==LO

 

lette#='';

eleif $==L

 

lette#='"';

eleif $==M!

 

lette#='2';

eleif $==M

 

lette#='';

eleif $==M6

 

lette#='4';

ele

 

lette#='l';

)*Q*Q*Q*Q*

/n$

(28)

8ettere cro(e :

)functi&n lette#0in0a0line

functi&n [fl #e pace]=lette#0c#&p(im0te2t&

) >ii$e lette# in line

im0te2t&=clip(im0te2t&;

num0fila=i4e(im0te2t&,6;

)figu#e,imh&"(im0te2t&; )title('line ent in the

functi&n lette#';

f&# =+num0fila

;

um0c&l = um(im0te2t&(+,;

if um0c&l==!

k = 't#ue';

 

nm=im0te2t&(+,+Q; ) Fi#t lette# mat#i2

)figu#e,imh&"(nm;

)title('fi#t lette# in the functi&n

lette#0in0a0line';

)paue(;

 

#m=im0te2t&(+,+en$;) 7emaining line mat#i2

)figu#e,imh&"(#m;

)title('#emaining lette# in the functi&n

lette#0in0a0line';

)paue(;

fl = clip(nm;

)paue(;

 

#e=clip(#m;

pace = i4e(#m,6Qi4e(#e,6;

)*Q*Q*nc&mment line bel&" t& ee the #eult*Q

)ubpl&t(6,,;imh&"(fl;

 

)ubpl&t(6,,6;imh&"(#e;

b#eak

ele

 

fl=im0te2t&;)Dnl &ne line.

#e=[ ];

pace = !;

en$

en$

(29)

[f c]=fin$(img0in;

img0&ut=img0in(min(f+ma2(f,min(c+ma2(c;

8i!es Cro( :

functi&n [fl #e]=line(im0te2t&

) >ii$e te2t in line

) im0te2t&QRinput image; flQRfi#t line; #eQR#emain

line

) /2ample+

) im0te2t&=im#ea$('9/390K.jpg';

) [fl #e]=line(im0te2t&;

) ubpl&t(K,,;imh&"(im0te2t&;title('ICP9 I:8?/'

) ubpl&t(K,,6;imh&"(fl;title('FI739 IC/'

) ubpl&t(K,,K;imh&"(#e;title('7/:8IC IC/3'

im0te2t&=clip(im0te2t&;

num0fila=i4e(im0te2t&,;

f&# =+num0fila

if um(im0te2t&(,+==!

nm=im0te2t&(+Q, +; ) Fi#t line mat#i2

#m=im0te2t&(+en$, +;) 7emain line mat#i2

fl = clip(nm;

 

#e=clip(#m;

)*Q*Q*nc&mment line bel&" t& ee the #eult*Q

*Q*Q*Q

)

ubpl&t(6,,;imh&"(fl;

)

ubpl&t(6,,6;imh&"(#e;

b#eak

ele

 

fl=im0te2t&;)Dnl &ne line.

#e=[ ];

en$

en$

functi&n img0&ut=clip(img0in

[f c]=fin$(img0in;

img0&ut=img0in(min(f+ma2(f,min(c+ma2(c;)-#&p

image

(30)

0i#re 3. : Reco!ie te%t i! t)e (roject.

) QQQ /2ecute &n butt&n p#e in btn-&ne#t.

functi&n btn-&ne#t0-allback(hDbject, eent$ata,

han$le

) hDbject

han$le t& btn-&ne#t (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

) -&ne#t t& g#a cale

pathname=get(han$le.path,'3t#ing';

filename=get(han$le.te2t,'3t#ing';

a$$#e = cat(6,pathname,filename;

imagen=im#ea$(a$$#e;

if i4e(imagen,K==K )7? image

 

imagen=#gb6g#a(imagen;

en$

) -&ne#t t& G

th#eh&l$ = g#ath#eh(imagen;

imagen =Sim6b"(imagen,th#eh&l$;

) 7em&e all &bject c&ntaining fe"e# than K! pi2el

imagen = b"a#ea&pen(imagen,K!;

(31)

)3t&#age mat#i2 "&#$ f#&m image

"&#$=[ ];

te2t=[ ];

#e=imagen;

te2t='';

) &a$ template

l&a$ template

gl&bal template

) -&mpute the numbe# &f lette# in template file

num0let#a=i4e(template,6;

"hile 

)Fcn 'line' epa#ate line in te2t

[fl #e]=line(#e;

 

imgn=fl;

n=!;

)nc&mment line bel&" t& ee line &ne b &ne

)figu#e,imh&"(fl;paue(6

)QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

paceect&# = [];

) t& c&mpute the t&tal

pace bet"eeen

) a$jacent lette#

#c = fl;

"hile 

)Fcn 'lette#0c#&p' epa#ate lette# in a line

[fc #c pace]=lette#0c#&p(#c;

)fc = fi#t

lette# in the line

)#c = #emaining

c#&ppe$ line

)pace = pace

bet"een the lette#

)

c#&ppe$ an$

the ne2t lette#

)unc&mment bel&" line t& ee lette# &ne b &ne

)figu#e,imh&"(fc;paue(!.L

img0# = im#ei4e(fc,[56 65];

)#ei4e lette#

& that c&##elati&n

(32)

n = n T ;

 

paceect&#(n=pace;

)Fcn '#ea$0lette#' c&##elate the c#&ppe$ lette#

"ith the image

)gien in the f&l$e# 'lette#0numbe#'

lette# = #ea$0lette#(img0#,num0let#a;

)lette# c&ncatenati&n

"&#$ = ["&#$ lette#];

if iempt(#c

)b#eak l&&p "hen the#e a#e n&

m&#e cha#acte#

b#eak;

en$

en$

)QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ)

ma20pace = ma2(paceect&#;

n&0pace = !;

f&# 2= +n

)l&&p t& int#&$uce pace at #eJuiite

l&cati&n

if paceect&#(2Tn&0paceR (!.NL * ma20pace

n&0pace = n&0pace T ;

f&# m = 2+n

 

"&#$(nT2QmTn&0pace="&#$(nT2Q

mTn&0paceQ;

en$

"&#$(2Tn&0pace = ' ';

paceect&# = [! paceect&#];

en$

en$

)fp#intf(fi$,')<n',l&"e#("&#$;)G#ite '"&#$' in

te2t file (l&"e#

)fp#intf(fi$,')<n',"&#$;)G#ite '"&#$' in te2t

file (uppe#

(33)

) -lea# '"&#$' a#iable

"&#$=[ ];

)*Ghen the entence finih, b#eak the l&&p

if iempt(#e

)3ee a#iable '#e' in Fcn 'line'

b#eak

en$

en$

h = "aitba#(!,'Pleae "ait...';

tep = !!;

f&# tep = +tep

) c&mputati&n take place he#e

"aitba#(tep  tep

en$

cl&e(h

et(han$le.te2t6,'3t#ing',te2t;

et(han$le.te2t6,'F&nt3i4e',65;

et(han$le.3peak,'/nable','&n';

gui$ata(hDbject, han$le;

'+ve to NoteP+" :

(34)

) QQQ /2ecute &n butt&n p#e in btnDpen.

functi&n btnDpen0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& btnDpen (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

alue=get(han$le.te2t6,'3t#ing';

etapp$ata(!,'t2t',alue

file0fig(;

0i#re 3., : '+vi! + te%t >le.

) QQQ /2ecute &n butt&n p#e in btnDk.

functi&n btnDk0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& btnDk (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

)Dpen te2t.t2t a file f&# "#ite

fname=get(han$le.e$it0name,'3t#ing';

filename=t#cat(fname,'.t2t';

pathname=get(han$le.e$it0l&cati&n,'3t#ing';

filepath=fullfile(pathname,filename;

if ieJual(e2it(filepath,'file',6

butt&n = Juet$lg('file name al#ea$ e2it ', ...

'Ga#ning','De##i$e','-ancle','-ancle';

(35)

cae 'De##i$e'

fi$ = f&pen(filepath, '"t';

cae '-ancle'

#etu#n;

en$

ele

fi$ = f&pen(filepath, '"t';

en$

h = "aitba#(!,'Pleae "ait...';

tep = !!;

f&# tep = +tep

) c&mputati&n take place he#e

"aitba#(tep  tep

en$

cl&e(h

)fp#intf(fi$,')<n',l&"e#("&#$;)G#ite '"&#$' in te2t

file (l&"e#

t2t=getapp$ata(!,'t2t';

#mapp$ata(!,'t2t';

n7&" = i4e(t2t,  ;

t2t='';

if n7&"R

f&# k=+n7&"

 

fp#intf(fi$,')<n',t2t(k,+;)G#ite '"&#$' in

te2t file (uppe#

 

t2t=t#cat(t2t,K6,t2t(k,+,!;

en$

ele

 

fp#intf(fi$,')<n',t2t;

 

t2t=t2t;

en$

fcl&e(fi$;

$ate=$ate;

$ec#=get(han$le.e$it0n&te,'3t#ing';

if t#cmp($ec#,'G#ite C&te he#e ...'

 

$ec#=CaC;

(36)

)$ata = cell(,M;

c&lumn={'i$','name0file','te2t','path0file','time','n&

te'};

$ata={han$le.lati$ fname t2t pathname $ate $ec#};

c&nn = $atabae('$bFile','a','6K';

ine#t(c&nn,'File0>ata',c&lumn,$ata;

cl&e(c&nn

) p$ate han$le t#uctu#e

gui$ata(hDbject, han$le;

)Dpen 'te2t.t2t' file

"in&pen(filepath

cl&e

0i#re 3. : E"ite" te%t i! + Note(+" >le *orm+t.

8o+" Te%t 0ile :

0i#re 3.6 : 8o+"i! + te%t >le @Note(+" >le *orm+t.

) QQQ /2ecute &n butt&n p#e in l&a$.

(37)

) hDbject

han$le t& l&a$ (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

[filename,pathname] = uigetfile('*.t2t;','elect t2t

file';

filepath=fullfile(pathname,filename;

h = "aitba#(!,'Pleae "ait...';

tep = !!;

f&# tep = +tep

) c&mputati&n take place he#e

"aitba#(tep  tep

en$

cl&e(h;

)U p#eaign  t& &me la#ge cell a##a

t2t=cell(!!!!,;

i43 = !!!!;

line-t = ;

fi$ = f&pen(filepath,'#';

tline = fgetl(fi$;

"hile icha#(tline

t2t{line-t} = tline;

line-t = line-t T ;

)U g#&"  if necea#

if line-t R i43

t2t = [t2t;cell(!!!!,];

i43 = i43 T !!!!;

en$

tline = fgetl(fi$;

en$

)U #em&e empt ent#ie in 

t2t(line-t+en$ = [];

et(han$le.te2t6,'3t#ing',t2t

et(han$le.3peak,'/nable','&n'

fcl&e(fi$

(38)

0i#re 3.7 : 8o+"i! + te%t o* !ote(+" >le *orm+t i! t)e e"it tool.

Te%t To '(eec)

 +

) QQQ /2ecute &n butt&n p#e in 3peak.

functi&n 3peak0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& 3peak (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

te2t=get(han$le.te2t6,'3t#ing';

n7&" = i4e(te2t,  ;

if iempt(te2t

te2t = 'G#ite &mething t& peak';

en$

t#

 

C/9.a$$8embl('3tem.3peech';

3peake# =

3tem.3peech.3nthei.3peech3nthei4e#;

f&# n=+n7&"

 

#"t2t=te2t(n,+;

if Sia(#"t2t,'cell'

#"t2t = {#"t2t};

(39)

en$

f&# k=+length(#"t2t

3peake#.3peak (#"t2t{k};

en$

en$

catch

 

"a#ning(['C&t "&#king VV'];

en$

Desi! D+t+4+se @#si! '8 'rver 2996 R :

Ta)%e ame ! File!ata !

0i#re 3.19 : 0ile "+t+.

ome /ata in a Ta)%e !

0i#re 3.11 : 'ome "+t+ i! + "+t+b+se t+ble.

-icroso*t '8 'erver OD4C i! -+tl+b *or ;i!"ows

:

(40)

0i#re 3.12 : D+t+b+se e%(lorer i! m+tl+b.

8ist o* Te%t i! D+t+b+se :

0i#re 3.13 : 8ist o* te%t i! t)e "+t+b+se.

(41)

) QQQ /2ecute jut bef&#e lit0file i ma$e iible.

functi&n lit0file0DpeningFcn(hDbject, eent$ata,

han$le, a#a#gin

) 9hi functi&n ha n& &utput a#g, ee DutputFcn.

) hDbject

han$le t& figu#e

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

) a#a#gin

c&mman$ line a#gument t& lit0file (ee

18787?IC

han$le.e$it=!;

c&nn = $atabae('$bFile','a','6K';

cu# = e2ec(c&nn,['elect * f#&m File0>ata'];

et$bp#ef('>ata7etu#nF&#mat','cella##a'

cu#=fetch(cu#;

a=cu#.>ata;

if SieJual('C& >ata',a

 

et(han$le.litb&2,'3t#ing',a(+,6

 

et(han$le.litb&2,'1alue',

 

et(han$le.e$it0i$,'3t#ing',a(,

 

et(han$le.e$it0name,'3t#ing',a(,6

 

et(han$le.e$it0$ate,'3t#ing',a(,L

 

et(han$le.e$it0l&cati&n,'3t#ing',a(,5

 

et(han$le.e$it0te2t,'3t#ing',a(,K

if iempt(a(,M

 

et(han$le.e$it0n&te,'3t#ing','9he#e i n&

n&te';

ele

 

et(han$le.e$it0n&te,'3t#ing',a(,M;

en$

en$

) -h&&e $efault c&mman$ line &utput f&# lit0file

han$le.&utput = hDbject;

) p$ate han$le t#uctu#e

gui$ata(hDbject, han$le;

(42)

0i#re 3.1 : O(e! >le b/ #si! !ote(+" >le *orm+t.

) QQQ /2ecute &n butt&n p#e in btn0&pen.

functi&n btn0&pen0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& btn0&pen (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

i$=get(han$le.e$it0i$,'3t#ing';

if Siempt(i$

fname=get(han$le.e$it0name,'3t#ing';

fname=t#cat(fname,'.t2t';

pathname=get(han$le.e$it0l&cati&n,'3t#ing';

filepath=fullfile(pathname,fname;

t2t=get(han$le.e$it0te2t,'3t#ing';

ee=e2it(filepath{},'file';

if ieJual(ee,6

 

"in&pen(filepath{}

ele

butt&n = Juet$lg(['file ha been $amge$ &# change

it l&cati&n. ',cha#(!,'Ghat &u "ant t& $&W'], ...

'Ga#ning','-#eate','>elete','-ancle','-ancle';

"itch butt&n

cae '-#eate'

fi$ = f&pen(filepath{}, '"t'

n7&" = i4e(t2t,  ;

(43)

f&# k=+n7&"

 

fp#intf(fi$,')<n',t2t{k,+};)G#ite

'"&#$' in te2t file (uppe#

en$

 

fcl&e(fi$;

 

"in&pen(filepath{};

cae '>elete'

butt&n = Juet$lg(['8#e &u u#e &u "ant

t& $eleteW'], ...

'Ga#ning','DB','-ancle','-ancle';

"itch butt&n

cae 'DB'

 

btn0$el0-allback(hDbject,

eent$ata, han$le;

cae '-ancle'

#etu#n;

en$

cae '-ancle'

#etu#n;

en$

en$

en$

E"it :

0i#re 3.1$ : E"ite" te%t i! !ote(+" >le.

) QQQ /2ecute &n butt&n p#e in puhbutt&nL.

functi&n btn0e$it0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& puhbutt&nL (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

(44)

i$=get(han$le.e$it0i$,'3t#ing';

if Siempt(i$

han$le.e$it=han$le.e$itT;

if han$le.e$it==

 

et(han$le.e$it0n&te,'/nable','&n'

 

et(han$le.e$it0n&te,'ackg#&un$-&l&#',[.! .!

.!];

ele

 

han$le.e$it=!;

c&nn = $atabae('$bFile','a','6K';

 

e$it0t2t=get(han$le.e$it0n&te,'3t#ing';

if SieJual(e$it0t2t,'9he#e i n& n&te'

 

"he#eclaue=t#cat('"he#e i$=',i$;

 

up$ate(c&nn,'File0>ata',{'n&te'},

{e$it0t2t},"he#eclaue

 

et(han$le.e$it0n&te,'/nable','inactie'

 

et(han$le.e$it0n&te,'ackg#&un$-&l&#',[!.M

!.NM !.6];

 

help$lg('%&u a#e >&ne up$ate','p$ate'

ele

 

et(han$le.e$it0n&te,'/nable','inactie'

 

et(han$le.e$it0n&te,'ackg#&un$-&l&#',[!.M

!.NM !.6];

en$

en$

) p$ate han$le t#uctu#e

gui$ata(hDbject, han$le;

en$

Delete 0rom D+t+b+se

 :

) QQQ /2ecute &n butt&n p#e in btn0$el.

functi&n btn0$el0-allback(hDbject, eent$ata, han$le

) hDbject

han$le t& btn0$el (ee ?-D

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

i$=get(han$le.e$it0i$,'3t#ing';

if Siempt(i$

(45)

butt&n = Juet$lg(['8#e &u u#e &u "ant t& $eleteW'],

...

'Ga#ning','DB','-ancle','-ancle';

"itch butt&n

cae 'DB'

 

i$=get(han$le.e$it0i$,'3t#ing';

 

Jue#=t#cat('$elete f#&m File0>ata

"he#e i$=',i$;

c&nn =

$atabae('$bFile','a','6K';

cu# = e2ec(c&nn,Jue#{};

cu# = e2ec(c&nn,['elect * f#&m

File0>ata'];

et$bp#ef('>ata7etu#nF&#mat','cella##a'

 

cu#=fetch(cu#;

 

a=cu#.>ata;

if SieJual('C& >ata',a{}

et(han$le.litb&2,'3t#ing',a(+,6

 

et(han$le.litb&2,'1alue',

et(han$le.litb&2,'3t#ing',a(+,6

 

et(han$le.litb&2,'1alue',

et(han$le.e$it0i$,'3t#ing',a(,

et(han$le.e$it0name,'3t#ing',a(,6

et(han$le.e$it0$ate,'3t#ing',a(,L

et(han$le.e$it0l&cati&n,'3t#ing',a(,5

et(han$le.e$it0te2t,'3t#ing',a(,K

if iempt(a(,M

et(han$le.e$it0n&te,'3t#ing','9he#e i n& n&te';

ele

et(han$le.e$it0n&te,'3t#ing',a(,M;

en$

(46)

et(han$le.litb&2,'3t#ing',''

et(han$le.e$it0i$,'3t#ing',''

et(han$le.e$it0name,'3t#ing',''

et(han$le.e$it0$ate,'3t#ing',''

et(han$le.e$it0l&cati&n,'3t#ing',''

et(han$le.e$it0te2t,'3t#ing',''

et(han$le.e$it0n&te,'3t#ing',''

en$

 

cl&e(cu#

 

cl&e(c&nn

 

help$lg('>elete if >&ne','>elete'

cae '-ancle'

#etu#n;

en$ en$

8ist o* >les :

0i#re 3.1, : 8ist o* >les.

) QQQ /2ecute &n butt&n p#e in btn0peak.

functi&n btn0peak0-allback(hDbject, eent$ata,

han$le

(47)

) eent$ata #ee#e$ Q t& be $efine$ in a

futu#e e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue#

$ata (ee ?I>898

te2t=get(han$le.e$it0te2t,'3t#ing';

if Siempt(te2t

alue=get(han$le.e$it0te2t,'3t#ing';

etapp$ata(!,'te2t',alue

cl&e(

&c#0gui(

en$

Ret#r! to t)e m+i! 0orm wit) t)e te%t

:

(48)

functi&n &c#0gui0DpeningFcn(hDbject, eent$ata,

han$le, a#a#gin

) 9hi functi&n ha n& &utput a#g, ee DutputFcn.

) hDbject

han$le t& figu#e

) eent$ata #ee#e$ Q t& be $efine$ in a futu#e

e#i&n &f :898

) han$le

t#uctu#e "ith han$le an$ ue# $ata (ee

?I>898

) a#a#gin

c&mman$ line a#gument t& &c#0gui (ee

18787?IC

) -h&&e $efault c&mman$ line &utput f&# &c#0gui

han$le.&utput = hDbject;

te2t=getapp$ata(!,'te2t';

if Siempt(te2t

 

et(han$le.te2t6,'3t#ing',te2t

 

et(han$le.3peak,'/nable','&n'

 

#mapp$ata(!,'te2t';

en$

) p$ate han$le t#uctu#e

gui$ata(hDbject, han$le;

(49)

CHAPTER 0OUR

I-P8E-ENTATION

.1 Project Im(leme!t+tio! :

=. :oading any image format "bmp, jpg, png Metc #

0i#re .1 : 8o+"i! +! im+e i!to t)e (ror+m.

;. The image will load .

0i#re .2 : iewi! t)e im+e i! t)e (ror+m.

(50)

0i#re .3 : iewi! t)e im+e i!*orm+tio!.

B. onvert the image to grayscale and binari*e it using the threshold value "Otsu algorithm#.

K. Fage layout analysis. (n this step we tried to identify the text *ones present in the image. $o that only that portion is used for recognition and rest of the region is left out.

I. :ines detection and removing.

?. 2etection of text lines and words. 5ere we also need to take care of di&erent font si*es and small spaces between words.

. !ecognition of characters. This is the main algorithm of O!N an image of every character must be converted to appropriate character code. $ometimes this algorithm produces several character codes for

uncertain images. 3or instance, recognition of the image of E(E character can produce E(E, EE E=E, ElE codes and the nal character code will be selected later.

(51)

>. lick !ecogni*e Text to get the text

0i#re . : Reco!ii! te%t.

10 . Saving results to selected output format, for instance, searchable TXT file format.

 And store (name, Text, Location, path and note of txt file in database directl! .

11 . "li#ing on Save to $otepad %ill open form to insert name and location of the file (&ro'se .

(52)

0i#re .$ : '+vi! te%t i! + !ote(+" >le.

=;. lick OP to open and save in a le.

(f the le name is already in the location you select a message will show ask you if you want to override or cancel to rename the le

.

(53)

0i#re . : O(e!i! + >le i! !ote(+".

1 .

(mport text to be edited and read in the editor and to be converted into voice " text0to0speech # conversion

.

(54)

• %hen !ou select the file ,the contents text 'ell loaded in the edit text )

0i#re .7 : 8o+"i! t)e co!te!ts o* t)e >le i!to t)e e"it te%t.

1* .

4sing database to view the recent documents that have been saved by this program

(55)

0i#re .19 : iewi! t)e rece!t "oc#me!t #si! t)e "+t+b+se.

=K . Open the text you have been saved in database in 7otepad

(56)

=I .  Gou can -dit the note .

(57)

0i#re .13 : U("+ti! t)e e"iti!.

=?. Gou can click on speak to load the text in main form. =. Absolutely you can delete from the list.

References

Related documents