Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Subsampling
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josef Brandt
Subsampling
Commits
f83f5d56
Commit
f83f5d56
authored
Mar 30, 2020
by
Josef Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix in Cython...
parent
4250c8d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
cythonModules/rotateContour.pyx
cythonModules/rotateContour.pyx
+8
-10
gui/filterView.py
gui/filterView.py
+2
-3
tests/test_cython.py
tests/test_cython.py
+3
-3
No files found.
cythonModules/rotateContour.pyx
View file @
f83f5d56
...
...
@@ -3,13 +3,11 @@ cimport numpy as np
cimport
cython
DTYPE
=
np
.
float
ctypedef
np
.
float_t
DTYPE_t
ctypedef
np
.
int32_t
INT32_t
def
rotate_contour_around_point
(
np
.
ndarray
[
DTYPE_t
,
ndim
=
3
]
contour
,
np
.
ndarray
[
DTYPE_t
,
ndim
=
1
]
refPoint
,
np
.
float
angleDegree
):
# def rotate_contour_around_point(contour: np.ndarray, refPoint: tuple, angleDegree: float) -> np.ndarray:
def
rotate_contour_around_point
(
np
.
ndarray
[
INT32_t
,
ndim
=
3
]
contour
,
np
.
ndarray
[
INT32_t
,
ndim
=
1
]
refPoint
,
np
.
float
angleDegree
):
"""
Rotates a point around another one...
Rotates a point around another one...
All coordinates in pixel space (integers)
:param contour: Array of points to be rotated, [:, 0, 0] = x, [:, 0, 1] = y
:param refPoint: The referemce point around which the first point is rotated, tuple of x and y
:param angleDegree: The angle in degree to rotate (counter-clockwise)
...
...
@@ -17,16 +15,16 @@ def rotate_contour_around_point(np.ndarray[DTYPE_t, ndim=3] contour, np.ndarray[
"""
cdef
int
i
cdef
double
theta
,
sin
,
cos
,
x
,
y
cdef
np
.
ndarray
[
DTYPE
_t
,
ndim
=
3
]
newContour
cdef
np
.
ndarray
[
INT32
_t
,
ndim
=
3
]
newContour
theta
=
np
.
deg2rad
(
angleDegree
)
sin
=
np
.
sin
(
theta
)
cos
=
np
.
cos
(
theta
)
newContour
=
np
.
zeros_like
(
contour
,
dtype
=
np
.
float
)
newContour
=
np
.
zeros_like
(
contour
)
for
i
in
range
(
contour
.
shape
[
0
]):
x
:
float
=
cos
*
(
contour
[
i
,
0
,
0
]
-
refPoint
[
0
])
-
sin
*
(
contour
[
i
,
0
,
1
]
-
refPoint
[
1
])
+
refPoint
[
0
]
y
:
float
=
sin
*
(
contour
[
i
,
0
,
0
]
-
refPoint
[
0
])
+
cos
*
(
contour
[
i
,
0
,
1
]
-
refPoint
[
1
])
+
refPoint
[
1
]
newContour
[
i
,
0
,
0
]
=
x
newContour
[
i
,
0
,
1
]
=
y
x
=
cos
*
(
contour
[
i
,
0
,
0
]
-
refPoint
[
0
])
-
sin
*
(
contour
[
i
,
0
,
1
]
-
refPoint
[
1
])
+
refPoint
[
0
]
y
=
sin
*
(
contour
[
i
,
0
,
0
]
-
refPoint
[
0
])
+
cos
*
(
contour
[
i
,
0
,
1
]
-
refPoint
[
1
])
+
refPoint
[
1
]
newContour
[
i
,
0
,
0
]
=
round
(
x
)
newContour
[
i
,
0
,
1
]
=
round
(
y
)
return
newContour
gui/filterView.py
View file @
f83f5d56
...
...
@@ -54,11 +54,10 @@ class FilterView(QtWidgets.QGraphicsView):
if
newRotation
!=
self
.
rotation
:
angle
:
float
=
np
.
float
(
newRotation
-
self
.
rotation
)
center
:
np
.
ndarray
=
np
.
array
([
self
.
filter
.
circleOffset
[
0
]
+
self
.
filter
.
diameter
/
2
,
self
.
filter
.
circleOffset
[
1
]
+
self
.
filter
.
diameter
/
2
],
dtype
=
np
.
float
)
self
.
filter
.
circleOffset
[
1
]
+
self
.
filter
.
diameter
/
2
],
dtype
=
np
.
int32
)
for
particle
in
self
.
dataset
.
particleContainer
.
particles
:
contour
:
np
.
ndarray
=
particle
.
contour
.
astype
(
np
.
float
)
particle
.
contour
=
rc
.
rotate_contour_around_point
(
contour
,
center
,
angle
)
particle
.
contour
=
rc
.
rotate_contour_around_point
(
particle
.
contour
,
center
,
angle
)
self
.
_update_particle_contours
()
self
.
rotation
=
newRotation
...
...
tests/test_cython.py
View file @
f83f5d56
...
...
@@ -7,8 +7,8 @@ class CythonTester(unittest.TestCase):
def
test_rotate_contour
(
self
):
contour
:
np
.
ndarray
=
np
.
array
([[[
0
,
5
]],
[[
5
,
5
]],
[[
5
,
0
]]],
dtype
=
np
.
float
)
refPoint
:
np
.
ndarray
=
np
.
array
([
0
,
0
],
dtype
=
np
.
float
)
[[
5
,
0
]]],
dtype
=
np
.
int32
)
refPoint
:
np
.
ndarray
=
np
.
array
([
0
,
0
],
dtype
=
np
.
int32
)
angle
:
float
=
90.0
newContour
:
np
.
ndarray
=
rc
.
rotate_contour_around_point
(
contour
,
refPoint
,
angle
)
...
...
@@ -37,7 +37,7 @@ class CythonTester(unittest.TestCase):
self
.
assertAlmostEqual
(
newContour
[
2
,
0
,
0
],
0
)
self
.
assertAlmostEqual
(
newContour
[
2
,
0
,
1
],
-
5
)
refPoint
=
np
.
array
([
5
,
5
],
dtype
=
np
.
float
)
refPoint
=
np
.
array
([
5
,
5
],
dtype
=
np
.
int32
)
angle
:
float
=
90.0
newContour
=
rc
.
rotate_contour_around_point
(
contour
,
refPoint
,
angle
)
...
...
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