Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
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
Shashank Suhas
seminar-breakout
Commits
bc551406
You need to sign in or sign up before continuing.
Commit
bc551406
authored
Jun 20, 2017
by
eyaler
Committed by
Yuxin Wu
Jun 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow non-default borderValue (#307)
parent
5a163e7c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
tensorpack/dataflow/imgaug/geometry.py
tensorpack/dataflow/imgaug/geometry.py
+6
-4
No files found.
tensorpack/dataflow/imgaug/geometry.py
View file @
bc551406
...
...
@@ -15,12 +15,13 @@ class Shift(ImageAugmentor):
""" Random horizontal and vertical shifts """
def
__init__
(
self
,
horiz_frac
=
0
,
vert_frac
=
0
,
border
=
cv2
.
BORDER_REPLICATE
):
border
=
cv2
.
BORDER_REPLICATE
,
border_value
=
0
):
"""
Args:
horiz_frac (float): max abs fraction for horizontal shift
vert_frac (float): max abs fraction for horizontal shift
border: cv2 border method
border_value: cv2 border value for border=cv2.BORDER_CONSTANT
"""
assert
horiz_frac
<
1.0
and
vert_frac
<
1.0
super
(
Shift
,
self
)
.
__init__
()
...
...
@@ -36,7 +37,7 @@ class Shift(ImageAugmentor):
def
_augment
(
self
,
img
,
shift_m
):
ret
=
cv2
.
warpAffine
(
img
,
shift_m
,
img
.
shape
[
1
::
-
1
],
borderMode
=
self
.
border
)
borderMode
=
self
.
border
,
borderValue
=
self
.
border_value
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
...
...
@@ -47,7 +48,7 @@ class Rotation(ImageAugmentor):
def
__init__
(
self
,
max_deg
,
center_range
=
(
0
,
1
),
interp
=
cv2
.
INTER_LINEAR
,
border
=
cv2
.
BORDER_REPLICATE
,
step_deg
=
None
):
border
=
cv2
.
BORDER_REPLICATE
,
step_deg
=
None
,
border_value
=
0
):
"""
Args:
max_deg (float): max abs value of the rotation angle (in degree).
...
...
@@ -57,6 +58,7 @@ class Rotation(ImageAugmentor):
step_deg (float): if not None, the stepping of the rotation
angle. The rotation angle will be a multiple of step_deg. This
option requires ``max_deg==180`` and step_deg has to be a divisor of 180)
border_value: cv2 border value for border=cv2.BORDER_CONSTANT
"""
assert
step_deg
is
None
or
(
max_deg
==
180
and
max_deg
%
step_deg
==
0
)
super
(
Rotation
,
self
)
.
__init__
()
...
...
@@ -72,7 +74,7 @@ class Rotation(ImageAugmentor):
def
_augment
(
self
,
img
,
rot_m
):
ret
=
cv2
.
warpAffine
(
img
,
rot_m
,
img
.
shape
[
1
::
-
1
],
flags
=
self
.
interp
,
borderMode
=
self
.
border
)
flags
=
self
.
interp
,
borderMode
=
self
.
border
,
borderValue
=
self
.
border_value
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
...
...
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