资源简介
流行排序MATLAB代码, 略有改动, 可以直接运行 效果比原始版本略好
代码片段和文件信息
% Demo for paper “Saliency Detection via Graph-based Manifold Ranking“
% by Chuan Yang Lihe Zhang Huchuan Lu Ming-Hsuan Yang and Xiang Ruan
% To appear in Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2013) Portland June 2013.
addpath(‘./others/‘);
%%------------------------set parameters---------------------%%
theta=10; % control the edge weight
alpha=0.99;% control the balance of two items in manifold ranking cost function
spnumber=200;% superpixel number
imgRoot=‘./test/‘;% test image path
saldir=‘./saliencymap/‘;% the output path of the saliency map
supdir=‘./superpixels/‘;% the superpixel label file path
foredir=‘./foreground/‘;%the foreground map
mkdir(supdir);
mkdir(saldir);
mkdir(foredir);
imnames=dir([imgRoot ‘*‘ ‘jpg‘]);
for ii=1:length(imnames)
disp(ii);
imname=[imgRoot imnames(ii).name];
[input_imw]=removeframe(imname);% run a pre-processing to remove the image frame
[mnk] = size(input_im);
%%----------------------generate superpixels--------------------%%
imname=[imname(1:end-4) ‘.bmp‘];% the slic software support only the ‘.bmp‘ image
comm=[‘SLICSuperpixelSegmentation‘ ‘ ‘ imname ‘ ‘ int2str(20) ‘ ‘ int2str(spnumber) ‘ ‘ supdir];
system(comm);
spname=[supdir imnames(ii).name(1:end-4) ‘.dat‘];
superpixels=ReadDAT([mn]spname); % superpixel label matrix
spnum=max(superpixels(:));% the actual superpixel number
%%----------------------design the graph model--------------------------%%
% compute the feature (mean color in lab color space)
% for each node (superpixels)
input_vals=reshape(input_im m*n k);
rgb_vals=zeros(spnum13);
inds=cell(spnum1);
for i=1:spnum
inds{i}=find(superpixels==i);
rgb_vals(i1:)=mean(input_vals(inds{i}:)1);
end
lab_vals = colorspace(‘Lab<-‘ rgb_vals);
seg_vals=reshape(lab_valsspnum3);% feature for each superpixel
% get edges
adjloop=AdjcProcloop(superpixelsspnum);
edges=[];
for i=1:spnum
indext=[];
ind=find(adjloop(i:)==1);
for j=1:length(ind)
indj=find(adjloop(ind(j):)==1);
indext=[indextindj];
end
indext=[indextind];
indext=indext((indext>i));
indext=unique(indext);
if(~isempty(indext))
ed=ones(length(indext)2);
ed(:2)=i*ed(:2);
ed(:1)=indext;
edges=[edges;ed];
end
end
% compute affinity matrix
weights = makeweights(edgesseg_valstheta);
W = adjacency(edgesweightsspnum);
% learn the optimal affinity matrix (eq. 3 in paper)
dd = sum(W); D = sparse(1:spnum1:spnumdd); clear dd;
optAff =(D-alpha*W)\eye(spnum);
mz=diag(ones(spnum1));
mz=~mz;
optAff=optAff.*mz;
%%-----------------------------stage 1--------------------------%%
% compute the saliency value for each superpix
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-27 19:17 cvprcode\
文件 5599 2018-04-24 22:34 cvprcode\demo.m
文件 5679 2018-04-24 22:31 cvprcode\demo1.m
文件 5768 2018-04-24 22:34 cvprcode\demo2.m
目录 0 2018-04-27 19:17 cvprcode\foreground\
文件 1822 2018-04-24 22:45 cvprcode\foreground\11987_foreground.png
文件 1851 2018-04-24 22:46 cvprcode\foreground\11987_foreground1.png
文件 1851 2018-04-24 22:46 cvprcode\foreground\11987_foreground2.png
文件 1363 2018-04-24 22:45 cvprcode\foreground\148226_foreground.png
文件 1320 2018-04-24 22:46 cvprcode\foreground\148226_foreground1.png
文件 1488 2018-04-24 22:46 cvprcode\foreground\148226_foreground2.png
文件 1373 2018-04-24 22:45 cvprcode\foreground\149193_foreground.png
文件 1220 2018-04-24 22:46 cvprcode\foreground\149193_foreground1.png
文件 1110 2018-04-24 22:46 cvprcode\foreground\149193_foreground2.png
文件 1938 2018-04-24 22:45 cvprcode\foreground\149563_foreground.png
文件 1590 2018-04-24 22:46 cvprcode\foreground\149563_foreground1.png
文件 1590 2018-04-24 22:46 cvprcode\foreground\149563_foreground2.png
文件 1462 2018-04-24 22:45 cvprcode\foreground\150127_foreground.png
文件 1302 2018-04-24 22:46 cvprcode\foreground\150127_foreground1.png
文件 1302 2018-04-24 22:46 cvprcode\foreground\150127_foreground2.png
文件 1715 2018-04-24 22:45 cvprcode\foreground\15359_foreground.png
文件 1613 2018-04-24 22:46 cvprcode\foreground\15359_foreground1.png
文件 1613 2018-04-24 22:46 cvprcode\foreground\15359_foreground2.png
文件 1893 2018-04-24 22:45 cvprcode\foreground\159048_foreground.png
文件 1801 2018-04-24 22:46 cvprcode\foreground\159048_foreground1.png
文件 1517 2018-04-24 22:46 cvprcode\foreground\159048_foreground2.png
文件 1914 2018-04-24 22:45 cvprcode\foreground\162962_foreground.png
文件 2310 2018-04-24 22:46 cvprcode\foreground\162962_foreground1.png
文件 2056 2018-04-24 22:46 cvprcode\foreground\162962_foreground2.png
文件 1873 2018-04-24 22:45 cvprcode\foreground\168405_foreground.png
文件 1908 2018-04-24 22:46 cvprcode\foreground\168405_foreground1.png
............此处省略428个文件信息
- 上一篇:数字滤波器的MATLAB与FPGA实现VHDL版
- 下一篇:揭秘跨境电商.mobi
评论
共有 条评论