Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Show more breadcrumbs
Works on my machine
zesje
Commits
386a2286
Commit
386a2286
authored
5 years ago
by
Ruben Young On
Browse files
Options
Downloads
Patches
Plain Diff
Changed threshold and added more comments
parent
75244e07
No related branches found
No related tags found
1 merge request
!5
Add multiple choice checkbox location to database
Pipeline
#17334
passed
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zesje/images.py
+7
-4
7 additions, 4 deletions
zesje/images.py
with
7 additions
and
4 deletions
zesje/images.py
+
7
−
4
View file @
386a2286
...
...
@@ -36,7 +36,7 @@ def get_box(image_array, box, padding=0.3):
return
image_array
[
top
:
bottom
,
left
:
right
]
def
box_is_filled
(
image_array
,
box_coords
,
padding
=
0.3
,
threshold
=
50
,
pixels
=
False
):
def
box_is_filled
(
image_array
,
box_coords
,
padding
=
0.3
,
threshold
=
1
50
,
pixels
=
False
):
"""
Determines if a box is filled
...
...
@@ -45,14 +45,16 @@ def box_is_filled(image_array, box_coords, padding=0.3, threshold=50, pixels=Fal
image_array : 2D or 3D array
The image source.
box_coords : 4 floats (top, bottom, left, right)
Coordinates of the bounding box in inches. By due to differing
Coordinates of the bounding box in inches
or pixels
. By due to differing
traditions, box coordinates are counted from the bottom left of the
image, while image array coordinates are from the top left.
padding : float
Padding around box borders in inches.
threshold : int
Optional threshold value to determine minimal
'
darkness
'
needed to consider a box to be filled in
to consider a box to be filled in
pixels : boolean
Whether the box coordinates are entered as pixels instead of inches.
"""
# Divide by DPI if pixel coordinates are used
...
...
@@ -61,8 +63,9 @@ def box_is_filled(image_array, box_coords, padding=0.3, threshold=50, pixels=Fal
box_img
=
get_box
(
image_array
,
box_coords
,
padding
)
# Check if the coordinates are outside of the image
if
box_img
.
size
==
0
:
raise
RuntimeError
(
"
C
oordinates are outside of image
"
)
raise
RuntimeError
(
"
Box c
oordinates are outside of image
"
)
avg
=
np
.
average
(
box_img
)
...
...
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