我有这张图片
我想从图像中去除阴影。我知道许多不同的方法(例如某些形态学运算)已用于去除阴影:
我为同一张图片创建了此蒙版
我还有其他方法可以尝试使用创建的此蒙版吗?
编辑:
输入与要求尺寸相同的图像和遮罩:
编辑2:我生成了一维不变图像,但它并不完美
I = imread('shadow.jpg');
J = im2double(I);
R = J(:,:,1);
G = J(:,:,2);
B = J(:,:,3);
[len,wid] = size(R);
% Generation of 2-D Log Chromaticity Image.
for i = 1:len
for j = 1:wid
if ((R(i,j)*G(i,j)*B(i,j))~= 0)
c1(i,j) = R(i,j)/((R(i,j)*G(i,j)*B(i,j))^(1/3));
c2(i,j) = G(i,j)/((R(i,j)*G(i,j)*B(i,j))^(1/3));
c3(i,j) = B(i,j)/((R(i,j)*G(i,j)*B(i,j))^(1/3));
else
c1(i,j) = 1;
c2(i,j) = 1;
c3(i,j) = 1;
end
end
end
rho1 = mat2gray(log(c1));
rho2 = mat2gray(log(c2));
rho3 = mat2gray(log(c3));
X1 = mat2gray(rho1*1/(sqrt(2)) - rho2*1/(sqrt(2))); %(1/sqrt(2); -1/sqrt(2); 0)
X2 = mat2gray(rho1*1/(sqrt(6)) + rho2*1/(sqrt(6)) - rho3*2/(sqrt(6))); %(1/sqrt(6); 1/sqrt(6); -2/sqrt(6))
theta = 120;
InvariantImage = cos(theta*pi/180)*X1 + sin(theta*pi/180)*X2;
imagesc(InvariantImage); colormap(gray)
无法理解我在做什么错,请帮忙?