shadowremoval.m

来自「很好的mATLAB代码」· M 代码 · 共 44 行

M
44
字号
clear
F=(imread('C:\Downloads\PCA_based Face Recognition System\TestDatabase\1.jpg'));% feeding input matrix
% F=rgb2gray(F); % change bmp into gray-level image.
% imshow(F);

[row,col]=size(F);% size of image
U=zeros(row,col);% internal activity matrix
Y=zeros(row,col);% output matrix
K=[1 1 1;1 0 1;1 1 1];% Convolutions kernel matrix;
L=zeros(row,col);% linking matrix L=Step(Y convolution K)
Theta=ones(row,col)*0.9; % threshold matrix
Quo=zeros(row,col);
Seg=zeros(row,col);
Inter=Y;
Re=Seg;

Beta=0.8;
Delta=1/256;
minVal=0.004;

DeltaMatrix=Delta*ones(row,col);
F=((1-minVal)/255)*double(F)+0.00004;%nonilize input matrix

imshow(F);
%-------------------------------------------------------------
% Inter=Y+1;
while (1)% if not all neuron have fired;
    L=hardlim(conv2(Y,K,'same')-1);
    Inter=Y;
    U=F.*(1+Beta*L);
    Y=hardlim(U-Theta);        
    Seg=Seg+Y.*Theta;
    Theta=Theta+Y*1000;
    Theta=Theta-Delta;
%     Quo=Quo+Y;
    Quo=F./Seg;
%     imshow(Quo);
    if Theta>1 
        break;
    end;
end;

imshow(Quo);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?