HPatches数据集(图像匹配)---3画出结果图(matlab2018b)

使用代码:

https://github.com/hpatches/hpatches-benchmark/tree/master/matlab

比如论文中的:

参考:

https://github.com/hpatches/hpatches-benchmark/tree/ench/matplotlib-fig/

https://github.com/hpatches/hpatches-benchmark/blob/master/matlab/res_article.m

matlab还需要matlab2tikz:

参考:

https://gist.github.com/ducha-aiki/5115026028f9ba1e6d384e15b391f85c

https://github.com/matlab2tikz/matlab2tikz

 

对orb sift brief deepdesc handnet rootsift描述符,计算评估结果,准备可视化,但是发现python没有可视化,那我们只能通过matlab了,下面的这些是python计算的,不能用于matlab

第一步:

下载vlfeat,版本vlfeat-0.9.20-bin.tar.gz

https://www.vlfeat.org/download/vlfeat-0.9.20-bin.tar.gz

解压放在hpatches-benchmark-master/matlab/vlfeat路径下

然后运行hb_setup.m

他会将vlfeat和hpatches-benchmark-master项目添加进matlab路径

后续就可以使用hb命令在matlab的命令行窗口

第二步:

matlab对路径要求很高

我们在目录中的data下软链接数据,因为我之前数据不放在这里的

这里大家千万别放在了matlab/data/下,

ln -s mageMatch_dataset/data/hpatches-release hpatches-release

ln -s ImageMatch_dataset/data/descriptors descriptors

这里我们已经通过直接下载或者python提取了各个算法的描述符

如果你想通过matlab提取,建议使用下面的命令

>> hb help
Usage: `hb COMMAND ...
 hb HPatches command line interface
   `hb help`
      Print this help string.
   `hb help COMMAND`
      Print a help string for a COMMAND.
 
   `hb dataset`
      Provision the HPatches dataset to `<hb_root>/data/hpatches_v1.1/`.
 
   `hb computedesc DESCNAME`
      Compute descriptor DESCNAME for patch images stored in
      `<hb_root>/data/hpatches_v1.1/`. Supported descriptors are:
 
      * sift, rootsift, meanstd, resize
 
      For your own descriptor, add a function DESCNAME to
      +desc/+feats/DESCNAME.m
 
   `hb all DESCNAME`
   `hb verification | matching | retrieval DESCNAME`
      Run all or selected benchmarks for a descriptor DESCNAME.
      Descriptor must be stored in `<hb_root>/data/descriptors/DESCNAME/`
      as  `SEQ_NAME/IMNAME.csv` in comma separated files (one descriptor
      per line).
      By default, stores the results in CSV files in:
      `<hb_root>/scores/<DESCNAME>/<BENCHNAME>.csv`
      If tresults file exist, the computation is skipped. Use
      `'override', true'` to overwrite existing score files. You can change
      the scores path with the `'scoresroot', 'newpath'` option.
 
      You can additionally configure the descriptor normalisation
      with `'norm', true`, see `hb help norm` for additional arguments.

Valid commands:
	all  verification  matching  retrieval  computedesc  packdesc  dataset  norm  

matlab暂时只支持sift等:

如果你想在matlab加入自己的desc提取算法,可直接放入该文件夹下:

/home/boyun/MATLAB/code/hpatches-benchmark-master/matlab/+desc/+feats/

其他不会的命令可以使用帮助,比如:packdesc

>> hb help packdesc
Help for hb command `packdesc`:
 pack Pack a descriptor to a zip file together with meta

 

第三步:

通过matlab进行评估

这样只能一个一个评估,想要快一点就是:

hb all sift

这条命令会同时在三个任务上评估sift的描述符

相当于运行了

hb verification sift

hb matching sift

hb retrieval sift

运行后默认会将文件存储在:

hpatches-benchmark-master/matlab/scores/default/sift/verification.csv

剩下的我们直接使用hb all sift进行评估,这里无需二次载入desc,因为第一次载入时候,已经将载入的desc写成了matlab方便读取的.mat文件放在了对应的desc文件夹下

而且由于我们刚刚已经计算了verification任务,这里代码会自动检测,如果存在就不进行二次计算

假设我们更改了sift的desc,就要把的sift/desc.mat删除

或者修改代码,不要载入之前的缓存:

假设更改desc后想重新计算某一个已经计算过的任务,两种方式,自己删了

或者让程序直接覆盖:

If tresults file exist, the computation is skipped. Use 'override', true' to overwrite existing score files.

说了那么多废话,我觉得自己删除最好

还有计算的任务评估结果,存放路径可以修改,默认是前面说的

hpatches-benchmark-master/matlab/scores/default

如果你想更改:

其他两个任务不截图了

第四步:

下载matlab2tikz

https://github.com/matlab2tikz/matlab2tikz

放在:

打开res_article.m

修改一些东西,符合我们现在的环境

首先:

%%
outpath = fullfile(hb_path, 'matlab', 'results', 'article');
vl_xmkdir(outpath);
fullfile(hb_path, '/matlab2tikz/src/')

还有,我们只有sift orb 而且没有pca-norm

关于这个怎么开启计算,使用

hb help norm:

Help for hb command `norm`:
 normdesc Descriptor normalisation
   normdesc is a helper wrapper used for descriptor normalisation. By
   default performs square root followed by L2 normalisation. normdesc
   renames the descriptor -> stores results in a new path.
 
   The order of the operations is (if enabled):
     Whitening -> Power law normalisation -> L2 Normalisation
 
   normdesc ... 'OptionName', 'OptionValue' can additionaly change:
 
   norm_split :: 'a'
     Selects a split used for learning the PCA/ZCA projection.
 
   whiten :: ''
     Either 'PCA' or 'ZCA' to enable PCA or ZCA whitening. Additionally
     uses the following options:
     clipeigen :: 0
       If not zero, clip all the lowest eigen values of the selected
       cumulative energy to its highest values [1]. E.g. with =1, sets all
       eigen values to be equal to the highest eigen value.
     epsilon :: 1e-6
       The minimum factor used for the division operator in the PCA/ZCA
       whitening. Similar effect as clipeigen.
     dimReduction :: inf
       Perform dimensionality reduction, if smaller than the descriptor
       dimensionality.
 
   pl :: 0.5
     Perform power-law normalisation of the given factor. E.g. with 0.5,
     uses the square root of the descriptor.
 
   l2norm :: true
     L2-normalise the descriptor to have magnitude of 1 in the L2 space,
     when true.
 
 
   [1] G. Hua, M. Brown, and S. Winder. Discriminant embedding
       for local image descriptors. In ICCV, pages 1–8. IEEE, 2007

hb help norm:

所以要注释一些东西:

除了sift orb其他一些算法的东西全部注释了

det_sets = {};

%只有原始
det_sets{end+1}.dets = baselines;
det_sets{end}.detnames = {bnames.printname};
det_sets{end}.name = 'baselines';

%只有pca-norm
%det_sets{end+1}.dets = baselines_pca;
%det_sets{end}.detnames = {bnames_pca.printname};
%det_sets{end}.name = 'baselines-pca';

%有原始+pca-norm
% det_sets{end+1}.dets = [baselines, baselines_pca];
% det_sets{end}.detnames = [{bnames.printname}, {bnames_pca.printname}];
% det_sets{end}.name = 'baselines-all';

%det_sets{end+1}.dets = [baselines, baselines_pca, baselines_chance];
%det_sets{end}.detnames = [{bnames.printname}, {bnames_pca.printname}, {baselines_chance.printname}];
%det_sets{end}.name = 'baselines-all-chance';

没弄好,但是雏形出来了

在文件hpatches-benchmark-master/matlab/results/article下有保存结果,但是暂时好像不对,无法用latex打开

用latex打开:

放入可运行代码段落

\documentclass[10pt,a4paper]{memoir} % <-- changed article to memoir
\usepackage[latin1]{inputenc}

\usepackage{pgfplots}
\pgfplotsset{every axis/.append style={
		label style={font=\footnotesize },
		label style={font=\footnotesize },
		tick label style={font=\footnotesize},  
		legend style={font=\miniscule},                     
}}

\usepackage{tikz}
\usepackage{amsmath}
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\newlength\fwidth
\newlength\fheight % not used in this example

\begin{document}
	
	\begin{figure}[htb]
		\begin{center}
			\setlength{\fwidth}{.7\linewidth} 
			\setlength{\fheight}{.7\linewidth} 

			\definecolor{mycolor1}{rgb}{0.17969,0.54297,0.33984}%
			\definecolor{mycolor2}{rgb}{0.00000,0.53125,0.21484}%
			\definecolor{mycolor3}{rgb}{0.36719,0.23438,0.59766}%
			\definecolor{mycolor4}{rgb}{0.78906,0.00000,0.12500}%
			\definecolor{mycolor5}{rgb}{0.52734,0.80469,0.91797}%
			%
			\begin{tikzpicture}
				%https://github.com/matlab2tikz/matlab2tikz/pull/604
				\begin{axis}[%
					width=0.951\fwidth,
					height=\fheight,
					at={(0\fwidth,0\fheight)},
					scale only axis,
					bar shift auto,
					clip=false,
					xmin=0,
					xmax=100,
					xlabel style={font=\color{white!15!black}},
					xlabel={Patch Retrieval mAP [\%]},
					y dir=reverse,
					ymin=0.6,
					ymax=2.4,
					ytick={1,2},
					yticklabels={{\textbackslash{}orb},{\textbackslash{}sift}},
					axis background/.style={fill=white},
					xmajorgrids,
					ymajorgrids,
					legend style={legend cell align=left, align=left, draw=white!15!black}
					]
					
					\addplot[xbar, bar width=0.8, fill=mycolor1, draw=white!20!black, area legend] table[row sep=crcr] {%
						41.9548209460414	2\\
					};
					\addplot[forget plot, color=white!15!black] table[row sep=crcr] {%
						0	0.6\\
						0	2.4\\
					};
					\addlegendentry{data1}
					
					\node[right, align=left]
					at (axis cs:101,2) {41.95\%};
					\addplot [color=mycolor2, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor2, mycolor2}]
					table[row sep=crcr]{%
						64.7063703472285	2\\
					};
					\addlegendentry{data2}
					
					\addplot [color=mycolor3, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor3, mycolor3}]
					table[row sep=crcr]{%
						38.1802387463562	2\\
					};
					\addlegendentry{data3}
					
					\addplot [color=mycolor4, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor4, mycolor4}]
					table[row sep=crcr]{%
						22.9778537445396	2\\
					};
					\addlegendentry{data4}
					
					\addplot[xbar, bar width=0.8, fill=mycolor5, draw=white!20!black, area legend] table[row sep=crcr] {%
						29.2544208148136	1\\
					};
					\addplot[forget plot, color=white!15!black] table[row sep=crcr] {%
						0	0.6\\
						0	2.4\\
					};
					\addlegendentry{data5}
					
					\node[right, align=left]
					at (axis cs:101,1) {29.25\%};
					\addplot [color=mycolor2, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor2, mycolor2}]
					table[row sep=crcr]{%
						50.0597027132659	1\\
					};
					\addlegendentry{data6}
					
					\addplot [color=mycolor3, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor3, mycolor3}]
					table[row sep=crcr]{%
						24.2959181262745	1\\
					};
					\addlegendentry{data7}
					
					\addplot [color=mycolor4, draw=none, mark size=1.5pt, mark=*, mark options={solid, fill=black!60!mycolor4, mycolor4}]
					table[row sep=crcr]{%
						13.4076416049004	1\\
					};
					\addlegendentry{data8}
					
					\end{axis}
					\end{tikzpicture}%
			\label{fig:someLabel}
			\caption{some Caption}
		\end{center}
	\end{figure}
	
\end{document}

说实话我肯定弄错了,但是大致样子和步骤差不多了

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值