联系QQ:

2181264433

新闻资讯
联系我们
联系:张女士
微信:扫一扫右侧二维码
QQ :2181264433
邮箱:2181264433@qq.com
地址:浙江省-嘉兴市-南湖区
网址:www.mhslogic.com
您当前位置:首页 > 国内资讯 > 正文国内资讯
MATLAB代做|FPGA代做|simulink代做——histmatch
添加时间:2020-8-12 来源:本站整理
function [ result ] = histmatch(source,target)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
src_r=source(:,:,1);
src_g=source(:,:,2);
src_b=source(:,:,3);

src_hnorm_r=imhist(src_r)./numel(src_r);
src_hnorm_g=imhist(src_g)./numel(src_g);
src_hnorm_b=imhist(src_b)./numel(src_b);

src_cdf_r=cumsum(src_hnorm_r);
src_cdf_g=cumsum(src_hnorm_g);
src_cdf_b=cumsum(src_hnorm_b);

src_cdf_r=im2uint8(src_cdf_r)+1;
src_cdf_g=im2uint8(src_cdf_g)+1;
src_cdf_b=im2uint8(src_cdf_b)+1;

tag_r=target(:,:,1);
tag_g=target(:,:,2);
tag_b=target(:,:,3);

tag_hnorm_r=imhist(tag_r)./numel(tag_r);
tag_hnorm_g=imhist(tag_g)./numel(tag_g);
tag_hnorm_b=imhist(tag_b)./numel(tag_b);

tag_cdf_r=cumsum(tag_hnorm_r);
tag_cdf_g=cumsum(tag_hnorm_g);
tag_cdf_b=cumsum(tag_hnorm_b);

tag_cdf_r=im2uint8(tag_cdf_r)+1;
tag_cdf_g=im2uint8(tag_cdf_g)+1;
tag_cdf_b=im2uint8(tag_cdf_b)+1;

[h,w,c]=size(source);
result=ones(h,w,c);

src2tag=ones(256,1);

% r
startz=1;
for s=1:1:256
    for z=startz:1:256
        if((int16(tag_cdf_r(z))-s)>=0)
            src2tag(s)=z;
            break;
        end
    end
    startz=z;
end

for i=1:1:h
    for j=1:1:w
        result(i,j,1)=src2tag(src_cdf_r(src_r(i,j)+1))-1;
    end
end
% g
startz=1;
for s=1:1:256
    for z=startz:1:256
        if((int16(tag_cdf_g(z))-s)>=0)
            src2tag(s)=z;
            break;
        end
    end
    startz=z;
end

for i=1:1:h
    for j=1:1:w
        result(i,j,2)=src2tag(src_cdf_g(src_g(i,j)+1))-1;
    end
end

% b
startz=1;
for s=1:1:256
    for z=startz:1:256
        if((int16(tag_cdf_b(z))-s)>=0)
            src2tag(s)=z;
            break;
        end
    end
    startz=z;
end

for i=1:1:h
    for j=1:1:w
        result(i,j,3)=src2tag(src_cdf_b(src_b(i,j)+1))-1;
    end
end

result=double(result)./255;


end

联系:张女士

QQ :2181264433

微信:lovemike121

邮箱:2181264433@qq.com

网站:http://www.mhslogic.com/

------------------------------------------------------------------------------------------------

交易可直接通过淘宝店铺


(可直接通过旺旺与技术员联系)




https://shop185632181.taobao.com/?spm=2013.1.w5001-22653403434.6.27f92e0a6xR1sB&scene=taobao_shop

扫一扫,关注我们