Code Understanding Help Needed
显示 更早的评论
Hello, I have some problems in understanding this piece of code. Anybody's help will be really appreciated.
lambda=100;
level=1;
im=im2double(curr_frame);
scrib=im2double(curr_trimap);
scrib=reshape(scrib(:,:,1),[],1);
nn=[10;2];
[m n d]=size(im);
val=scrib>0.99;
map=(scrib<0.01)+val;
[a b]=ind2sub([m n],1:m*n);
feature=[reshape(im,m*n,d)';[a;b]/sqrt(m*m+n*n)*level+rand(2,m*n)*1e-6];
now=0;
for i=1:size(nn,1)
ind=vl_kdtreequery(vl_kdtreebuild(feature),feature,feature,'NUMNEIGHBORS',nn(i),'MAXNUMCOMPARISONS',nn(i)*2);
a=reshape(repmat(uint32(1:m*n),nn(i),1),[],1);
b=reshape(ind,[],1);
row(now+1:now+m*n*nn(i),:)=[min(a,b) max(a,b)];
feature(d+1:d+2,:)=feature(d+1:d+2,:)/100;
now=now+m*n*nn(i);
end
value=max(1-sum(abs(feature(1:d+2,row(:,1))-feature(1:d+2,row(:,2))))/(d+2),0);
A=sparse(double(row(:,1)),double(row(:,2)),value,m*n,m*n);
A=A+A';
D=spdiags(sum(A,2),0,n*m,n*m);
M=D-A+lambda*spdiags(map,0,m*n,m*n);
L=ichol(M);
x=pcg(M,lambda*val,[],2000,L,L');
% figure,imshow(reshape(x,m,n));
% imwrite(reshape(x,m,n),'res.png','png');
Alpha = reshape(x,m,n);
val=scribe>0.99; it will assign 1 to the values greater than 0.99 and all others =0. Now next is map=(scrib<0.01)+val; How the values will be assign here? Please explain this condition. Also, please explain this line:
feature=[reshape(im,m*n,d)';[a;b]/sqrt(m*m+n*n)*level+rand(2,m*n)*1e-6];
I am unable to understand this line.
Please help. Thanks
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!