renamed files, lesson 10/11
This commit is contained in:
32
11-08/eigenfaces_scatter.jl
Normal file
32
11-08/eigenfaces_scatter.jl
Normal file
@ -0,0 +1,32 @@
|
||||
using Colors, LinearAlgebra, Plots, Statistics
|
||||
|
||||
function eigenfaces_scatter(images, indices)
|
||||
|
||||
(w, h, nExpressions, nIndividuals) = size(images)
|
||||
X= reshape(images, (w*h, nIndividuals*nExpressions))
|
||||
avg = mean(X, dims=2)
|
||||
Xd = X .- avg
|
||||
(U,S,V) = svd(Xd)
|
||||
scores = U[:,indices]' * Xd
|
||||
# normalize scores and samples
|
||||
# scores = bsxfun(@rdivide,scores,sqrt(sum(abs(scores).^2)));
|
||||
|
||||
if length(indices) == 3
|
||||
scatter(
|
||||
scores[1,:],
|
||||
scores[2,:],
|
||||
scores[3,:],
|
||||
markersize = 3*ones(size(scores[1,:])),
|
||||
marker_z = reshape(kron(1:nExpressions, ones(1,nIndividuals)'), (nExpressions*nIndividuals, 1)),
|
||||
legend = nothing
|
||||
)
|
||||
elseif length(indices) == 2
|
||||
scatter(
|
||||
scores[1,:],
|
||||
scores[2,:],
|
||||
markersize = 3*ones(size(scores[1,:])),
|
||||
marker_z = reshape(kron(1:nExpressions, ones(1,nIndividuals)'), (nExpressions*nIndividuals, 1)),
|
||||
legend = nothing
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user