Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
py-3d-face-reconstruction
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
py-3d-face-reconstruction
Commits
a54d0723
Commit
a54d0723
authored
Apr 06, 2016
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform pca
parent
c6bdbd9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
src/main.py
src/main.py
+2
-1
src/pca.py
src/pca.py
+24
-2
No files found.
src/main.py
View file @
a54d0723
...
...
@@ -62,8 +62,9 @@ if __name__ == '__main__':
imm_points
.
append
(
imm
.
get_points
())
# imm.show()
imm_points
=
np
.
array
(
imm_points
)
mean_values
=
build_mean_aam
(
np
.
array
(
imm_points
))
pca
(
imm_points
,
mean_values
)
V
,
S
=
pca
(
imm_points
,
mean_values
)
# show immpoints
imm
=
IMMPoints
(
points
=
mean_values
)
...
...
src/pca.py
View file @
a54d0723
def
pca
(
data
,
mean_values
):
print
mean_values
import
numpy
as
np
def
preprocess
(
data
):
flattened
=
[]
y
,
x
,
dim
=
data
.
shape
for
i
in
range
(
y
):
flattened
.
append
(
np
.
ndarray
.
flatten
(
data
[
i
]))
return
np
.
array
(
flattened
)
def
pca
(
data
,
mean_values
,
n_components
):
# subtract mean
zero_mean
=
data
-
mean_values
X
=
preprocess
(
zero_mean
)
observations
,
dims
=
X
.
shape
U
,
S
,
V
=
np
.
linalg
.
svd
(
X
)
return
V
[:
n_components
],
S
[:
n_components
]
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