背景和前景重建方法,直接在alpha数值上进行RGB颜色的融合

本文探讨了图像合成与融合的实现过程,包括读取图片、颜色调整与合成方法,最终展示融合后的图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

alpha=imread('..\plasticbag.png');%read three image from local directory
b=imread('F:\matting\input_lowres\doll.png');%background img
f=imread('F:\matting\input_training_lowres\GT04.png');%foreground img


%%
alpha=im2double(alpha);%rgb color,r=g=b
alpha=alpha(:,:,1);% size(alpha)==size(f:froeground)
%%
b=im2double(b);
f=im2double(f);
[h,w,c]=size(f);%here we only use the foreground image,
[bh,bw,bc]=size(b);
b(:)=1;%设置为白色的背景
%%
% the size of b:background >= the size of f:foreground
%%
img=zeros(h,w,c);
for i=1:h
    for j=1:w
        img(i,j,1)=f(i,j,1)*alpha(i,j)+b(i,j,1)*(1-alpha(i,j));%融合函数
        img(i,j,2)=f(i,j,2)*alpha(i,j)+b(i,j,2)*(1-alpha(i,j));
        img(i,j,3)=f(i,j,3)*alpha(i,j)+b(i,j,3)*(1-alpha(i,j));
    end
end
imshow(img);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值