renamed files, lesson 10/11

This commit is contained in:
elvis
2023-11-15 11:23:16 +01:00
parent 8d7c769823
commit 9e7f427faa
188 changed files with 321 additions and 7 deletions

View 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