Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DeProj
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IAH public
DeProj
Commits
7ba91408
Commit
7ba91408
authored
4 years ago
by
Jean-Yves TINEVEZ
Browse files
Options
Downloads
Patches
Plain Diff
Change the input of functions.
Now we work more like a class with methods.
parent
49028dd1
No related branches found
No related tags found
1 merge request
!9
Rework the whole code for the upcoming publication.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
RunExample.m
+4
-4
4 additions, 4 deletions
RunExample.m
src/area3d.m
+14
-4
14 additions, 4 deletions
src/area3d.m
src/perimeter3d.m
+17
-8
17 additions, 8 deletions
src/perimeter3d.m
with
35 additions
and
16 deletions
RunExample.m
+
4
−
4
View file @
7ba91408
...
...
@@ -146,15 +146,15 @@ for i = 1 : n_objects
o
=
objects
(
i
);
area
=
area3d
(
o
.
boundary
);
perim
=
perimeter3d
(
o
.
boundary
);
[
area
,
uncorr_area
]
=
area3d
(
o
);
[
perim
,
uncorr_perim
]
=
perimeter3d
(
o
);
objects
(
i
)
.
area
=
area
;
objects
(
i
)
.
perimeter
=
perim
;
uncorr
=
struct
();
uncorr
.
area
=
polyarea
(
o
.
boundary
(:,
1
),
o
.
boundary
(:,
2
)
)
;
uncorr
.
perimeter
=
perimeter3d
(
o
.
boundary
(
:,
1
:
2
)
)
;
uncorr
.
area
=
uncorr_area
;
uncorr
.
perimeter
=
uncorr_perim
;
objects
(
i
)
.
uncorr
=
uncorr
;
end
...
...
This diff is collapsed.
Click to expand it.
src/area3d.m
+
14
−
4
View file @
7ba91408
function
area
=
area3d
(
p
)
%AREA3D Computes the area of a 3D closed polygon.
% p must be a Nx3 matrix.
function
[
area
,
uncorr_area
]
=
area3d
(
o
)
%AREA3D Computes the area of the object.
%% Deprojected 3D version.
p
=
o
.
boundary
;
n_vertices
=
size
(
p
,
1
);
...
...
@@ -25,7 +28,14 @@ function area = area3d( p )
% Total positive area.
area
=
sum
(
area_triangle
)
/
2
;
%% 2D area.
uncorr_area
=
polyarea
(
o
.
boundary
(:,
1
),
o
.
boundary
(:,
2
)
);
%% Subfunction.
function
n
=
euclidean_norm
(
v
)
n
=
sqrt
(
sum
(
v
.*
v
,
ndims
(
v
)
)
);
end
...
...
This diff is collapsed.
Click to expand it.
src/perimeter3d.m
+
17
−
8
View file @
7ba91408
function
perim
=
perimeter3d
(
p
)
function
[
perim
,
uncorr_perim
]
=
perimeter3d
(
o
)
%PERIMETER3D Perimeter of a closed N-dimensional polygon.
% p can be a N x d matrix, with d being the dimensionality.
p
2
=
[
p
;
p
(
1
,
:
)
]
;
p_diff
=
diff
(
p2
);
p
erim
=
compute_perim
(
o
.
boundary
)
;
uncorr_perim
=
compute_perim
(
o
.
boundary
(
:
,
1
:
2
)
);
p_diff_2
=
p_diff
.*
p_diff
;
p_diff_2_sum
=
sum
(
p_diff_2
,
2
);
sls
=
sqrt
(
p_diff_2_sum
);
perim
=
sum
(
sls
);
%% Subfunction
function
l_perim
=
compute_perim
(
p
)
% p can be a N x d matrix, with d being the dimensionality.
p2
=
[
p
;
p
(
1
,
:
)
];
p_diff
=
diff
(
p2
);
p_diff_2
=
p_diff
.*
p_diff
;
p_diff_2_sum
=
sum
(
p_diff_2
,
2
);
sls
=
sqrt
(
p_diff_2_sum
);
l_perim
=
sum
(
sls
);
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment