Demo entry 6686580

发生的

   

Submitted by 士大夫似的 on Dec 24, 2017 at 08:35
Language: Matlab. Code size: 565 Bytes.

function[W,H] =  nmfex2(V,r,maviter)
%V=double(imread('lena.jpg'));
V = rgb2gray(V);
imshow(mat2gray(V));
V = double(V);
[i, u]=size(V);                                    %计算V的规格
%r=100;                                  %设置分解矩阵的秩
W=rand(i,r);                            %初始化WH,为非负数
H=rand(r,u);
%maviter=100;                                    %最大迭代次数
for iter=1:maviter
    W=W.*((V./(W*H))*H');           %注意这里的三个公式和文中的是对应的
    W=W./(ones(i,1)*sum(W));    
    H=H.*(W'*(V./(W*H)));
end

img_V=W*H;
figure;
imshow(histeq(mat2gray(img_V)));
end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).