im doing face recognition project.please explain the above coding in a step by step manner in how it works
2 ビュー (過去 30 日間)
古いコメントを表示
%% illumination normalization
[x y] = ndgrid(1:size(I,1),1:size(I,2)); z = double(I); [Gx Gy] = gradient(z); mag = sqrt(Gx.^2+Gy.^2); h = fspecial('average',3); smooth = imfilter(z,h); norm_x = Gx./smooth; norm_y = Gy./smooth; niter = 10; kappa = 10; lambda = 0.25; im = double(norm_x+norm_y); figure,imshow(im),title('Smoothed image'); [rows,cols] = size(im); diff = im; var = 2;
for i = 1:niter diffl = zeros(rows+2,cols+2); diffl(2:rows+1,2:cols+1) = diff; %differences deltaN = diffl(1:rows,2:cols+1) - diff; deltaS = diffl(3:rows+2,2:cols+1) - diff; deltaE = diffl(2:rows+1,3:cols+2) - diff; deltaW = diffl(2:rows+1,1:cols) - diff;
%conduction
cN = exp(-(deltaN/kappa).^2);
cS = exp(-(deltaS/kappa).^2);
cE = exp(-(deltaE/kappa).^2);
cW = exp(-(deltaW/kappa).^2);
diff = diff+lambda*(cN.*deltaN+cS.*deltaS+cE.*deltaE+cW.*deltaW);
end
R = mat2gray(diff); bgImg = z;%Background Image fgImg = R;%Foreground Image
%Define Alpha Factor alphaFactor = 0.2;% 0 <= alphaFactor =< 1
%Size Validation bg_size = size(bgImg); fg_size = size(fgImg); sizeErr = isequal(bg_size, fg_size); if(sizeErr == 0) disp('Error: Images to be fused should be of same dimensions'); return; end
%Fuse Images fusedImg = FuseImages(bgImg, fgImg, alphaFactor); fusedImg = 25+uint8(fusedImg);
%Display Images figure; imshow(fusedImg);title('Illumination Normalized');
%% PCA feature extraction fusedImg=im2double(fusedImg); [Evalues, Evectors, x_mean]=PCA(fusedImg); figure,imshow(Evectors,[]);title('PCA');
features=entropy(x_mean)
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!