查看: 116|回复: 0|关注: 0

[未答复] 颜色空间迁徙

[复制链接]

新手

5 麦片

财富积分


050


1

主题

1

帖子

0

最佳答案
发表于 2020-8-31 10:07:29 | 显示全部楼层 |阅读模式
有没有大神可以帮忙改下程序,主要是使用一个图片给另一个图片进行颜色的迁徙。目前程序可以运行,但是显示图片是全黑的,希望大神可以帮忙改下,谢谢。
%+++++++++++++++++++++++++++++求取目标图像的lab+++++++++++++++++++++++++++++++++++
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
l3=zeros(wid,hei);
alpha3=zeros(wid,hei);
beta3=zeros(wid,hei);
for i=1:wid
    for j=1:hei
        l3(i,j)=(l2(i,j)-lm2)*sigm1/sigm11+lm1;
        alpha3(i,j)=(alpha2(i,j)-am2)*sigm2/sigm22+am1;
        beta3(i,j)=(beta2(i,j)-bm2)*sigm3/sigm33+bm1;
    end
end
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%+++++++++++++++++++++++++++++++反变换到LMS++++++++++++++++++++++++++++++++++++
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
L3=zeros(wid,hei);
M3=zeros(wid,hei);
S3=zeros(wid,hei);
for i=1:wid
    for j=1:hei
        m=inv(con3*con2)*[l3(i,j);alpha3(i,j);beta3(i,j)];
        L3(i,j)=m(1);
        M3(i,j)=m(2);
        S3(i,j)=m(3);
    end
end
%==================================LMS取指数===============================
L3=power(10,L3);
M3=power(10,M3);
S3=power(10,S3);
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%++++++++++++++++++++++++++++++转换到RGB++++++++++++++++++++++++++++++++++++++
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TarR=zeros(wid,hei);
TarG=zeros(wid,hei);
TarB=zeros(wid,hei);
for i=1:wid
    for j=1:hei
        m=inv(con1)*[L3(i,j);M3(i,j);S3(i,j)];
        TarR(i,j)=m(1);
        if TarR(i,j)>255
           TarR(i,j)=255;
        elseif TarR(i,j)<0
           TarR(i,j)=0;  
        end
        TarG(i,j)=m(2);
        if TarG(i,j)>255
           TarG(i,j)=255;
        elseif TarG(i,j)<0
           TarG(i,j)=0;  
        end
        TarB(i,j)=m(3);
        if TarB(i,j)>255
           TarB(i,j)=255;
        elseif TarB(i,j)<0
           TarB(i,j)=0;  
        end        
    end
end
Tar=uint8(cat(3,TarR,TarG,TarB));
imshow(Tar);
回复主题 已获打赏: 0 积分

举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐上一条 /5 下一条

快速回复 返回顶部 返回列表