|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
以下是一个关于Retinex算法的代码:
I=imread('1.jpg');
I=rgb2gray(I);
if(isgray(I))%判断是否为灰度图像
I=double(I)/255;
I=log(I);
[M N]=size(I);
constant=128;%mean2(I)
h=floor(M/2);
v=floor(N/2);
while(h>=1&v>=1)
for x=0:M-1
for y=0:N-1
R_lightness(x,y)=log(I(x+h,y))-log(I(x,y));
lightness(x,y)=constant+R_lightness(x,y);
R_lightness(x,y)=log(I(x,y+v))-log(I(x,y));
lightness(x,y)=constant+R_lightness(x,y);
end
end
h=floor(h/2);
v=floor(v/2);
end
high=max(max(lightness));
low=min(min(lightness));
for x=0:M-1
for y=0:N-1
L(x,y)=((lightness(x,y)-max)/(max-min))*255;
end
end
imshow(uint8(L),[]);
end
运行结果成了这样了:
Warning: Log of zero.
??? Subscript indices must either be real positive integers or logicals.
请高手指教一下,谢谢! |
|