-
大小: 2KB文件類型: .m金幣: 1下載: 0 次發(fā)布日期: 2021-06-10
- 語言: Matlab
- 標簽: 圖像處理??ImageProcess??圖像量化??MSE/SNR/PSNR??Matlab代碼??
資源簡介
圖像處理中的量化方法以及MSE/SNR/PSNR誤差計算,采用了Level=16和Level=8兩種量化方式。
代碼片段和文件信息
clc;
close?all;
clear?all;
O=imread(‘model.jpg‘‘jpg‘);
I=rgb2gray(O);
%I?saves?the?gray?information?of?image?model.jpg
I_info=size(I);
M=I_info(1);?%the?width?of?the?image
N=I_info(2);?%the?height?of?the?image
%I?saves?the?information?of?image?modelgray.jpg
imshow(I);title(‘original?image‘);
%display?original?image
I64=floor(I/4)*4+2;
III=double(I);
I6464=double(I64);
I64_mse=sum(sum((III-I6464).^2))/(M*N);
mean64=sum(sum(I64))/(M*N);
mean64_2=mean64*ones(MN);
I64_2=double(I64)-mean64_2;
sigma2_64=sum(sum((I64_2).^2))./(M*N);
I64_snr=10*log(sigma2_64/I64_mse);
I64_psnr=10*log(255^2/I64_mse);
fprintf(‘\nLevel=64?MSE/SNR/PSNR?are??%f?/?%f?/?%f??separately.\n‘I64_mseI64_snrI64_psnr);
figure;
imshow(I64);title(‘quantized?image?with?L=64‘);
%level=64
%display?the?MSE/SNR/PSNR?and?the?quantized?image
I32=floor(I/8)*8;
I32_mse=sum(sum((I-I32).^2))/(M*N);
評論
共有 條評論