Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jigyasa Watwani
/
growth-pattern-control
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
92895a3d
authored
Jan 09, 2024
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added code to find area enclosed by the contour
parent
d9e3725c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
convergence_extension/perimeter_long_axis.py
convergence_extension/perimeter_long_axis.py
View file @
92895a3d
...
...
@@ -4,15 +4,15 @@ import pandas as pd
from
matplotlib.widgets
import
Slider
from
scipy.spatial
import
ConvexHull
def
perimeter
(
X
,
Y
):
def
perimeter
_area
(
X
,
Y
):
points
=
np
.
column_stack
((
X
,
Y
))
hull
=
ConvexHull
(
points
)
N
=
len
(
hull
.
vertices
)
value
=
0
perimeter_
value
=
0
for
i
in
range
(
N
):
value
+=
np
.
linalg
.
norm
(
points
[
hull
.
vertices
[
i
]]
-
points
[
hull
.
vertices
[(
i
+
1
)
%
N
]])
perimeter_
value
+=
np
.
linalg
.
norm
(
points
[
hull
.
vertices
[
i
]]
-
points
[
hull
.
vertices
[(
i
+
1
)
%
N
]])
# The (i+1)%N part ensures that after the last vertex, we go back to the first vertex, creating a closed loop
return
value
return
(
perimeter_value
,
hull
.
volume
)
def
long_axis
(
x
,
y
):
x_diff
=
x
[:,
None
]
-
x
...
...
@@ -21,16 +21,16 @@ def long_axis(x, y):
return
np
.
max
(
distances
)
# NOTE: check perimeter and long_axis functions on known shapes
# x = np.array([1, 0, -1, 0])
# y = np.array([0, 2, 0, -2])
# print(long_axis(x, y))
# x = np.array([1, -1, -1, 1])
# y = np.array([1, 1, -1, -1])
# points = np.column_stack((x, y))
# hull = ConvexHull(points)
# print(perimeter_area(x, y))
# print(long_axis(x, y))
# raise SystemExit
file
=
np
.
loadtxt
(
'xy_coordinates_movie1
5
.txt'
)
file
=
np
.
loadtxt
(
'xy_coordinates_movie1.txt'
)
number_of_pixels
=
file
.
shape
[
0
]
time_points
=
file
.
shape
[
1
]
time_array
=
np
.
arange
(
0
,
5
*
int
(
time_points
/
2
),
5
)
...
...
@@ -84,14 +84,19 @@ plt.xlabel('Time')
plt
.
ylabel
(
'Length of the long axis'
)
plt
.
show
()
# find the perimeter
# find the perimeter
and area
perimeter_array
=
np
.
zeros
(
int
(
time_points
/
2
))
area_array
=
np
.
zeros
(
int
(
time_points
/
2
))
for
k
in
range
(
0
,
int
(
time_points
/
2
)):
perimeter_array
[
k
]
=
perimeter
(
x
[
k
],
y
[
k
])
perimeter_array
[
k
]
,
area_array
[
k
]
=
perimeter_area
(
x
[
k
],
y
[
k
])
plt
.
plot
(
time_array
,
perimeter_array
,
marker
=
'o'
,
linestyle
=
'None'
)
plt
.
xlabel
(
'Time'
)
plt
.
ylabel
(
'Perimeter'
)
plt
.
xlabel
(
'Time
(min)
'
)
plt
.
ylabel
(
'Perimeter
($
\
mu m$)
'
)
plt
.
show
()
plt
.
plot
(
time_array
,
area_array
,
marker
=
'o'
,
linestyle
=
'None'
)
plt
.
xlabel
(
'Time (min)'
)
plt
.
ylabel
(
'Area ($
\
mu m^2$)'
)
plt
.
show
()
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