YUV色彩空间中对比度、色度、饱和度调节

前言

        图像处理中,如果要调整图像的对比度、色度、饱和度,在RGB色彩空间处理实为不变,这需要转换到HSV色彩空间中去,不够快速。因此本文提出了直接基于YUV色彩空间处理的方法。

对比度调节

        代码如下:        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C1=0.5;
C2=2;
for i=1:m
   for j=1:n 
       Y1(i,j) = Y1(i,j)*C1;
   end
end

for i=1:m
   for j=1:n 
       Y2(i,j) = Y2(i,j)*C2;
   end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   效果如下:

色度调节

        代码如下:        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%调节色度
% U' = (U-128) x Cos(H) + (V-128) x Sin(H)
% V' = (V-128) x Cos(H) - (U-128) x Sin(H)
H1=120;
H1=H1/180*pi;
for i=1:m
   for j=1:n 
       Cb1(i,j) =(Cb1(i,j)-128)*sin(H1) +(Cr1(i,j)-128)*cos(H1)+128;
       Cr1(i,j) =(Cr1(i,j)-128)*sin(H1) -(Cb1(i,j)-128)*cos(H1)+128;
   end
end
H2=60;
H2=H2/180*pi;
for i=1:m
   for j=1:n 
       Cb2(i,j) =(Cb2(i,j)-128)*sin(H2) +(Cr2(i,j)-128)*cos(H2)+128;
       Cr2(i,j) =(Cr2(i,j)-128)*sin(H2) -(Cb2(i,j)-128)*cos(H2)+128;
   end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 效果如下:        

饱和度调节 

        代码如下:        

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S1=0.25;
S2=0.75;
for i=1:m
   for j=1:n 
       Cb1(i,j) =(Cb1(i,j)-128)*S1 +128;
       Cr1(i,j) =(Cr1(i,j)-128)*S1 +128;
   end
end
for i=1:m
   for j=1:n 
       Cb2(i,j) =(Cb2(i,j)-128)*S2 +128;
       Cr2(i,j) =(Cr2(i,j)-128)*S2 +128;
   end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

效果如下:        

欢迎点赞收藏

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值