Be It OFFLINE HANDWRITING RECOGNITION USING NEURAL NETWORK
Be It OFFLINE HANDWRITING RECOGNITION USING NEURAL NETWORK
In
Partial Fulfillment of Requirement for the
Degree of Bachelor of Engineering
In
Information & Technology
By
PALLAVI DUBEY
1
2008 - 2009
In
Partial Fulfillment of Requirement for the
Degree of Bachelor of Engineering
In
Information & Technology
By
PALLAVI DUBEY
2
Department of Information & Technology Engineering
2008 - 2009
CERTIFICATE
This is to certify that the project work entitled “OFFLINE HANDWRITING RECOGNITION
USING NEURAL NETWORK” submitted by Pallavi Dubey to the Department of
Information & Technology Engineering, SCOPE College of Engineering, Bhopal is a
bonafide work carried out by the student during the session 2008 - 2009 under the guidance of
undersigned. It is further certified that the work reported in the Project fulfills the requirement of
the ordinance related to the degree of Bachelor of Engineering in Information & Technology
from Rajiv Gandhi Proudyogiki Vishwavidyalaya, Bhopal.
Head Principal
(Project Guide) Department of Electronics &
3
Communication
4
DECLARATION
We hereby declare that work which is being presented in the major project entitled “OFFLINE
HANDWRITING RECOGNITION USING NEURAL NETWORK” is in partial fulfillment for
the awarded of Degree of Bachelor of Engineering in Information & Technology Engineering.
The work has been carried out at SCOPE College of Engineering, Bhopal and is an authentic
record of our own work.
Bhopal
Date
Pallavi Dubey
5
ACKNOWLEDGEMENT
We wish to express our sincere gratitude to our guide Mr. Vivek Tiwari for/his
inspiration, sustained help and invaluable guidance without this project could not have
been completed.
We are thankful to Prof. Sitesh Sinha, Head Department of Information & Technology
for his constant support and encouragement in carrying out the work for this project.
We are grateful to all our friends and those who were involved directly or indirectly in
completing this project.
Our utmost thanks go to our family members for their moral and financial support
throughout the academic year.
Pallavi Dubey
6
INDEX
1. Introduction
2. Preprocessing
2.1.Noise Reduction
2.2.Width Normalization
2.3.Skeletonization
3. Feature Extraction
3.1.Global Features
4. Related Work.
5. Classification
7. Implementation.
9. Future Work
10.Conclusion
11.Refrences
7
1. INTRODUCTION
As available computing power eventually increases and computer algorithms become
smarter, tasks that a few years ago seamed completely unfeasible, now come again to focus. This
partly explains why a considerable amount of research effort is recently devoted in designing
algorithms and techniques associated with the problems like human handwritten signature
recognition and verification.
A HRVS that is based on global and grid features. A technique based on thickened
templates that can be utilized as an initial face of a SRVS in order to reject Handwriting s that
are completely unmatched .A Handwriting retrieval and identification system based on
geometric and topologic features .In HRVS a directional probability density function in
conjunction with back propagation-trained neural networks is used . Used multiple neural
networks supplied by three sets of global features in combination with a neural network classifier
.However, the experimental results were based on a small number of samples.
In this report, a novel approach for off-line Handwriting recognition and verification is
proposed. The presented system is based on two powerful feature sets in combination with a
multiple-stage neural-network-based classifier (Fig.1).
The novelty of the system lies mainly on the structure of the classifier and the way that it
is used. The neural network classifier is arranged in two stages.
The ability to easily add/remove Handwriting from new /obsolete owner to its database
must be inherent. The approach toward this goal is to implement the structure of the neural
network classifier is a one class one network schema that is for each Handwriting owner of an
8
individual each time Handwriting from a new owner are added to the SRVS database, only a
small, fixed size neural network based classifier must be trained.
Moreover to farther overcome training difficulties stemming from the feature set size, the
proposed feature set is divided into three individual feature group of different physical meaning.
For each of the resulting two features group and individual multi layers perception neural
network is implemented. These three small and fixed size neural networks for each Handwriting
owner constitute the first stage of the classifiers. It is a lake of the second stage classifier ,a radial
basis function(RBF)neural network to combine the results of the first stage to make the final
decision of weather presented to the system Handwriting ,belongs to the candidate owner or not
The experimental results confirmed the effectiveness of the proposed structure and show
its ability to yield high recognition and verification rates.
9
2. PREPROCESSING
The preprocessing stage is divided into four different parts noise reduction, data area
cropping. Width normalization and Handwriting skeltonization.
Before any further processing takes place, A noise reduction filter is applied to the binary
scanned image .the goal is to eliminate single white pixels on black back ground and single black
pixels on white background und .In order t o accomplish this , we apply a 3 X 3 mask to the
image with a simple decision
Rule: if the no of the 8 neighbors of a pixel that have the same color with the central pixel
is less than two, we reverse the color of the central pixel .
The Handwriting area is separated from the background by using the well known
segmentation methods of vertical and horizontal projection.
The image size is adjusted so that the width reaches a default value while the height to
width ratio remains unchanged .
2.4 Skeletonization
Step 1:
Mark all the points of the Handwriting that are candidates for removing (black pixels
that have at least one white 8-neighbor and at least two black 8-neighborspixels).
Step 2:
Examine one by one all of them, following the contour lines of the Handwriting image,
and remove these as their removal will not cause a break in the resulting pattern.
10
Step 3:
If at least one point was deleted go again to Step 1 and repeat the process once more.
Fig.2. shows an example of this skeletonization technique. Skeletonization makes the extracted
features invariant to image characteristics like the qualities of the pen and the paper the signer
used, and the digitizing method and quality.
11
3. Feature Extraction
The choice of a powerful set of features is crucial in optical recognition systems. The
features used must be suitable for the application and for the applied classifier .In this system,
three groups of features are used categorized as global features and grid information.
While global features provide information about specific cases concerning the structure
of the Handwriting, grid information and texture features are intended to provide overall
Handwriting appearance information in two different levels of detail. For grid information
features, the image is segmented in 96 rectangular regions. Only the area (the number of
Handwriting points) in each region is utilized in order to form the grid information feature
group. For the texture feature group to be formed, a coarser segmentation scheme is adopted. The
Handwriting image is segmented in only six rectangular areas, while, for each area, information
about the transition of black and white pixels in the four deferent directions is used.
Image area.
12
Maximum vertical projection.
The vertical projection of the skeletonized Handwriting image is calculated. The highest
value of the projection histogram is taken as the maximum vertical projection.
As above, the horizontal projection histogram is calculated and the highest value of it is
considered as the maximum horizontal projection.
An edge point is defined as a Handwriting point that has only one 8-neighbor.
Number of cross points. Cross point is a Handwriting point that has at least
three 8-neighbors.
Figure 3: Examples of corner (C1, C2, C3, C4) and edge (E1, E2, E3, E4) points.
13
3.2. Grid Information Features
The skeletonized image is divided into 96 rectangular segments (12_8), and for each
segment, the area (the sum of foreground pixels) is calculated. The results are normalized so that
the lowest value (for the rectangle with the smallest number of black pixels) would be zero and
the highest value (for the rectangle with the highest number of black pixels) would be one. The
resulting 96 values form the grid feature vector. A representation of a Handwriting image and
the corresponding grid feature vector is shown in Fig. 4. A black rectangle indicates that for the
corresponding area of the skeletonized image we had the maximum number of black pixels. On
the contrary, a white rectangle
14
4. Related Work
Manke and Bodenhausen's A Connectionist Recognizer for On-Line cursive Handwriting
Recognition presented a Neural Network method for individual character recognition.
Their algorithm utilizes a sequence of time delay neural networks which are time shift
independent and aligns the output of the sequence with the Dynamic Time Warping algorithm.
The Dynamic Time Warping algorithm that appears in this paper as well as many others is
described in detail later.
The Time Delay Neural Network (TDNN) architecture consists of input, hidden and
output layers. Each node in the hidden layer is connected to a fixed sized time-window of the
input layer, and each node in the output layer is connected to a fixed size timewindow of the
hidden layer. Thus, multiple TDNN's can be strung together for the length of the input and
produce, for each element in the time sequence, a set of estimated likelihoods for all letters. In
practice, 78 output neurons are used, 3 for each letter, denoting the beginning, the middle and
end of each letter. This combination of the TDNN with DTW is called the Multi-State Time
Delay Neural Network (MS-TDNN). Each neuron is a summing unit with a sigmoid squashing
function applied to the output. Like many other multi-layer neural networks, it is trained via
back-propagation with a momentum term.
The alignment of the outputs is done with the aid of a dictionary. For each word in the
dictionary, the DTW algorithm is used to align the word optimally with the outputs of the MS-
TDNN. The word with the smallest cumulative error in its optimal alignment is outputted as the
optimal word. This reliance on a dictionary as the sole language model is the weakness of most
current algorithms as they cannot recognize strings such as names that are not in the dictionary or
abbreviations which humans can. The authors evaluate both a writer dependent and writer
independent version of the MSTDNN algorithm. The size of the dictionary ranges from 400 to
20000 words. Naturally, as the dictionary size increases, the recognition rate decreases.
Distinguishing words like “jog” and “joy” or “dump” and “clump” can confuse even human
recognizers. The recognition rate varied between 97.7% and 83.0%. Fortunately, the future work
section of the paper indicates that the authors are testing the MS-TDNN framework with an N-
best dynamic programming search driven by a language model instead of a fixed dictionary.
15
The architecture is also being used for speech recognition. Keogh and Pazzani present a
modification of the standard DTW algorithm that aligns a sequence of derivatives instead of the
raw data in Derivative Dynamic Time Warping. The problem with the standard DTW algorithm
is that it may try to explain warping of the Y-axis by warping the X (time) axis. This can lead to
very non-intuitive alignments where a single point on the time series is mapped onto a long
section of the other sequence. The authors call this effect a “singularity.” Most methods deal
with such a problem by constraining the possible deviation from the perfect alignment. The
algorithm presented by the authors operates on the approximate local derivatives of the data
instead of the coordinates themselves.
The problems arise when there are small differences in the Y axis, and singularities are
produced by the DTW algorithm. The DDTW algorithm first smooths the data so local
derivatives can be measured more accurately. The distance measure between two datapoints is
the difference in their derivatives. The time complexity for the two algorithms is the same as the
distance between two points is computed in constant time and the rest of the algorithm is
virtually identical. All the optimizations that apply to DTW also apply to DDTW.
Experimental results show that the mean warping, defined as the average warping for all
data-points in the optimal alignment, is significantly lower in the DDTW algorithm than in
DTW. Across three datasets, the mean warping for DTW ranged from 0.17 to 0.24 and from 0.03
to 0.04 for DDTW. The results of the authors show that the mean warping stays the same as the
size of random Gaussian bumps in the data increase, while the DTW algorithm implies much
more warping in the alignment. Future work seeks to use piecewise segments and Fourier
transforms instead of local derivatives, which would reduce the algorithm's complexity, since
Fourier transforms with a constant number of coefficients would be used.
16
Although an English professor will have a significantly larger vocabulary than a high
school student, he reads at the same speed as the high school student. The proposed algorithm
expresses the lexicon as a trie and attempts to optimally interpret the hypothesis graph with
respect to the trie. The algorithm assumes that a character recognizer has already assigned a cost
to each edge in the graph. The horizontal axis in the DP table represents the transition between
characters while the vertical axis represents the transition between graphemes. There are three
options for each element in the DP table. Either one grapheme is matched to a character, a
grapheme is omitted, or multiple graphemes are matched to a single character. Each transition is
weighted by the cost of the edge in the hypothesis graph corresponding to that transition. Each
entry in the table represents the cost or confidence of matching the first i characters with the first
j graphemes. In his dissertation, Jong Oh presents a complete on-line handwriting recognition
engine. One of the key elements in the dissertation is the comparison between Viterbi search and
Hypothesis Propagation Network search. The latter is a modification of the dynamic rogramming
algorithm presented by Chen 2 years earlier, and also uses a trie data structure to store the
lexicon. According to Oh, the Viterbi search resulted in a 73% recognition rate, while the
hypothesis graph search achieved a much higher 85% recognition rate. This increase is most
likely due to the lack of a 1st order Markov assumption in the hypothesis graph search.
17
5. Classification
Multi-layer Perceptron (MLP) neural networks are among the most commonly used
classifiers for pattern recognition problems. Despite their advantages, they suffer from some very
serious limitations that make their use, for some problems, impossible. The first limitation is the
size of the neural network. It is very dificult, for very large neural networks, to get trained. As
the amount of the training data increases, this dificulty becomes a serious obstacle for the
training process.
The second dificulty is that the geometry, the size of the network, the training method
used and the training parameters depend substantially on the amount of the training data. Also, in
order to specify the structure and the size of the neural network, it is necessary to know a priori
the number of the classes that the neural network will have to deal with. Unfortunately, when
talking about a useful SRVS, a priori knowledge about the number of Handwriting s and the
number of the Handwriting owners is not available. The proposed SRVS confronts these
problems by reducing the training computation time and the size of the neural networks used.
This is achieved by:
Reduction of the feature space. The feature set is split to two different groups, i.e.,
global features and grid features. Due to the different nature and the uncorrelation of the two
feature sets, the combination of the two feature vectors covers the required feature information.
Reduction of the necessary training samples. This is achieved because each neural
network corresponds to only one Handwriting owner. Specifically, during the first stage of
classification, multiple but fixed-size neural networks are used (Figs. 1 and 6). In Fig. 1, each
one of the neural-networks NN1 and NN2 specializes in Handwriting s of only one person. For
practical systems, this approach offers another significant advantage: each time we want to add a
set of Handwriting s (a new person) to the systems database,we only have to train two new
small neural networks (one for each set of features). It is not necessary to retrain a very large
neural network, which is of course a much more dificult situation. Due to the use of many neural
networks, it is necessary to apply a training algorithm that can train them eficiently, avoiding
local minima. Due to its stochastic nature, it presents a remarkable tendency to avoid local
minima.
18
In this work a Backward Propagation neural network is used in order to have the final
decision. The Backward Propagation neural networks are feed-forward architectures with a
hidden non-linear layer and a linear output layer. The structure of the network used here is
shown in Fig. 7. The network has four inputs (fed by the outputs of the first-stage classifiers), a
hidden layer with two non-linear neurons and a simple output linear neuron.
19
6. K-nearest neighbor algorithm
In pattern recognition, the k-nearest neighbor’s algorithm (k-NN) is a method for
classifying objects based on closest training examples in the feature space. k-NN is a type of
instance-based learning, or lazy learning where the function is only approximated locally and all
computation is deferred until classification. It can also be used for regression.
Overview
The k-nearest neighbor algorithm is amongst the simplest of all machine learning
algorithms. An object is classified by a majority vote of its neighbors, with the object being
assigned to the class most common amongst its k nearest neighbors. k is a positive integer,
typically small. If k = 1, then the object is simply assigned to the class of its nearest neighbor. In
binary (two class) classification problems, it is helpful to choose k to be an odd number as this
avoids tied votes.
The same method can be used for regression, by simply assigning the property value for
the object to be the average of the values of its k nearest neighbors. It can be useful to weight the
contributions of the neighbors, so that the nearer neighbors contribute more to the average than
the more distant ones.
The neighbors are taken from a set of objects for which the correct classification (or, in
the case of regression, the value of the property) is known. This can be thought of as the training
set for the algorithm, though no explicit training step is required. In order to identify neighbors,
the objects are represented by position vectors in a multidimensional feature space. It is usual to
use the Euclidean distance, though other distance measures, such as the Manhattan distance
could in principle be used instead. The k-nearest neighbor algorithm is sensitive to the local
structure of the data.
Algorithm
20
Example of k-NN classification. The test sample (green circle) should be classified either
to the first class of blue squares or to the second class of red triangles. If k = 3 it is classified to
the second class because there are 2 triangles and only 1 square inside the inner circle. If k = 5 it
is classified to first class (3 squares vs. 2 triangles inside the outer circle).
The training examples are vectors in a multidimensional feature space. The space is
partitioned into regions by locations and labels of the training samples. A point in the space is
assigned to the class c if it is the most frequent class label among the k nearest training samples.
Usually Euclidean distance is used as the distance metric, however this will only work with
numerical values. In cases such as text classification another metric, such as the overlap metric
(or Hamming distance) can be used.
The training phase of the algorithm consists only of storing the feature vectors and class
labels of the training samples. In the actual classification phase, the test sample (whose class is
not known) is represented as a vector in the feature space. Distances from the new vector to all
stored vectors are computed and k closest samples are selected. There are a number of ways to
classify the new vector to a particular class, one of the most used techniques is to predict the new
vector to the most common class amongst the K nearest neighbors. A major drawback to using
this technique to classify a new vector to a class is that the classes with the more frequent
examples tend to dominate the prediction of the new vector, as they tend to come up in the K
nearest neighbors when the neighbors are computed due to their large number. One of the ways
to overcome this problem is to take into account the distance of each K nearest neighbors with
the new vector that is to be classified and predict the class of the new vector based on these
distances.
Parameter selection
The best choice of k depends upon the data; generally, larger values of k reduce the effect
of noise on the classification, but make boundaries between classes less distinct. A good k can be
selected by various heuristic techniques, for example, cross-validation. The special case where
the class is predicted to be the class of the closest training sample (i.e. when k = 1) is called the
nearest neighbor algorithm.
21
The accuracy of the k-NN algorithm can be severely degraded by the presence of noisy or
irrelevant features, or if the feature scales are not consistent with their importance. Much
research effort has been put into selecting or scaling features to improve classification. A
particularly popular approach is the use of evolutionary algorithms to optimize feature scaling.
Another popular approach is to scale features by the mutual information of the training data with
the training classes.
Properties
The naive version of the algorithm is easy to implement by computing the distances from
the test sample to all stored vectors, but it is computationally intensive, especially when the size
of the training set grows. Many nearest neighbor search algorithms have been proposed over the
years; these generally seek to reduce the number of distance evaluations actually performed.
Some optimizations involve partitioning the feature space, and only computing distances within
specific nearby volumes. Several different types of nearest neighbor finding algorithms include:
Linear scan
Kd-trees
Ball trees
Metric trees
Agglomerative-Nearest-Neighbor
The nearest neighbor algorithm has some strong consistency results. As the amount of
data approaches infinity, the algorithm is guaranteed to yield an error rate no worse than twice
the Bayes error rate (the minimum achievable error rate given the distribution of the data). k-
nearest neighbor is guaranteed to approach the Bayes error rate, for some value of k (where k
increases as a function of the number of data points).
22
The k-NN algorithm can also be adapted for use in estimating continuous variables. One
such implementation uses an inverse distance weighted average of the k-nearest multivariate
neighbors. This algorithm functions as follows:
Compute Euclidean or Mahalanobis distance from target plot to those that were
sampled.
23
7. Implementation:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmDWH
BorderStyle = 3 'Fixed Dialog
Caption = "DWH"
ClientHeight = 3600
ClientLeft = 1095
ClientTop = 435
ClientWidth = 5775
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3600
ScaleWidth = 5775
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox picButtons
Align = 2 'Align Bottom
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 300
Left = 0
ScaleHeight = 300
ScaleWidth = 5775
TabIndex = 4
Top = 2970
Width = 5775
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 300
24
Left = 4675
TabIndex = 9
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 300
Left = 3521
TabIndex = 8
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "&Delete"
Height = 300
Left = 2367
TabIndex = 7
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdUpdate
Caption = "&Update"
Height = 300
Left = 1213
TabIndex = 6
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "&Add"
Height = 300
Left = 59
25
TabIndex = 5
Top = 0
Width = 1095
End
End
Begin VB.TextBox txtFields
DataField = "B"
DataSource = "datPrimaryRS"
Height = 285
Index = 1
Left = 1320
TabIndex = 3
Top = 2055
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "A"
DataSource = "datPrimaryRS"
Height = 285
Index = 0
Left = 1320
TabIndex = 1
Top = 1620
Width = 3375
End
Begin MSAdodcLib.Adodc datPrimaryRS
Align = 2 'Align Bottom
Height = 330
Left = 0
Top = 3270
Width = 5775
_ExtentX = 10186
_ExtentY = 582
26
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from DWH"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
27
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "B:"
Height = 195
Index = 1
Left = 1065
TabIndex = 2
Top = 2055
Width = 150
End
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "A:"
Height = 195
Index = 0
Left = 1065
TabIndex = 0
Top = 1620
Width = 150
End
End
Attribute VB_Name = "frmDWH"
Attribute VB_GlobalNameSpace = False
28
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
29
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
30
End Sub
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0";
"MSDATGRD.OCX"
Begin VB.Form frmDWHs
Caption = "DWH"
ClientHeight = 4140
ClientLeft = 1110
31
ClientTop = 450
ClientWidth = 5745
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 4140
ScaleWidth = 5745
Begin VB.PictureBox picButtons
Align = 2 'Align Bottom
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 300
Left = 0
ScaleHeight = 300
ScaleWidth = 5745
TabIndex = 1
Top = 3510
Width = 5745
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 300
Left = 4675
TabIndex = 6
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 300
Left = 3521
TabIndex = 5
Top = 0
Width = 1095
32
End
Begin VB.CommandButton cmdDelete
Caption = "&Delete"
Height = 300
Left = 2367
TabIndex = 4
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdUpdate
Caption = "&Update"
Height = 300
Left = 1213
TabIndex = 3
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "&Add"
Height = 300
Left = 59
TabIndex = 2
Top = 0
Width = 1095
End
End
Begin MSAdodcLib.Adodc datPrimaryRS
Align = 2 'Align Bottom
Height = 330
Left = 0
Top = 3810
Width = 5745
_ExtentX = 10134
33
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=CDB.mdb;"
OLEDBString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data
Source=CDB.mdb;"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select AID,FRAME,NAME from DWH"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
34
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid grdDataGrid
Align = 1 'Align Top
Bindings = "frmDWHs.frx":0000
Height = 3495
Left = 0
TabIndex = 0
Top = 0
Width = 5745
_ExtentX = 10134
_ExtentY = 6165
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
AllowAddNew = -1 'True
AllowDelete = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
35
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 1033
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 1033
36
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmDWHs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
37
'If you want to trap them, add code here to handle them
MsgBox "Data error event hit err:" & Description
End Sub
38
Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.MoveLast
grdDataGrid.SetFocus
SendKeys "{down}"
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
39
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmKP
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
BorderStyle = 0 'None
Caption = "KP"
ClientHeight = 1410
ClientLeft = 1050
ClientTop = 0
ClientWidth = 5775
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1410
ScaleWidth = 5775
ShowInTaskbar = 0 'False
40
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox picButtons
Align = 2 'Align Bottom
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 300
Left = 0
ScaleHeight = 300
ScaleWidth = 5775
TabIndex = 4
Top = 780
Width = 5775
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 300
Left = 4675
TabIndex = 9
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 300
Left = 3521
TabIndex = 8
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "&Delete"
Height = 300
Left = 2367
41
TabIndex = 7
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdUpdate
Caption = "&Update"
Height = 300
Left = 1213
TabIndex = 6
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "&Add"
Height = 300
Left = 59
TabIndex = 5
Top = 0
Width = 1095
End
End
Begin VB.TextBox txtFields
DataField = "NAME"
DataSource = "datPrimaryRS"
Height = 285
Index = 1
Left = 2040
TabIndex = 3
Top = 380
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "ID"
42
DataSource = "datPrimaryRS"
Height = 285
Index = 0
Left = 2040
TabIndex = 1
Top = 60
Width = 3375
End
Begin MSAdodcLib.Adodc datPrimaryRS
Align = 2 'Align Bottom
Height = 330
Left = 0
Top = 1080
Width = 5775
_ExtentX = 10186
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
43
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select ID,NAME from KP"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label lblLabels
BackStyle = 0 'Transparent
Caption = "NAME:"
Height = 255
Index = 1
Left = 120
TabIndex = 2
Top = 380
Width = 1815
44
End
Begin VB.Label lblLabels
BackStyle = 0 'Transparent
Caption = "ID:"
Height = 255
Index = 0
Left = 120
TabIndex = 0
Top = 60
Width = 1815
End
End
Attribute VB_Name = "frmKP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
45
'This will display the current record position for this recordset
datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
Exit Sub
46
AddErr:
MsgBox Err.Description
End Sub
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
47
Private Sub cmdClose_Click()
Unload Me
End Sub
VERSION 5.00
Begin VB.Form FrmMain
Caption = "Panel"
ClientHeight = 1350
ClientLeft = 60
ClientTop = 450
ClientWidth = 4095
LinkTopic = "Form1"
ScaleHeight = 1350
ScaleWidth = 4095
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command6
Caption = "Exit"
Height = 495
Left = 2760
TabIndex = 5
Top = 720
Width = 1215
End
Begin VB.CommandButton Command5
Caption = "DWH"
Height = 495
Left = 1440
TabIndex = 4
Top = 720
Width = 1215
48
End
Begin VB.CommandButton Command4
Caption = "True False"
Height = 495
Left = 120
TabIndex = 3
Top = 720
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "New Person"
Height = 495
Left = 2760
TabIndex = 2
Top = 120
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Tuple"
Height = 495
Left = 1440
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Frame"
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
49
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
frmFrame.Show
End Sub
VERSION 5.00
50
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmTF
BorderStyle = 3 'Fixed Dialog
Caption = "TRUE FALSE"
ClientHeight = 2400
ClientLeft = 1095
ClientTop = 435
ClientWidth = 5775
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2400
ScaleWidth = 5775
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "GRAPH"
Height = 735
Left = 4440
TabIndex = 14
Top = 120
Width = 1215
End
Begin VB.PictureBox picButtons
Align = 2 'Align Bottom
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 300
Left = 0
ScaleHeight = 300
ScaleWidth = 5775
TabIndex = 8
51
Top = 1770
Width = 5775
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 300
Left = 4675
TabIndex = 13
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 300
Left = 3521
TabIndex = 12
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "&Delete"
Height = 300
Left = 2367
TabIndex = 11
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdUpdate
Caption = "&Update"
Height = 300
Left = 1213
TabIndex = 10
Top = 0
Width = 1095
52
End
Begin VB.CommandButton cmdAdd
Caption = "&Add"
Height = 300
Left = 59
TabIndex = 9
Top = 0
Width = 1095
End
End
Begin VB.TextBox txtFields
DataField = "RESULTS"
DataSource = "datPrimaryRS"
Height = 285
Index = 3
Left = 960
TabIndex = 7
Top = 1380
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "NAME"
DataSource = "datPrimaryRS"
Height = 285
Index = 2
Left = 960
TabIndex = 5
Top = 945
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "FRAME"
DataSource = "datPrimaryRS"
53
Height = 285
Index = 1
Left = 960
TabIndex = 3
Top = 495
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "AID"
DataSource = "datPrimaryRS"
Height = 285
Index = 0
Left = 960
TabIndex = 1
Top = 60
Width = 3375
End
Begin MSAdodcLib.Adodc datPrimaryRS
Align = 2 'Align Bottom
Height = 330
Left = 0
Top = 2070
Width = 5775
_ExtentX = 10186
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
54
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\reHAND\
CDB.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select AID,FRAME,NAME,RESULTS from TRUEFALSE"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
55
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "RESULTS:"
Height = 195
Index = 3
Left = 60
TabIndex = 6
Top = 1380
Width = 795
End
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "NAME:"
Height = 195
Index = 2
Left = 345
TabIndex = 4
Top = 945
Width = 510
End
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "ERROR:"
Height = 195
Index = 1
Left = 225
TabIndex = 2
Top = 495
Width = 630
End
56
Begin VB.Label lblLabels
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "AID:"
Height = 195
Index = 0
Left = 540
TabIndex = 0
Top = 60
Width = 315
End
End
Attribute VB_Name = "frmTF"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
57
End Sub
58
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
datPrimaryRS.Recordset.UpdateBatch adAffectAll
59
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0";
"COMDLG32.OCX"
Begin VB.Form frmTuple
Caption = "Tuple"
ClientHeight = 5235
ClientLeft = 60
ClientTop = 450
ClientWidth = 6735
LinkTopic = "Form1"
ScaleHeight = 5235
ScaleWidth = 6735
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 5880
Top = 4800
End
Begin VB.TextBox Text2
Height = 285
Left = 120
60
TabIndex = 8
Top = 1320
Width = 4695
End
Begin VB.CommandButton cmddwh
Caption = "Enter in Data Ware House"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 7
Top = 720
Width = 4695
End
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 3015
Left = 120
ScaleHeight = 199
ScaleMode = 3 'Pixel
ScaleWidth = 311
TabIndex = 6
Top = 1680
Width = 4695
61
End
Begin VB.CommandButton cmdAna
Caption = "Trace"
Enabled = 0 'False
Height = 495
Left = 2520
TabIndex = 5
Top = 120
Width = 1095
End
Begin VB.TextBox Text1
Height = 405
Left = 5520
TabIndex = 4
Top = 4800
Visible = 0 'False
Width = 375
End
Begin VB.ListBox List1
Height = 4545
ItemData = "frmTuple.frx":0000
Left = 4920
List = "frmTuple.frx":0002
TabIndex = 3
Top = 120
Width = 1695
End
Begin VB.CommandButton cmdDecode
Caption = "Create Tuple"
Enabled = 0 'False
Height = 495
Left = 1320
TabIndex = 2
62
Top = 120
Width = 1095
End
Begin VB.CommandButton cmdchk
Caption = "Check"
Enabled = 0 'False
Height = 495
Left = 3720
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.CommandButton cmdOpen
Caption = "Open"
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1095
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 6240
Top = 4800
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Image Image1
Height = 360
Left = 120
Picture = "frmTuple.frx":0004
Stretch = -1 'True
Top = 4800
63
Width = 100
End
End
Attribute VB_Name = "frmTuple"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long,
ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long,
ByVal y As Long, ByVal crColor As Long) As Long
64
frmDWH.Hide
Timer1.Interval = I
Timer1.Enabled = True
End Sub
End Sub
For I = 0 To Picture1.Height
color2 = GetPixel(Picture1.hdc, I, 1)
color = GetPixel(Picture1.hdc, I, 0)
If color <> -1 Then List1.AddItem Hex(color) & " " & Hex(color2) & " " & color2 -
color
Select Case color2 - color
65
'Case 37
'Text1.Text = Text1.Text + " "
'Case 36
'Text1.Text = Text1.Text + "9"
'Case 35
'Text1.Text = Text1.Text + "8"
'Case 34
'Text1.Text = Text1.Text + "7"
'Case 33
'Text1.Text = Text1.Text + "6"
'Case 32
'Text1.Text = Text1.Text + "5"
'Case 31
'Text1.Text = Text1.Text + "4"
'Case 30
'Text1.Text = Text1.Text + "3"
'Case 29
'Text1.Text = Text1.Text + "2"
'Case 28
'Text1.Text = Text1.Text + "1"
'Case 27
'Text1.Text = Text1.Text + "0"
66
Case 26
Text1.Text = Text1.Text + "Z"
Case 25
Text1.Text = Text1.Text + "Y"
Case 24
Text1.Text = Text1.Text + "X"
Case 23
Text1.Text = Text1.Text + "W"
Case 22
Text1.Text = Text1.Text + "V"
Case 21
Text1.Text = Text1.Text + "U"
Case 20
Text1.Text = Text1.Text + "T"
Case 19
Text1.Text = Text1.Text + "S"
Case 18
Text1.Text = Text1.Text + "R"
Case 17
Text1.Text = Text1.Text + "Q"
Case 16
Text1.Text = Text1.Text + "P"
67
Case 15
Text1.Text = Text1.Text + "O"
Case 14
Text1.Text = Text1.Text + "N"
Case 1
Text1.Text = Text1.Text + "M"
Case 2
Text1.Text = Text1.Text + "L"
Case 3
Text1.Text = Text1.Text + "K"
Case 4
Text1.Text = Text1.Text + "J"
Case 5
Text1.Text = Text1.Text + "I"
Case 6
Text1.Text = Text1.Text + "H"
Case 7
Text1.Text = Text1.Text + "G"
Case 8
Text1.Text = Text1.Text + "F"
Case 9
Text1.Text = Text1.Text + "E"
68
Case 10
Text1.Text = Text1.Text + "D"
Case 11
Text1.Text = Text1.Text + "C"
Case 12
Text1.Text = Text1.Text + "B"
Case 13
Text1.Text = Text1.Text + "A"
End Select
Next
Me.Caption = UCase(Text1.Text)
cmdAna.Enabled = True
End Sub
69
If Image1.Width = 6500 Then
frmDWH.Show
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "CTIME" & "'"
C = frmDWH.txtFields(1).Text
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "ETIME" & "'"
E = frmDWH.txtFields(1).Text
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "FACTOR" & "'"
F = frmDWH.txtFields(1).Text
frmKP.Show
frmDWH.Hide
frmKP.datPrimaryRS.Recordset.Filter = "ID='" & Me.Caption & "'"
MsgBox C
MsgBox E
If E < 16 Then
E=E+1
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "ETIME" & "'"
frmDWH.txtFields(1).Text = E
frmDWH.datPrimaryRS.Recordset.MoveNext
MsgBox "Unknown1"
Else
If C = (E + 1) Then
F = F + Round(Sqr(E))
E=E+F
MsgBox E
MsgBox F
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "ETIME" & "'"
frmDWH.txtFields(1).Text = E
frmDWH.datPrimaryRS.Recordset.MoveNext
frmDWH.datPrimaryRS.Recordset.Filter = "A='" & "FACTOR" & "'"
frmDWH.txtFields(1).Text = F
frmDWH.datPrimaryRS.Recordset.MoveNext
MsgBox "Unknown2"
Else
70
MsgBox frmKP.txtFields(1).Text
End If
End If
frmKP.Hide
frmTF.Show
Timer1.Enabled = False
Image1.Width = 100
End If
End Sub
VERSION 5.00
Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0";
"MSCHRT20.OCX"
Begin VB.Form gr
Caption = "TRUEFALSE"
ClientHeight = 5085
ClientLeft = 1110
ClientTop = 450
ClientWidth = 6675
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 5085
ScaleWidth = 6675
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "Close"
Height = 300
Left = 60
TabIndex = 1
Top = 3960
Width = 1080
End
71
Begin MSChart20Lib.MSChart chtReport
Height = 3840
Left = 60
OleObjectBlob = "gr.frx":0000
TabIndex = 0
Top = 60
Width = 6360
End
End
Attribute VB_Name = "gr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
72
'-------------------------------------------------------------------------
'Purpose: Display an error message to the user
'In:
' [oError]
' Error object containing error information
'-------------------------------------------------------------------------
Private Sub DisplayError(oError As ErrObject)
MsgBox oError.Description, vbExclamation, App.Title
End Sub
73
Dim sngButtonTop As Single
Dim sngScaleWidth As Single
Dim sngScaleHeight As Single
'-------------------------------------------------------------------------
'Purpose: Determines if the passed key is being used in the
' passed collection.
'In:
' [cCol] The collection to check for key use in.
' [sKey] The key to look for.
'Return: If the key is being used by the collection, true
74
' is returned. Otherwise, false is returned.
'-------------------------------------------------------------------------
Private Function IsKeyInCollection(cCol As Collection, sKey As String) As Boolean
Dim v As Variant
On Error Resume Next
v = cCol.Item(sKey)
'It is important to check for error 5, rather than checking for
'any error, because an error could occur even if the key is valid.
'If the key existed, but it was associated with an element that
'was an object, an error would occur because 'Set' wasn't used
'to assign it to 'v'.
IsKeyInCollection = (Err.Number <> VBERR_INVALID_PROCEDURE_CALL)
Err.Clear
End Function
'----------------------------------------------------------
'Purpose: Shows or Hides series markers, according to the
' parameter.
'In:
' [bShow] If true, all the series markers will be shown.
' Otherwise, all the series markers will be hidden.
'----------------------------------------------------------
Private Sub ShowMarkers(bShow As Boolean)
Dim i As Long
On Error GoTo ShowMarkers_Click_Error
With chtReport.Plot
For i = 1 To .SeriesCollection.Count
.SeriesCollection(i).SeriesMarker.Show = bShow
Next
End With
Exit Sub
ShowMarkers_Click_Error:
DisplayError Err
75
Exit Sub
End Sub
'----------------------------------------------------------
'Purpose: Displays the data summarized in the passed recordset
' in the Chart.
'In:
' [recParent]
' A recordset created using a Shape command, that
' groups by one or two fields, and summarizes one.
' [sFldX]
' The name of the field to group by on the X axis.
' [sFldY]
' The name of the field to summarize on the Y axis.
' [sFldZ]
' The name of the field to group by on the Z axis. This
' field should be a zero length string, if the recordset
' only groups by one field.
'----------------------------------------------------------
Private Sub ShowRecordsInChart(recParent As Recordset, _
sFldX As String, _
sFldY As String, _
sFldZ As String)
76
On Error GoTo ShowRecordsInChart_Error
If Len(sFldZ) = 0 Then bUseZ = False Else bUseZ = True
With Me.chtReport
'Turn off chart painting
.Repaint = False
With .DataGrid
'Clear the chart
.DeleteRows 1, .RowCount
.DeleteColumns 1, .ColumnCount
.DeleteColumnLabels 1, .ColumnLabelCount
.DeleteRowLabels 1, .RowLabelCount
'Make sure there is one level of labels
.InsertColumnLabels 1, 1
.InsertRowLabels 1, 1
'If the Z axis is not being used, make
'sure there is one column
If Not bUseZ Then .InsertColumns 1, 1
recParent.MoveFirst
Do Until recParent.EOF
'Make sure a row is added for this X field
sValue = FixNull(recParent.Fields(sFldX).Value, False)
If Not IsKeyInCollection(cRows, sValue) Then
lMaxRow = lMaxRow + 1
lRow = lMaxRow
'Store the row index associated with
'the Row name
cRows.Add lRow, sValue
.InsertRows lRow, 1
.RowLabel(lRow, 1) = sValue
77
Else
lRow = cRows.Item(sValue)
End If
78
ShowRecordsInChart_Error:
'Make sure the charts painting is turned back on
Me.chtReport.Repaint = True
DisplayError Err
Exit Sub
End Sub
'-------------------------------------------------------------------------
'Purpose: Checks a variant value for null. If the value is null, returns
' a vbNullString or a zero.
'In:
' [vField]
' The variant to check for null.
' [bNumericRequired]
' If true, return 0 if the variant is null. Otherwise, return
' vbNullString.
'-------------------------------------------------------------------------
Private Function FixNull(vField As Variant, _
bNumericRequired As Boolean) As Variant
If IsNull(vField) Then
If bNumericRequired Then
FixNull = 0
Else
FixNull = vbNullString
End If
Else
FixNull = vField
End If
End Function
79
GDI 32 program:
Gdi32 function program code:
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
80
ByVal hdc As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long _
) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" ( _
ByVal hdc As Long _
) As Long
Private Declare Function BitBlt Lib "gdi32" ( _
ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" ( _
ByVal hObject As Long _
) As Long
81
lhDCCopy = CreateCompatibleDC(lhDCC)
lhBmpCopy = CreateCompatibleBitmap(lhDCC, tBM.bmWidth, tBM.bmHeight)
lhBmpCopyOld = SelectObject(lhDCCopy, lhBmpCopy)
HBitmapFromPicture = lhBmpCopy
End Sub
82
' Copy the bitmap in lHDC:
Dim lhDCCopy As Long
Dim lhBmpCopy As Long
Dim lhBmpCopyOld As Long
Dim lhDCC As Long
Dim tBM As BITMAP
HBitmapFromDC = lhBmpCopy
End Sub
To test out the functions, add a PictureBox to the project's form, and load a picture into it.
Then add a CommandButton and the following code:
83
left As Long
top As Long
right As Long
bottom As Long
End Type
Dim tR As RECT
tR.Left = Rnd * Me.ScaleWidth \ Screen.TwipsPerPixelX
tR.Top = Rnd * Me.ScaleHeight \ Screen.TwipsPerPixelY
tR.Right = tR.Left + Rnd * Me.ScaleWidth \ (Screen.TwipsPerPixelX * 2)
tR.Bottom = tR.Top + Rnd * Me.ScaleHeight \ (Screen.TwipsPerPixelY * 2)
FillRect Me.hDC, tR, hBr
DeleteObject hBr
84
End Sub
Ebpa Code
85
Private Sub Command3_Click()
Dim CustomSituation As DayType
Call EnableControls(False)
Call SetDay(CustomSituation, Combo(0).ListIndex, Combo(1).ListIndex,
Combo(2).ListIndex, Combo(3).ListIndex, True)
Call GetResult(CustomSituation, D, ComboNeighbors.ListIndex + 1)
Call EnableControls(True)
End Sub
Call EnableControls(False)
frmMain.Info.Text = ""
AddInfo "Performing Forward Selection on data set..." & vbCrLf
For n = 1 To nFeatures
Msg = ""
ThisDeviation = 0
Call SetSelectionFeature(n)
For i = LBound(D) To UBound(D)
Cur = 1
ReDim D2(LBound(D) To UBound(D) - 1)
For j = LBound(D) To UBound(D)
If i <> j Then
D2(Cur) = D(j)
86
Cur = Cur + 1
End If
Next j
For j = LBound(D2) To UBound(D2)
Call CreateScale(D2(n), D2)
Next j
Expected = GetResult(D(i), D2, ComboNeighbors.ListIndex + 1, False)
ThisDeviation = ThisDeviation + Abs(GetOutput(Output(i)) - Expected)
DoEvents
Next i
For m = 1 To Deviations.Count
If Deviations(m) > ThisDeviation Then
DeviationIndexes.Add n, , m
Deviations.Add ThisDeviation, , m
GoTo NextFeature
End If
Next m
DeviationIndexes.Add n
Deviations.Add ThisDeviation
NextFeature:
Msg = Msg & "Leaving out feature " & DispFeature(n) & " gives a total deviation
of:" & vbCrLf & ThisDeviation & vbCrLf
AddInfo Msg
Next n
Call SetSelectionFeature(0)
Call EnableControls(True)
87
End Sub
Check2.Value = 1
88
Call SetDay(Situation2, conti, decr, Normal, Weak, True)
Combo(0).AddItem "conti"
Combo(0).AddItem "Overcast"
Combo(0).AddItem "incr"
Combo(0).ListIndex = 0
Combo(1).AddItem "abrupt"
Combo(1).AddItem "Mild"
Combo(1).AddItem "decr"
Combo(1).ListIndex = 0
Combo(2).AddItem "Normal"
Combo(2).AddItem "High"
Combo(2).ListIndex = 0
Combo(3).AddItem "Weak"
Combo(3).AddItem "Strong"
Combo(3).ListIndex = 0
89
Me.Width = ((Me.Width / Screen.TwipsPerPixelX - Me.ScaleWidth) + Info.Left +
Info.Width + 8) * Screen.TwipsPerPixelX
Me.Height = ((Me.Height / Screen.TwipsPerPixelY - Me.ScaleHeight) +
ButtonBox.Top + ButtonBox.Height + 8) * Screen.TwipsPerPixelY
Info.Height = Me.ScaleHeight - Info.Top - 8
Table.AutoRedraw = True
y=0
For n = LBound(D) - 1 To UBound(D)
y=y+1
If n < LBound(D) Then
Table.Line (0, (y * 18) + 3)-(Table.Width, (y * 18) + 3)
Table.Line (53, 0)-(53, Table.Height)
Table.Line (343, 0)-(343, Table.Height)
End If
Table.CurrentX = 7
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
Table.Print "Days"
Else
Table.CurrentY = (y * 18) - 10
Table.Print "Day " & n;
End If
Table.CurrentX = 65
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
Table.Print "Outlook"
Else
Table.CurrentY = (y * 18) - 10
Table.Print ShowOutlook(D(n).Outlook)
End If
Table.CurrentX = 135
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
90
Table.Print "Xi"
Else
Table.CurrentY = (y * 18) - 10
Table.Print ShowXi(D(n).Xi)
End If
Table.CurrentX = 205
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
Table.Print "Yi"
Else
Table.CurrentY = (y * 18) - 10
Table.Print ShowYi(D(n).Yi)
End If
Table.CurrentX = 275
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
Table.Print "Ii"
Else
Table.CurrentY = (y * 18) - 10
Table.Print ShowIi(D(n).Ii)
End If
Table.CurrentX = 355
If n < LBound(D) Then
Table.CurrentY = (y * 18) - 14
Table.Print "Declare"
Else
Table.CurrentY = (y * 18) - 10
Table.Print ShowOutput(Output(n))
End If
Next n
End Sub
91
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload frmMenus
End Sub
Modules
Public D(1 To 14) As DayType
Public D2() As DayType
Type DayType
Outlook As OutlookEnum
Xi As XiEnum
Yi As YiEnum
Ii As IiEnum
Scaled_Outlook As Double
Scaled_Xi As Double
Scaled_Yi As Double
Scaled_Ii As Double
Distance As Double
Match As Long
End Type
Public Const nFeatures = 4
Public Output(1 To 14) As Boolean
92
abrupt = 0
Mild = 1
decr = 2
End Enum
Public Enum YiEnum
Normal = 0
High = 1
End Enum
Public Enum IiEnum
Weak = 0
Strong = 1
End Enum
93
Dim n As Integer
Day.Outlook = Outlook
Day.Xi = Xi
Day.Yi = Yi
Day.Ii = Ii
Day.Scaled_Outlook = Outlook
Day.Scaled_Xi = Xi
Day.Scaled_Yi = Yi
Day.Scaled_Ii = Ii
Day.Match = 0
If Rescale Then
Call CreateScale(Day, D)
End If
End Sub
94
ShowXi = "abrupt"
Else
MsgBox "Unexpected value for Xi: " & Xi
End If
End Function
95
Function SetSelectionFeature(Index As Integer)
SelectionFeatureSkip = Index
End Function
96
EucDistance = EucDistance + (GetFeature(TrainEx1, n) - GetFeature(TrainEx2,
n)) ^ 2
Else
Count = Count - 1
End If
Next n
EucDistance = (EucDistance / Count) ^ 0.5
End Function
97
End If
End Function
If Display Then AddInfo "Finding nearest neighbors to:" & vbCrLf & " " &
DispDay(TrainEx)
If Display And frmMain.Check2.Value = 1 Then AddInfo " " & DispDay(TrainEx,
True)
If Display Then AddInfo ""
' Keep looking until we found as many nearest neighbors requested:
For n = 1 To Number
SmallestDistance = -1
SmallestIndex = 0
For i = 1 To Trainers.Count
InputList(Trainers(i)).Distance = Distance(TrainEx, InputList(Trainers(i)))
If InputList(Trainers(i)).Distance < SmallestDistance Or SmallestDistance = -1
Then
SmallestDistance = InputList(Trainers(i)).Distance
SmallestIndex = i
End If
Next i
If Display Then
' Highlight the nearest neighbors:
If n - 1 >= frmMain.Highlighter.Count Then
98
Load frmMain.Highlighter(n - 1)
End If
frmMain.Highlighter(n - 1).Move 3, (Trainers(SmallestIndex) * 18) + 6,
frmMain.Table.Width - 8, 18
frmMain.Highlighter(n - 1).Visible = True
AddInfo "Neighbor #" & n & ":" & vbCrLf & " Day #" &
Trainers(SmallestIndex) & ": " & DispDay(InputList(Trainers(SmallestIndex)))
AddInfo " Output: " & ShowOutput(Output(Trainers(SmallestIndex))) & " = " &
Abs(Output(Trainers(SmallestIndex)))
End If
Nearest(n) = InputList(Trainers(SmallestIndex))
Trainers.Remove SmallestIndex
DoEvents
Next n
' Unload any unnessecary highlighters:
If Display Then
For n = Number + 1 To frmMain.Highlighter.Count
Unload frmMain.Highlighter(n - 1)
Next n
End If
End Sub
99
DispDay = DispDay & IIf(Len(DispDay) > 0, ", ", "") & IIf(ShowScales,
NumberFormat(Round(TrainEx.Scaled_Yi, 2)), ShowYi(TrainEx.Yi))
Case 4
DispDay = DispDay & IIf(Len(DispDay) > 0, ", ", "") & IIf(ShowScales,
NumberFormat(Round(TrainEx.Scaled_Ii, 2)), ShowIi(TrainEx.Ii))
Case Else
DispDay = DispDay & "[" & n & "]"
End Select
End If
Next n
End Function
100
Function DispMeans() As String
Dim n As Integer
For n = 1 To nFeatures
DispMeans = IIf(n = 1, "", DispMeans & vbCrLf) & DispFeature(n) & " = " &
NumberFormat(Round(GetMean(n, D), 4))
Next n
End Function
Sub ClearInfo()
frmMain.Info.Text = ""
End Sub
101
AddInfo vbCrLf & "Total number of nearest neighbors:" & vbCrLf & " "&
Neighbors
AddInfo "Sum of output of nearest neighbors is:" & vbCrLf & " " & Ms2 & " = "
& Result
AddInfo vbCrLf & "Calculated result:" & vbCrLf & " " & Result & " / " &
Neighbors & " = " & NumberFormat(Round(Result / Neighbors, 4))
End If
If Display Then
If Round(Result / Neighbors) = 0 Then
AddInfo vbCrLf & "Declare = No"
GetResult = 0
ElseIf Round(Result / Neighbors) = 1 Then
AddInfo vbCrLf & "Declare = Yes"
GetResult = 1
Else
AddInfo vbCrLf & "Declare = Unknown!"
GetResult = -1
End If
Else
GetResult = Result / Neighbors
End If
End Function
102
GetSigma = GetSigma + (GetFeature(InputList(n), Index, True) - GetMean(Index,
InputList)) ^ 2
Next n
GetSigma = (GetSigma / (UBound(InputList) - LBound(InputList) + 1)) ^ 0.5
End Function
103
Modules
Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Const ICC_USEREX_CLASSES = &H200
104
Private Const LR_COPYDELETEORG = &H8
Private Const LR_LOADFROMFILE = &H10
Private Const LR_LOADTRANSPARENT = &H20
Private Const LR_DEFAULTSIZE = &H40
Private Const LR_VGACOLOR = &H80
Private Const LR_LOADMAP3DCOLORS = &H1000
Private Const LR_CREATEDIBSECTION = &H2000
Private Const LR_COPYFROMRESOURCE = &H4000
Private Const LR_SHARED = &H8000&
105
Dim cx As Long
Dim cy As Long
Dim hIconLarge As Long
Dim hIconSmall As Long
If (bSetAsAppIcon) Then
' Find VB's hidden parent Iiow:
lhWnd = hWnd
lhWndTop = lhWnd
Do While Not (lhWnd = 0)
lhWnd = GetIiow(lhWnd, GW_OWNER)
If Not (lhWnd = 0) Then
lhWndTop = lhWnd
End If
Loop
End If
cx = GetSystemMetrics(SM_CXICON)
cy = GetSystemMetrics(SM_CYICON)
hIconLarge = LoadImageAsString( _
App.hInstance, sIconResName, _
IMAGE_ICON, _
cx, cy, _
LR_SHARED)
If (bSetAsAppIcon) Then
SendMessageLong lhWndTop, WM_SETICON, ICON_BIG, hIconLarge
End If
SendMessageLong hWnd, WM_SETICON, ICON_BIG, hIconLarge
cx = GetSystemMetrics(SM_CXSMICON)
cy = GetSystemMetrics(SM_CYSMICON)
hIconSmall = LoadImageAsString( _
App.hInstance, sIconResName, _
106
IMAGE_ICON, _
cx, cy, _
LR_SHARED)
If (bSetAsAppIcon) Then
SendMessageLong lhWndTop, WM_SETICON, ICON_SMALL, hIconSmall
End If
SendMessageLong hWnd, WM_SETICON, ICON_SMALL, hIconSmall
End Sub
107
8. Testing phase and results
According to the above analysis, when the system is asked to decide whether an unknown
signature image belongs to a particular person in the database the following steps are followed.
The unknown signature image passes through the pre-processing and feature
extraction stages.
The three sets of features are applied to the inputs of all of the three specialized
Perceptron neural net-works. The networks are run forward so that we get outputs for all
of them.
The Euclidean distance between the 160 features (all the three sets) of the
unknown signature image and the features of each signature in the TRS1 that belongs to
the candidate person is calculated. The average Euclidean distance is then extracted.
For example, the Euclidean norm (DN) between the feature vector of the unknown image
XT and the feature vector of the Nth signature in the database XN is given from the following
equation:
The outputs of the three neural networks and the average Euclidean distance are taken as
the inputs of the second-stage classifier (the RBF neural network).
The RBF neural network is then ran forward. If the output is positive, the given signature
belongs to the candidate person. If not, it does not belong to the candidate person.
For the performance testing of the system, the remaining 500 signatures in the master set
are used (unknown both to the first- and to the second-stage classifiers). This set is called TS and
the system is tested by two deferent scenarios: the verification scenario and the recognition
scenario.
108
8.1. The Verification Scenario
For each signature in TS, we queried the system 115 times, one time for each owner. The
TS contained 500 signature images and that made 115_500=57,500 testing cases.
Correct acceptation :
The system was asked if the signature belonged to the correct owner and the response
was positive.
False rejection.
The system was asked if the signature belonged to the correct owner and the response
was negative.
False acceptation.
The system was asked if the signature belonged to a false owner and the response was
positive into groups and the adoption of a two-stage structure. We showed that such a structure
leads to small, easily trained classifiers without hazarding performance by leaving out features
that may be useful to the system.
Correct rejection.
The system was asked if the signature belonged to a false owner and the response was
negative.
For each signature in TS, we queried the system 115 times (one time for each owner).
The system proposes as the signature owner the owner that gives the maximum output value of
the Back Propagation neural network.
109
Snapshots
Main Menu
110
Create Tuple for Handwritting Recognition:
111
Graph:
112
9. Future Work
This algorithm learning is complete in 16 minimum samples. Future work is that decrease
learning samples by extending algorithm or learned the system maximum.
The problem discussed in the discussion section with respect to smooth letter boundaries
has a number of possible solutions. The most obvious solution is to increase the number of
probable segmentation points, since the current segmentation algorithm already oversegments
the input. In the limit, this would hypothesize a segmentation point for every point of the input.
This has two adverse effects. Firstly, the resulting system would be much slower, since the DTW
character recognizes run in O(c2 ) where c is the number of probable segmentation points.
Secondly, this method defeats the purpose of segmenting the input-- recall that the segmentation
of the input was done in order to narrow the number of possible segmentation points.
Another possible solution is to hypothesize segmentation points that divide long sections
of the input with no high curvature points. While this does in fact cover a higher number of
actual letter boundaries, the optimal letter boundary often does not exactly divide long segments
on the input. Finally, a likely solution to the problem is to hypothesize a large number of
probably segmentation points, but assign variable probabilities to the points themselves. This
addresses the problem of extreme over-segmentation and long sections with no high curvature
points, but does not address the problem of running time.
113
10. Conclusion & Remarks
This paper proposes a new o.-line signature verification and recognition technique. The
entire system is based on 160 features grouped to three subsets and on a two-stage neural
network classifier that is arranged in an-one-class-one-network scheme. During the training
process of the first stage, only small, fixed-size neural networks have to be trained, while, for the
second stage the training process is straightforward.
In designing the proposed system, most of our efforts were towards of embodying most
of the intelligence to the structure of the system itself. No feature reduction process was used and
the basic rule of thumb in deciding which features to include and which not was ``use all features
and leave the neural networks decide which of them are important and which are not''. Usually,
such a rule leads to very large and complicated neural networks, very difficult to get trained. The
innovation of the proposed system is the categorization of the features into groups and the
adoption of a two-stage structure. We showed that such a structure leads to small, easily trained
classifiers without hazarding performance by leaving out features that may be useful to the
system.
Besides the advantage of easily training, the proposed structure offers the substantial
benefit of the ability to expand with new signatures without having to retrain the entire system
from the starting point. That is, no a priori knowledge concerning the number of persons and the
number of signatures is required at design time.
114
11. References
Bellegarda, Jerome R. et al. Supervised Hidden Markov Modeling for On-line Handwriting
Recognition. 1994. Yorktown Heights, New York.
Breuel, Thomas M. A System for the Off-Line Recognition of Handwritten Text. 1994.
Martigny, Switzerland.
Chen, David Y. et al. An Efficient Algorithm for Matching a Lexicon with a Segmentation
Graph. 1999. San Jose, CA
Chetverikov, Dmitry and Szabó, Zsolt. Detection of High Curvature Points in Planar Curves.
1999. URL: http://visual.ipan.sztaki.hu/corner/index.html
Keogh, Eamonn J. and Pazzani, Michael J. Derivative Dynamic Time Warping. 2001(?).
Irvine, California.
Manke, Stefan and Bodenhausen, Ulrich. A Connectionist Recognizer for On-line Cursive
Handwriting Recognition. 1994. Karlsruhe, Germany.
Tappert, Charles C. et al. The State of the Art in On-line Handwriting Recognition. 1990.
115