-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage processing.R
More file actions
33 lines (31 loc) · 1.79 KB
/
Copy pathImage processing.R
File metadata and controls
33 lines (31 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#Image processing using Support Vector Machines technique
"When OCR software first processes a document, it divides the paper into a
matrix such that each cell in the grid contains a single glyph, which is just a term
referring to a letter, symbol, or number. Next, for each cell, the software will attempt
to match the glyph to a set of all characters it recognizes. Finally, the individual
characters would be combined back together into words, which optionally could be
spell-checked against a dictionary in the document's language.
In this exercise, we'll assume that we have already developed the algorithm to
partition the document into rectangular regions each consisting of a single character.
We will also assume the document contains only alphabetic characters in English.
Therefore, we'll simulate a process that involves matching glyphs to one of the 26
letters, A through Z.The attributes measure such characteristics as the horizontal and vertical
dimensions of the glyph, the proportion of black (versus white) pixels, and the
average horizontal and vertical position of the pixels. Presumably, differences in the
concentration of black pixels across various areas of the box should provide a way to
differentiate among the 26 letters of the alphabet"
letters<-read.csv(file.choose(),header = T)
str(letters)
View(letters)
letters_train <- letters[1:16000, ]
letters_test <- letters[16001:20000, ]
install.packages("kernlab")
library(kernlab)
letter_classifier <- ksvm(class ~ ., data = letters_train,
kernel = "rbfdot")
letter_predictions <- predict(letter_classifier, letters_test)
head(letter_predictions)
table(letter_predictions, letters_test$class)
agreement <- letter_predictions == letters_test$class
table(agreement)
prop.table(table(agreement))