Pysot和MATLAB画图给线条加标注符区分对比算法

画图一般我们都是通过颜色来区分对比算法,但是有些期刊需求是黑白印刷,颜色区分算法明显达不到要求的。所以本博客使用“线条形状”+“颜色”来区别对比算法。

1.Pysot加标注符
Pysot中的线条形状只有四种“-(实线),–(双虚线),-.(点虚线),:(虚线)”。
设置步骤:打开pysot-tookit之后点击pysot中的draw_utils.py,如下图
在这里插入图片描述
这个py文件中“LINE_STYLE”这个列表为线条形状,如下:
在这里插入图片描述
因为只有四种线型,当我们的对比算法超过四种时,线形就无法作为区别算法的主要因素了。这里给出解决步骤如下,以Pysot对OTB数据集作图为例:
1.同样在draw_utils.py这个文件中有“标记符”列表,如下:
在这里插入图片描述
列表中的符号代表了一些“三角,星号”之类的标记,具体想了解的大家去查一下,这里就不细说了。
2.打开pysot中visualization的draw_success_precision.py,如下:在这里插入图片描述
3.找到plt.plot(…)代码,加入marker=MARKER_STYLE[idx],代码中一共有三处这样的代码。当然别忘了开头的“from .draw_utils import COLOR, LINE_STYLE, MARKER_STYLE”

plt.plot(thresholds, np.mean(value, axis=0),
                 linestyle=LINE_STYLE[idx], color=COLOR[idx], marker=MARKER_STYLE[idx], label=label, linewidth=2, markersize=6)

4.点击运行eval.py就可以出图了,如下:
在这里插入图片描述
2.MATLAB加标注符
MATLAB和Pysot的基本情况一致,就不说废话了,直接上干货:
1.打开perfPlot.m这个文件,找到plotDrawStyle10处的代码在struct()中加入’Marker’,’ 标注符’。具体如下:
在这里插入图片描述
如果你对比的算法超过10个,需要改动的地方如下:

(1)、rankNum = 10; 这行代码就在这个m文件中。
(2)、在plotDrawStyleAll中加入’Marker’,‘标注符’。
2.打开utils中plotDrawSave.m文件,这里需要改动的地方在49行,修改结果如下:

h(i) = plot(thresholdSet,bb,'color',plotDrawStyle{i}.color, 'lineStyle', plotDrawStyle{i}.lineStyle,'Marker',plotDrawStyle{i}.Marker,'lineWidth', 2, 'Parent',axes1);

3.这时就可以点击运行perfPlot.m出图了:
在这里插入图片描述
4.跟踪的标注框,若也需要区别的话。我们可以加入标准,在for循环中用if语句来判断不同跟踪算法,去画不同的标注框,操作如下打开drawResultBB.m文件,找到下面这行代码:

for j=10:length(trks)

这行代码意思就是读取我们在confTracke.m中写入的所有算法。
下面呢,我们在下面这“LineStyle = plotDrawStyle{j}.lineStyle;”行代码下面加入我们if判断语句:
其中LineStyle可以设置线条形状:

 if j==1 
                switch resultsAll{j}.type
                    case 'rect'
                        rectangle('Position', resultsAll{j}.res(i,:), 'EdgeColor', plotDrawStyle{j}.color, 'LineWidth', LineWidth,'LineStyle','-');
                        continue;
                end
            end

与此类似,依次加入 if j==2 …等。补充一点,上文提到的标准具体内容为:六种,只介绍其中最常用两种,其它的看代码吧:

‘rect’: 矩形,存储的格式为[x y width height]
‘ivtAff’: 粒子滤波里面和放射变换有关的格式,1×6,可以组成一个2×3的仿射矩阵

然后我们看drawResultsBB.m里面的一段代码,如果想了解某个格式,顺着读下去就可以了

switch resultsAll{j}.type
                case 'rect'
                    rectangle('Position', resultsAll{j}.res(i,:), 'EdgeColor', plotDrawStyle{j}.color, 'LineWidth', LineWidth,'LineStyle',LineStyle);
                case 'ivtAff'
                    drawbox(resultsAll{j}.tmplsize, resultsAll{j}.res(i,:), 'Color', plotDrawStyle{j}.color, 'LineWidth', LineWidth,'LineStyle',LineStyle);
                case 'L1Aff'
                    drawAffine(resultsAll{j}.res(i,:), resultsAll{j}.tmplsize, plotDrawStyle{j}.color, LineWidth, LineStyle);                    
                case 'LK_Aff'
                    [corner c] = getLKcorner(resultsAll{j}.res(2*i-1:2*i,:), resultsAll{j}.tmplsize);
                    hold on,
                    plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
                case '4corner'
                    corner = resultsAll{j}.res(2*i-1:2*i,:);
                    hold on,
                    plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
                case 'SIMILARITY'
                    warp_p = parameters_to_projective_matrix(resultsAll{j}.type,resultsAll{j}.res(i,:));
                    [corner c] = getLKcorner(warp_p, resultsAll{j}.tmplsize);
                    hold on,
                    plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
                otherwise
                    disp('The type of output is not supported!')
                    continue;
            end
  这里对rect加入曲率,变成椭圆作为一种标准。具体代码如下:
      rectangle('Position',resultsAll{j}.res(i,:),'Curvature',[1 1],'EdgeColor', plotDrawStyle{j}.color,'linewidth',LineWidth,'LineStyle','-');

最后我们点击运行drawResultBB.m,结果如下:在这里插入图片描述

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值