PhotoShop中的色调均化算法(matlab)

1. 统计直方图,对于RGB图像,三通道联合统计

2. 采用累积直方图映射

function outmat = ToneEqualization(inmat, bits)
% PhotoShop色调均化

% bits = 16;
% inmat = imgdata;
% imshow(uint8(inmat./65535.*255));

[Height, Width, plane] = size(inmat);
nbins = uint16(2^bits);
in1 = inmat(:,:,1);
in2 = inmat(:,:,2);
in3 = inmat(:,:,3);
all_in = [in1 in2 in3];
all_hist = zeros(nbins,1);
for i=1:Height
    for j=1:Width*3
        all_hist(uint16(all_in(i,j))) = all_hist(uint16(all_in(i,j))) + 1;
    end
end
% figure;plot(all_hist);

%all_hist = imhist(uint16(all_in(:)),nbins);

% 计算映射表,累积直方图
Num = 0;
for y=1:1:nbins
    Num = Num + all_hist(y);
    Lut(y) = uint32(Num / (Width * Height * 3) * nbins);   
end

outmat = zeros(Height, Width, plane);
for x=1:Height
    for y=1:Width
        outmat(x,y,1) = Lut(uint16(in1(x,y)));
        outmat(x,y,2) = Lut(uint16(in2(x,y)));
        outmat(x,y,3) = Lut(uint16(in3(x,y)));
    end
end
% imshow(uint8(outmat./65535.*255));
end

 

                                           原始图                                                                                 色调均化后

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值