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
e220b436
Commit
e220b436
authored
Oct 11, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coordinate mapping for affine transform
parent
b17c8e73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
tensorpack/dataflow/imgaug/geometry.py
tensorpack/dataflow/imgaug/geometry.py
+1
-1
tensorpack/dataflow/imgaug/transform.py
tensorpack/dataflow/imgaug/transform.py
+38
-2
No files found.
tensorpack/dataflow/imgaug/geometry.py
View file @
e220b436
...
...
@@ -69,7 +69,7 @@ class Rotation(TransformAugmentorBase):
if
self
.
step_deg
:
deg
=
deg
//
self
.
step_deg
*
self
.
step_deg
"""
The correct center is shape*0.5-0.5 This can be verified by:
The correct center is shape*0.5-0.5
.
This can be verified by:
SHAPE = 7
arr = np.random.rand(SHAPE, SHAPE)
...
...
tensorpack/dataflow/imgaug/transform.py
View file @
e220b436
...
...
@@ -102,5 +102,41 @@ class WarpAffineTransform(ImageTransform):
return
ret
def
apply_coords
(
self
,
coords
):
# TODO
raise
NotImplementedError
()
coords
=
np
.
concatenate
((
coords
,
np
.
ones
((
coords
.
shape
[
0
],
1
),
dtype
=
'f4'
)),
axis
=
1
)
coords
=
np
.
dot
(
coords
,
self
.
mat
.
T
)
return
coords
if
__name__
==
'__main__'
:
shape
=
(
100
,
100
)
center
=
(
10
,
70
)
mat
=
cv2
.
getRotationMatrix2D
(
center
,
20
,
1
)
trans
=
WarpAffineTransform
(
mat
,
(
130
,
130
))
def
draw_points
(
img
,
pts
):
for
p
in
pts
:
try
:
img
[
int
(
p
[
1
]),
int
(
p
[
0
])]
=
0
except
IndexError
:
pass
image
=
cv2
.
imread
(
'cat.jpg'
)
image
=
cv2
.
resize
(
image
,
shape
)
orig_image
=
image
.
copy
()
coords
=
np
.
random
.
randint
(
100
,
size
=
(
20
,
2
))
draw_points
(
orig_image
,
coords
)
print
(
coords
)
for
k
in
range
(
1
):
coords
=
trans
.
apply_coords
(
coords
)
image
=
trans
.
apply_image
(
image
)
print
(
coords
)
draw_points
(
image
,
coords
)
#viz = cv2.resize(viz, (1200, 600))
orig_image
=
cv2
.
resize
(
orig_image
,
(
600
,
600
))
image
=
cv2
.
resize
(
image
,
(
600
,
600
))
viz
=
np
.
concatenate
((
orig_image
,
image
),
axis
=
1
)
cv2
.
imshow
(
"mat"
,
viz
)
cv2
.
waitKey
()
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