You are on page 1of 5

IMAGE WATERMARKING

IMAGE COMPRESSION
MATRIX OPRRATIONS

% basis set for spaces associated with a matrix


A=randi(10,4,2);
A=[A A*randi(4,2,2)];
r=rank(A);
[U, S, V]=svd(A);
Cs=U(:,1:r);
rank([A Cs]);
Lns=U(:,r+1:end);
Lns'*A;
V=V';
Rs=V(:,r,:);
rank([A;Rs]);
Rns=V(r+1:end,:);
Rns*A;
%%
A=randi(10,6,3);
A=[A A*randi(6,3,3)]
[U,S,V]=svd(A);
Sin=S
c=A'*A
d=A*A'
eig(c)
eig(d)
%%
randi([0 9],5,6); % rank will be 5

%%
A= randi([0 9],3,1) * randi([0 9],1,3)
%%
%Create a 3x4 matrix with rank 3

A = randi (10,3, 3) ;
A =[A A*randi (5,3,1) 1;
rank (A)

%%
% Create a 3x3 matrix with rank 2
Office on the web Frame
A = randi (10, 3,2);
A =[A Atrandi (4,2, 1) 1;
rank (A)

%%
A=11 2 3 4;2 3 4 5];
b=[4;6];
Xp=pinv(A)*b; % check A*Xp—b
Nsv=null(A);
Nc=size(Nsv,2); % number of column vectors
Xn=Nsv*randi([0 9],Nc, 1);
X=Xp+Xn
%%
% Create a 3x2 matrix A with random integers between 1 and 10
A = randi(10, 3, 2);

% Extend A to a 3x3 matrix by adding a third column


A = [A A*randi(4, 2, 1)];

% Display matrix A
disp('Matrix A:');
disp(A);

% Calculate rank of A
fprintf('Rank of A: %d\n', rank(A));

% Calculate eigenvalues and eigenvectors of A


[eig_vect, eig_val] = eig(A);

% Display eigenvalues and eigenvectors


disp('Eigenvalues:');
disp(eig_val);
disp('Eigenvectors:');
disp(eig_vect);

% Check if eigenvectors correspond to non-zero eigenvalues lie in column space


B = [A eig_vect(:,1)]; % append eigenvector as a column
fprintf('Rank of B: %d\n', rank(B));

C = [A; eig_vect(:,1)']; % append eigenvector as a row


fprintf('Rank of C: %d\n', rank(C));

%%

% office on the web Frame random 5x4 matrix A with rank 2 and a 5x1 vector b such that Ax=b has infinite
solution.
A = randi (10, 5, 2) ;
A = [A A*randi (4,2,2)]; %creation of A matrix with rank 2
rank (A)
b = sum (A, 2); ° b is in column space of A
for i = 1:3
x = pinv (A) *b+null (A) *randi (4,2, 1); & solution
A*x : checking
x1 = 1x1 x]; % infinite solution
end

%%Generate a sinusoidal signal


t = 0:0.001:1;
f = 5;
A=1
Sig = A*sin (2*pi*f*t);
plot(t,Sig);
figure; stem(t,Sig)

%% Using SVD find basis set for all the spaces associated with a matrix
A = randi(10, 4, 2);
A = [A A*randi(4, 2, 2)]; % Creation of A matrix with rank 2
r = rank(A);
[U, S, V] = svd(A);
Cs = U(:, 1:r); % Column space basis
disp('Rank of [A Cs]:');
disp(rank([A Cs]));

Lns = U(:, r+1:end); % Left null space basis


disp('Checking x''*A=0 for left null space basis:');
disp(Lns' * A);

v = V';
Rs = v(:, 1:r); % Row space basis
disp('Rank of [A;Rs]:');
disp(rank([A; Rs]));

Rns = v(:, r+1:end); % Right null space basis


disp('Checking A*Rns''=0 for right null space basis:');
disp(A * Rns');

%%

while true
A = randi([-10, 10], 6);
if rank(A) == 3
break;
end
end

% SVD
[U, S, V] = svd(A);

disp('Singular Values:');
disp(diag(S));

% Calculate matrices B and C


B = A' * A;
C = A * A';

disp('Matrix B:');
disp(B);
disp('Matrix C:');
disp(C);

eigenvalues_B = eig(B);
eigenvalues_C = eig(C);

disp('Eigenvalues of B:');
disp(eigenvalues_B');
disp('Eigenvalues of C:');
disp(eigenvalues_C');

%%
x=-50: 50;y=x;
[x1,x2]=meshgrid(x,y);
Z=(x1-3).^2+(x2-5).^2;
surfc(x,y,Z);
shading interp
Xlabel('x');
ylabel('y');
zlabel('z');

You might also like