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
2c1bcb75
Commit
2c1bcb75
authored
13 years ago
by
unknown
Browse files
Options
Downloads
Patches
Plain Diff
Made letterCropper non destructive on source image, created a new test
which combines all the tests
parent
be937661
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/LetterCropper.py
+15
-22
15 additions, 22 deletions
src/LetterCropper.py
src/LocalBinaryPatternizerTest.py
+2
-1
2 additions, 1 deletion
src/LocalBinaryPatternizerTest.py
src/combined_test.py
+22
-0
22 additions, 0 deletions
src/combined_test.py
with
39 additions
and
23 deletions
src/LetterCropper.py
+
15
−
22
View file @
2c1bcb75
from
copy
import
deepcopy
from
Rectangle
import
Rectangle
class
LetterCropper
:
def
__init__
(
self
,
image
,
threshold
=
0.9
):
self
.
set_image
(
image
)
self
.
set_threshold
(
threshold
)
def
set_image
(
self
,
image
):
self
.
image
=
image
def
set_threshold
(
self
,
threshold
):
self
.
source_image
=
image
self
.
threshold
=
threshold
def
get_cropped_letter
(
self
):
self
.
determine_letter_bounds
()
self
.
image
.
crop
(
self
.
letter_bounds
)
return
self
.
image
self
.
result_image
=
deepcopy
(
self
.
source_image
)
self
.
result_image
.
crop
(
self
.
letter_bounds
)
return
self
.
result_image
def
determine_letter_bounds
(
self
):
min_x
=
self
.
image
.
width
min_x
=
self
.
source_image
.
width
max_x
=
0
min_y
=
self
.
image
.
height
min_y
=
self
.
source_
image
.
height
max_y
=
0
for
y
in
xrange
(
self
.
image
.
height
):
for
x
in
xrange
(
self
.
image
.
width
):
if
self
.
image
[
y
,
x
]
<
self
.
threshold
:
if
x
<
min_x
:
min_x
=
x
if
y
<
min_y
:
min_y
=
y
if
x
>
max_x
:
max_x
=
x
if
y
>
max_y
:
max_y
=
y
for
y
,
x
,
value
in
self
.
source_image
:
if
value
<
self
.
threshold
:
if
x
<
min_x
:
min_x
=
x
if
y
<
min_y
:
min_y
=
y
if
x
>
max_x
:
max_x
=
x
if
y
>
max_y
:
max_y
=
y
self
.
letter_bounds
=
Rectangle
(
min_x
,
min_y
,
max_x
-
min_x
,
max_y
-
min_y
)
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/LocalBinaryPatternizerTest.py
+
2
−
1
View file @
2c1bcb75
from
GrayscaleImage
import
GrayscaleImage
from
LocalBinaryPatternizer
import
LocalBinaryPatternizer
from
LetterCropper
import
LetterCropper
from
matplotlib.pyplot
import
imshow
,
subplot
,
show
,
axis
image
=
GrayscaleImage
(
"
../images/test.png
"
)
lbp
=
LocalBinaryPatternizer
(
image
)
lbp
=
LocalBinaryPatternizer
(
image
)
feature_vector
=
lbp
.
create_features_vector
()
feature_vector
/=
255
# Prepare for displaying -> 0 - 255 -> 0 - 1
...
...
This diff is collapsed.
Click to expand it.
src/combined_test.py
0 → 100644
+
22
−
0
View file @
2c1bcb75
from
GrayscaleImage
import
GrayscaleImage
from
LocalBinaryPatternizer
import
LocalBinaryPatternizer
from
LetterCropper
import
LetterCropper
from
matplotlib.pyplot
import
imshow
,
subplot
,
show
,
axis
image
=
GrayscaleImage
(
"
../images/test.png
"
)
cropper
=
LetterCropper
(
image
)
cropped_letter
=
cropper
.
get_cropped_letter
()
lbp
=
LocalBinaryPatternizer
(
cropped_letter
)
feature_vector
=
lbp
.
create_features_vector
()
feature_vector
/=
255
# Prepare for displaying -> 0 - 255 -> 0 - 1
subplot
(
121
)
imshow
(
image
.
data
,
cmap
=
'
gray
'
)
subplot
(
122
)
imshow
(
feature_vector
,
cmap
=
'
gray
'
)
axis
(
'
off
'
)
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