Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
licenseplates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
licenseplates
Commits
30145222
Commit
30145222
authored
13 years ago
by
unknown
Browse files
Options
Downloads
Patches
Plain Diff
NormalizedCharacterImage classe aangemaakt, extend GrayscaleImage, blurd,
cropped, resized
parent
a1848059
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/GrayscaleImage.py
+3
-3
3 additions, 3 deletions
src/GrayscaleImage.py
src/LetterCropper.py
+7
-8
7 additions, 8 deletions
src/LetterCropper.py
src/NormalizedCharacterImage.py
+5
-5
5 additions, 5 deletions
src/NormalizedCharacterImage.py
src/combined_test.py
+2
-7
2 additions, 7 deletions
src/combined_test.py
with
17 additions
and
23 deletions
src/GrayscaleImage.py
+
3
−
3
View file @
30145222
...
...
@@ -6,10 +6,10 @@ from scipy.misc import imresize, imsave
class
GrayscaleImage
:
def
__init__
(
self
,
image_path
=
None
,
data
=
None
):
if
image_path
:
if
image_path
!=
None
:
self
.
data
=
imread
(
image_path
)
self
.
convert_to_grayscale
()
elif
data
:
elif
data
!=
None
:
self
.
data
=
data
def
__iter__
(
self
):
...
...
@@ -40,7 +40,7 @@ class GrayscaleImage:
def
show
(
self
):
imshow
(
self
.
data
,
cmap
=
"
gray
"
)
#
show()
show
()
def
make_histogram
(
self
):
return
hist
(
self
.
data
)
...
...
This diff is collapsed.
Click to expand it.
src/LetterCropper.py
+
7
−
8
View file @
30145222
from
copy
import
deepcopy
from
Rectangle
import
Rectangle
from
GrayscaleImage
import
GrayscaleImage
class
LetterCropper
:
def
__init__
(
self
,
threshold
=
0.9
):
self
.
source_image
=
image
self
.
threshold
=
threshold
def
get_cropped_letter
(
self
):
def
crop_to_letter
(
self
,
image
):
self
.
image
=
image
self
.
determine_letter_bounds
()
self
.
result_image
=
deepcopy
(
self
.
source_image
)
self
.
result_image
.
crop
(
self
.
letter_bounds
)
return
self
.
result_image
self
.
image
.
crop
(
self
.
letter_bounds
)
def
determine_letter_bounds
(
self
):
min_x
=
self
.
source_
image
.
width
min_x
=
self
.
image
.
width
max_x
=
0
min_y
=
self
.
source_
image
.
height
min_y
=
self
.
image
.
height
max_y
=
0
for
y
,
x
,
value
in
self
.
source_
image
:
for
y
,
x
,
value
in
self
.
image
:
if
value
<
self
.
threshold
:
if
x
<
min_x
:
min_x
=
x
if
y
<
min_y
:
min_y
=
y
...
...
This diff is collapsed.
Click to expand it.
src/NormalizedCharacterImage.py
+
5
−
5
View file @
30145222
...
...
@@ -12,7 +12,7 @@ class NormalizedCharacterImage(GrayscaleImage):
self
.
size
=
size
self
.
gausse_filter
()
self
.
increase_contrast
()
self
.
crop
()
self
.
crop
_to_letter
()
self
.
resize
()
def
increase_contrast
(
self
):
...
...
@@ -23,9 +23,9 @@ class NormalizedCharacterImage(GrayscaleImage):
filter
=
GaussianFilter
(
1.1
)
filter
.
filter
(
self
)
def
crop
(
self
):
cropper
=
LetterCropper
(
self
,
0.9
)
self
.
data
=
cropper
.
get_
crop
ped
_letter
(
).
data
def
crop
_to_letter
(
self
):
cropper
=
LetterCropper
(
0.9
)
cropper
.
crop
_to
_letter
(
self
)
def
resize
(
self
):
self
.
resize
(
self
.
size
)
GrayscaleImage
.
resize
(
self
,
self
.
size
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/combined_test.py
+
2
−
7
View file @
30145222
from
GrayscaleImage
import
GrayscaleImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
# 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
from
LetterCropper
import
LetterCropper
image
=
GrayscaleImage
(
"
../images/test10.png
"
)
normalized_character_image
=
NormalizedCharacterImage
(
image
)
normalized_character_image
.
show
()
normalized_character_image
.
show
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment