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
3397e0bd
Commit
3397e0bd
authored
Mar 29, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix when opencv reshapes 1-channel image (fix #184)
parent
6cce6e01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
tensorpack/dataflow/imgaug/geometry.py
tensorpack/dataflow/imgaug/geometry.py
+6
-0
tensorpack/dataflow/imgaug/imgproc.py
tensorpack/dataflow/imgaug/imgproc.py
+4
-2
tensorpack/dataflow/imgaug/noname.py
tensorpack/dataflow/imgaug/noname.py
+6
-2
No files found.
tensorpack/dataflow/imgaug/geometry.py
View file @
3397e0bd
...
...
@@ -37,6 +37,8 @@ class Shift(ImageAugmentor):
def
_augment
(
self
,
img
,
shift_m
):
ret
=
cv2
.
warpAffine
(
img
,
shift_m
,
img
.
shape
[
1
::
-
1
],
borderMode
=
self
.
border
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
...
...
@@ -71,6 +73,8 @@ 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
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
...
...
@@ -99,6 +103,8 @@ class RotationAndCropValid(ImageAugmentor):
rot_m
=
cv2
.
getRotationMatrix2D
((
center
[
0
]
-
0.5
,
center
[
1
]
-
0.5
),
deg
,
1
)
ret
=
cv2
.
warpAffine
(
img
,
rot_m
,
img
.
shape
[
1
::
-
1
],
flags
=
self
.
interp
,
borderMode
=
cv2
.
BORDER_CONSTANT
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
neww
,
newh
=
RotationAndCropValid
.
largest_rotated_rect
(
ret
.
shape
[
1
],
ret
.
shape
[
0
],
deg
)
neww
=
min
(
neww
,
ret
.
shape
[
1
])
newh
=
min
(
newh
,
ret
.
shape
[
0
])
...
...
tensorpack/dataflow/imgaug/imgproc.py
View file @
3397e0bd
...
...
@@ -152,8 +152,10 @@ class Gamma(ImageAugmentor):
old_dtype
=
img
.
dtype
lut
=
((
np
.
arange
(
256
,
dtype
=
'float32'
)
/
255
)
**
(
1.
/
(
1.
+
gamma
))
*
255
)
.
astype
(
'uint8'
)
img
=
np
.
clip
(
img
,
0
,
255
)
.
astype
(
'uint8'
)
img
=
cv2
.
LUT
(
img
,
lut
)
.
astype
(
old_dtype
)
return
img
ret
=
cv2
.
LUT
(
img
,
lut
)
.
astype
(
old_dtype
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
return
ret
class
Clip
(
ImageAugmentor
):
...
...
tensorpack/dataflow/imgaug/noname.py
View file @
3397e0bd
...
...
@@ -39,8 +39,12 @@ class Flip(ImageAugmentor):
def
_augment
(
self
,
img
,
do
):
if
do
:
img
=
cv2
.
flip
(
img
,
self
.
code
)
return
img
ret
=
cv2
.
flip
(
img
,
self
.
code
)
if
img
.
ndim
==
3
and
ret
.
ndim
==
2
:
ret
=
ret
[:,
:,
np
.
newaxis
]
else
:
ret
=
img
return
ret
def
_fprop_coord
(
self
,
coord
,
param
):
raise
NotImplementedError
()
...
...
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