⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 no1.m

📁 人脸识别
💻 M
字号:
%% ---------------------------------------------------------------
%% Function description:
%% Assignment #2   (1) SVD 
%% ---------------------------------------------------------------
%% Created by Xuan Liu                   Version 1.0  2008.1.27
%% ---------------------------------------------------------------
clear all;
close all;
%% ---------------------------------------------------------------
%% Part 1: SVD ,draw original image and compressed images
%% ---------------------------------------------------------------
%load detail;
figure(1)
RGB=imread('aaa.jpg');
subplot(2,3,1)
imshow(RGB)
G =rgb2gray(RGB);

subplot(2,3,2)
imshow(G)
X=im2double(G);
title('original image')
subplot(2,3,3)
imshow(X)
[m,n]=size(X)
[U,S,V]=svd(X);
subplot(2,3,4)
k=5 ;
cratio1=(m+n)*k/(m*n)
imshow(U(:,1:k)*S(1:k,1:k)*V(:,1:k)')
title('compressed image with k=5')
subplot(2,3,5)
k=20 ;
cratio2=(m+n)*k/(m*n)
imshow(U(:,1:k)*S(1:k,1:k)*V(:,1:k)')
title('compressed image with k=20')
subplot(2,3,6)
k=100 ;
cratio3=(m+n)*k/(m*n)
imshow(U(:,1:k)*S(1:k,1:k)*V(:,1:k)')
title('compressed image with k=100')
%% ---------------------------------------------------------------
%% Part 2: plot singular values of X
%% ---------------------------------------------------------------
figure(2)
y=diag(S);
semilogy(1:min(m,n),y)
title('log plot of singular values of X')
axis([1,min(m,n),min(y),max(y)])
xlabel('i')
ylabel('singular values')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -