• 大小: 711KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: 其他
  • 标签: matlab  

资源简介

该代码能够有效去除阴影,亲测能运行,且效果很好

资源截图

代码片段和文件信息

clear all
% close all
clc
b=imread(‘Image9.jpg‘);
b=imresize(b [200 200]);
a=double(b);
figure;
imshow(b);



epsilon = 1e-3;
I=find(a==0);
a(I)=epsilon;

r_b=log(a(::1)./a(::3));
g_b=log(a(::2)./a(::3));
l = 1;
B = zeros(140000);
R = zeros(140000);
for i = 1:200
   for j = 1:200
    B(l) = g_b(ij);
    l = l+1;
   end
end
m = 1;
for i = 1:200
    for j = 1:200
        R(m) = r_b(ij);
        m = m+1;
    end
end
figure plot(RB‘o‘);


% %  deg = invAngle(r_b g_b);
deg=51;
rad = deg*(pi/180);
inv = (cos(rad)*(r_b) - sin(rad)*(g_b));
invexp = exp(inv);
invexp=invexp-min(min(invexp));
invexp=invexp*255/max(max(invexp));
figure;
imshow(invexp [0 255]);


%+++++++++++++++++++++++++++++++++++++++++++
% clustering into 2 clusters

x= (max(g_b(:)) + min(g_b(:)))/2;
c1=g_b(find(g_b >= x));
c2=g_b(find(g_b < x));
mc1=median(c1);
mc2=median(c2); 
for i=1:200    
    for j=1:200
        if(g_b(ij) >=x)
            logresRG(ij) = inv(ij)*cos(-rad) + mc1*sin(-rad);
            logresBG(ij) = -inv(ij)*sin(-rad) + mc1*cos(-rad);            
        else
            logresRG(ij) = inv(ij)*cos(-rad) + mc2*sin(-rad);
            logresBG(ij) = -inv(ij)*sin(-rad) + mc2*cos(-rad);                        
        end
    end
end
resRG = exp(logresRG);
resBG = exp(logresBG);

%+++++++++++++++++++++++++++++++++++++++++++


B =(3*invexp)./ (resRG + resBG +1);
B=B-min(B(:));
B=B/(max(B(:)));

R = resRG.*B;
R=R-min(R(:));
R=R/(max(R(:)));

G = resBG.*B;
G=G-min(G(:));
G=G/(max(G(:)));

rgb(::1)=R;
rgb(::2)=G;
rgb(::3)=B/2;
 
figure
imshow((rgb2gray(rgb)));% Gray Scale Image if shadow Less Image
figure
imshow(rgb); % RGB Shadow Less Image

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件      729417  2014-07-16 00:07  Image9.jpg
     文件        1763  2014-07-16 00:07  inv110107.asv
     文件        1762  2014-07-16 00:07  inv110107.m
     文件         758  2014-07-16 00:07  invAngle.m
     文件        1506  2014-07-16 00:07  license.txt
     文件         256  2014-07-16 00:07  waqar.txt

评论

共有 条评论