Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IAH public
DeProj
Commits
6fa45813
Commit
6fa45813
authored
Jul 24, 2020
by
Jean-Yves TINEVEZ
Browse files
Better version of find_contour.
One call to pdist per run. Speed-up ~ x8.
parent
156a1743
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/@deproj/find_countour.m
View file @
6fa45813
...
...
@@ -4,9 +4,12 @@ function P2 = find_countour( P )
P2
=
NaN
(
size
(
P
)
);
current
=
1
;
D
=
squareform
(
pdist
(
P
)
);
D
(
D
==
0
)
=
Inf
;
% Start point
ps
=
P
(
1
,
:
);
set_visited
(
1
)
id
=
1
;
ps
=
P
(
id
,
:
);
P2
(
current
,
:
)
=
ps
;
current
=
current
+
1
;
...
...
@@ -16,9 +19,10 @@ function P2 = find_countour( P )
done
=
current
==
size
(
P
,
1
);
id
=
find_next_point
(
ps
);
prev_id
=
id
;
id
=
find_next_point
(
id
);
ps
=
P
(
id
,
:
);
set_visited
(
id
)
set_visited
(
prev_
id
)
P2
(
current
,
:
)
=
ps
;
current
=
current
+
1
;
...
...
@@ -26,11 +30,12 @@ function P2 = find_countour( P )
function
set_visited
(
id
)
P
(
id
,
:
)
=
NaN
;
D
(
id
,
:
)
=
Inf
;
D
(
:,
id
)
=
Inf
;
end
function
id
=
find_next_point
(
p0
)
[
~
,
id
]
=
pdist2
(
P
,
p0
,
'Euclidean'
,
'Smallest'
,
1
);
function
id
=
find_next_point
(
id
)
[
~
,
id
]
=
min
(
D
(
:,
id
)
);
end
end
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment