资源简介
在matlab实现从RGB色空间到YCBCR色空间的转换,并用YCBCR色空间实现图像压缩
代码片段和文件信息
%RGB 空间与 YCbCr 空间的互换
%实现图像压缩
clear
close all;
I = imread( ‘avatar.bmp‘ );
I = im2double( I );
%RGB转换到 YCbCr
R = I( : : 1 );
G = I( : : 2 );
B = I( : : 3 );
Y = 16 + ( 0.256789 * R + 0.504129 * G + 0.097906 * B );
Cb = 128 + ( -0.148223 * R - 0.290992 * G + 0.439215 * B );
Cr = 128 + ( 0.439215 * R - 0.367789 * G - 0.071426 * B );
rebuilt_Cb = 1:300;
rebuilt_Cr = 1:300;
%图像压缩与解压
for i = 1:2:299
for j = 1:2:299
press_Cb = ( Cb(ij)+Cb(i+1j)+Cb(ij+1)+Cb(i+1j+1) ) / 4;
press_Cr = ( Cr(ij)+Cr(i+1j)+Cr(ij+1)+Cr(i+1j+1) ) / 4;
for k = i:( i + 1 )
for l = j:( j + 1 )
rebuilt_Cb( i j ) = press_Cb;
rebuilt_Cb( i + 1 j ) = press_Cb;
rebuilt_Cb( i j + 1 )
- 上一篇:MATLAB神经网络编程源代码
- 下一篇:包络谱分析
评论
共有 条评论