clc;clear all;close all;
image = imread('football.jpg');
image = double(image);
image_reshape = reshape(image, size(image,1)*size(image,2),3);
figure(1)
subplot(2,2,1)
imshow(mat2gray(image))
subplot(2,2,2)
imhist(mat2gray(image))
subplot(2,2,3)
plot3(image_reshape(:,1), image_reshape(:,2), image_reshape(:,3), 'r.')
subplot(2,2,4)
imhist(mat2gray(image_reshape))
q = 2;
[coeff,Data_PCA,latent,tsquared,explained,mu] = pca(image_reshape);
md1 = rica(Data_PCA, q);
Data_ICA = transform(md1, Data_PCA);
Data_no_noise = Data_ICA(:,1);
plotsPerCol = 2;
figure(2)
for i = 1:q
subplot(plotsPerCol, ceil(q/plotsPerCol), i)
plot(Data_ICA(:,i).^2)
title(strcat("Component ", string(i), " Squared"))
end
figure(3)
PCA1 = Data_PCA(:,1).^2;
PCA2 = Data_PCA(:,2).^2;
PCA3 = Data_PCA(:,3).^2;
plot3(PCA1, PCA2, PCA3, 'r.')