资源简介

国外写的knn-matting,图像抠图的源程序,有实例,可直接使用

资源截图

代码片段和文件信息

clear all;
run(‘vlfeat-0.9.16/toolbox/vl_setup‘);
lambda=100;
level=1;
%im=double(rgb2gray(imread(‘tuoniao.bmp‘)))/255;
im = double(imread(‘kongque.png‘))/255;
scrib=reshape(double(rgb2gray(imread(‘kongque_scribe.png‘)))/255[]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(imm*nd)‘;[a;b]/sqrt(m*m+n*n)*level+rand(2m*n)*1e-6];
now=0;
for i=1:size(nn1)
    ind=vl_kdtreequery(vl_kdtreebuild(feature)featurefeature‘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(ab) max(ab)];
    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+2row(:1))-feature(1:d+2row(:2))))/(d+2)0);
A=sparse(double(row(:1))double(row(:2))valuem*nm*n);
A=A+A‘;
D=spdiags(sum(A2)0n*mn*m);
M=D-A+lambda*spdiags(map0m*nm*n);
L=ichol(M);
x=pcg(Mlambda*val[]2000LL‘);
figureimshow(reshape(xmn));
imwrite(reshape(xmn)‘kongque_res.png‘‘png‘);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1083  2013-04-08 10:46  knn-matting\knn_matting_scribble_rgb.m

     文件     576711  2012-12-13 20:29  knn-matting\kongque.png

     文件      90456  2013-04-08 10:47  knn-matting\kongque_res.png

     文件       6636  2013-03-10 12:14  knn-matting\kongque_scribe.png

     文件         59  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\.gitattributes

     文件        694  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\.gitignore

     文件      11301  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\apps\phow_caltech101.m

     文件       4621  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\apps\sift_mosaic.m

     文件       8137  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\aib

     文件     206535  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\libvl.so

     文件      24862  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\mser

     文件      37466  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\sift

     文件       7466  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_gauss_elimination

     文件       8632  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_getopt_long

     文件      12132  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_heap-def

     文件       7211  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_host

     文件       9180  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_imopv

     文件      10445  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_mathop

     文件       7754  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_mathop_abs

     文件       7576  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_nan

     文件       8332  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_qsort-def

     文件       7936  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_rand

     文件      10378  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_stringop

     文件       8858  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_svd2

     文件       8434  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_threads

     文件       8327  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnx86\test_vec_comp

     文件      10671  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnxa64\aib

     文件     229568  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnxa64\libvl.so

     文件      28888  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnxa64\mser

     文件      43124  2012-10-04 18:19  knn-matting\vlfeat-0.9.16\bin\glnxa64\sift

............此处省略2057个文件信息

评论

共有 条评论