Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
licenseplates
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
licenseplates
Commits
30145222
Commit
30145222
authored
Dec 02, 2011
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NormalizedCharacterImage classe aangemaakt, extend GrayscaleImage, blurd,
cropped, resized
parent
a1848059
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
23 deletions
+17
-23
src/GrayscaleImage.py
src/GrayscaleImage.py
+3
-3
src/LetterCropper.py
src/LetterCropper.py
+7
-8
src/NormalizedCharacterImage.py
src/NormalizedCharacterImage.py
+5
-5
src/combined_test.py
src/combined_test.py
+2
-7
No files found.
src/GrayscaleImage.py
View file @
30145222
...
@@ -6,10 +6,10 @@ from scipy.misc import imresize, imsave
...
@@ -6,10 +6,10 @@ from scipy.misc import imresize, imsave
class
GrayscaleImage
:
class
GrayscaleImage
:
def
__init__
(
self
,
image_path
=
None
,
data
=
None
):
def
__init__
(
self
,
image_path
=
None
,
data
=
None
):
if
image_path
:
if
image_path
!=
None
:
self
.
data
=
imread
(
image_path
)
self
.
data
=
imread
(
image_path
)
self
.
convert_to_grayscale
()
self
.
convert_to_grayscale
()
elif
data
:
elif
data
!=
None
:
self
.
data
=
data
self
.
data
=
data
def
__iter__
(
self
):
def
__iter__
(
self
):
...
@@ -40,7 +40,7 @@ class GrayscaleImage:
...
@@ -40,7 +40,7 @@ class GrayscaleImage:
def
show
(
self
):
def
show
(
self
):
imshow
(
self
.
data
,
cmap
=
"gray"
)
imshow
(
self
.
data
,
cmap
=
"gray"
)
#
show()
show
()
def
make_histogram
(
self
):
def
make_histogram
(
self
):
return
hist
(
self
.
data
)
return
hist
(
self
.
data
)
...
...
src/LetterCropper.py
View file @
30145222
from
copy
import
deepcopy
from
copy
import
deepcopy
from
Rectangle
import
Rectangle
from
Rectangle
import
Rectangle
from
GrayscaleImage
import
GrayscaleImage
class
LetterCropper
:
class
LetterCropper
:
def
__init__
(
self
,
threshold
=
0.9
):
def
__init__
(
self
,
threshold
=
0.9
):
self
.
source_image
=
image
self
.
threshold
=
threshold
self
.
threshold
=
threshold
def
get_cropped_letter
(
self
):
def
crop_to_letter
(
self
,
image
):
self
.
image
=
image
self
.
determine_letter_bounds
()
self
.
determine_letter_bounds
()
self
.
result_image
=
deepcopy
(
self
.
source_image
)
self
.
image
.
crop
(
self
.
letter_bounds
)
self
.
result_image
.
crop
(
self
.
letter_bounds
)
return
self
.
result_image
def
determine_letter_bounds
(
self
):
def
determine_letter_bounds
(
self
):
min_x
=
self
.
source_
image
.
width
min_x
=
self
.
image
.
width
max_x
=
0
max_x
=
0
min_y
=
self
.
source_
image
.
height
min_y
=
self
.
image
.
height
max_y
=
0
max_y
=
0
for
y
,
x
,
value
in
self
.
source_
image
:
for
y
,
x
,
value
in
self
.
image
:
if
value
<
self
.
threshold
:
if
value
<
self
.
threshold
:
if
x
<
min_x
:
min_x
=
x
if
x
<
min_x
:
min_x
=
x
if
y
<
min_y
:
min_y
=
y
if
y
<
min_y
:
min_y
=
y
...
...
src/NormalizedCharacterImage.py
View file @
30145222
...
@@ -12,7 +12,7 @@ class NormalizedCharacterImage(GrayscaleImage):
...
@@ -12,7 +12,7 @@ class NormalizedCharacterImage(GrayscaleImage):
self
.
size
=
size
self
.
size
=
size
self
.
gausse_filter
()
self
.
gausse_filter
()
self
.
increase_contrast
()
self
.
increase_contrast
()
self
.
crop
()
self
.
crop
_to_letter
()
self
.
resize
()
self
.
resize
()
def
increase_contrast
(
self
):
def
increase_contrast
(
self
):
...
@@ -23,9 +23,9 @@ class NormalizedCharacterImage(GrayscaleImage):
...
@@ -23,9 +23,9 @@ class NormalizedCharacterImage(GrayscaleImage):
filter
=
GaussianFilter
(
1.1
)
filter
=
GaussianFilter
(
1.1
)
filter
.
filter
(
self
)
filter
.
filter
(
self
)
def
crop
(
self
):
def
crop
_to_letter
(
self
):
cropper
=
LetterCropper
(
self
,
0.9
)
cropper
=
LetterCropper
(
0.9
)
self
.
data
=
cropper
.
get_cropped_letter
().
data
cropper
.
crop_to_letter
(
self
)
def
resize
(
self
):
def
resize
(
self
):
self
.
resize
(
self
.
size
)
GrayscaleImage
.
resize
(
self
,
self
.
size
)
\ No newline at end of file
src/combined_test.py
View file @
30145222
from
GrayscaleImage
import
GrayscaleImage
from
GrayscaleImage
import
GrayscaleImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
from
LetterCropper
import
LetterCropper
# Comment added by Richard Torenvliet
# Steps in this test files are
# 1. crop image
# 2. resize to default hight (in future also to width)
# 3. plot
image
=
GrayscaleImage
(
"../images/test10.png"
)
image
=
GrayscaleImage
(
"../images/test10.png"
)
normalized_character_image
=
NormalizedCharacterImage
(
image
)
normalized_character_image
=
NormalizedCharacterImage
(
image
)
normalized_character_image
.
show
()
normalized_character_image
.
show
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment