码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • RootSIFT---SIFT图像特征的扩展


    RootSIFT是论文 Three things everyone should know to improve object retrieval - 2012所提出的

    在这里插入图片描述
    A Comparative Analysis of RootSIFT and SIFT Methods for Drowsy Features Extraction - 2020

    当比较直方图时,使用欧氏距离通常比卡方距离或Hellinger核时的性能差,但是在使用 SIFT 特征点为什么一直都使用欧氏距离呢?

    不论是对 SIFT 特征点进行匹配,还是对 SIFT 特征集合进行聚类得到视觉词汇表,又或者对图像进行BoW编码,都使用的是欧氏距离. 但是 SIFT 特征描述子本质上也是一种直方图,为什么对 SIFT 特征描述子进行比较的时候要使用欧氏距离呢,有没有一种更精确的比较方法呢?

    SIFT 描述子统计的是关键点邻域的梯度直方图.
    
    • 1

    论文作者认为之所以一直使用欧氏距离来测量 SIFT 特征的相似度,是由于在 SIFT 提出时,使用的是欧氏距离的度量,可以找出一种比较欧氏距离更为精确的度量方法. 故,提出了RootSift 对 SIFT 特征进行扩展.

    具体操作如下:

    在提取到 SIFT 描述向量 x x x 后,进行如下处理,即可得到 RootSIFT:

    [1] - 对特征向量 x x x 进行 l 1 l_1 l1​ 的归一化得到 x ′ x' x′ ;

    [2] - 对 x ′ x' x′的每一个元素求平方根;

    [3] - 进行 l 2 l_2 l2​归一化.(可选)

    • [3]中,是否进行l2归一化,有些不一致. 在[RootSIFT]论文 中并没有指出需要进行 l2 归一化,但是在 presentation, 却有 l2归一化.

    参考:图像检索(4):IF-IDF,RootSift,VLAD – RootSIFT

    1. RootSIFT 实现

    Python 实现如:

    • https://www.pyimagesearch.com/2015/04/13/implementing-rootsift-in-python-and-opencv/
    • https://github.com/jrosebr1/imutils/blob/master/imutils/feature/rootsift.py
    import numpy as np
    import cv2
    
    class RootSIFT:
        def __init__(self):
            # initialize the SIFT feature extractor
            #OpenCV2.4
            # self.extractor = cv2.DescriptorExtractor_create("SIFT")
                    #OpenCV3+
            self.extractor = cv2.xfeatures2d.SIFT_create()
            
        def compute(self, image, kps, eps=1e-7):
            # compute SIFT descriptors
            kps, descs = self.extractor.compute(image, kps)
    
            # if there are no keypoints or descriptors, return an empty tuple
            if len(kps) == 0:
                return ([], None)
    
            # apply the Hellinger kernel by first L1-normalizing and taking the
            # square-root
            descs /= (descs.sum(axis=1, keepdims=True) + eps)
            descs = np.sqrt(descs)
            #descs /= (np.linalg.norm(descs, axis=1, ord=2) + eps)
    
            # return a tuple of the keypoints and descriptors
            return (kps, descs)
    #
    image = cv2.imread("test.jpg")
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
     
    # detect Difference of Gaussian keypoints in the image
    sift = cv2.xfeatures2d.SIFT_create()
    kps, descs = sift.detectAndCompute(img1, None)
    print "SIFT: kps=%d, descriptors=%s " % (len(kps), descs.shape)
     
    # extract RootSIFT descriptors
    root_sift = RootSIFT()
    (kps, descs) = root_sift.compute(image, kps)
    print "RootSIFT: kps=%d, descriptors=%s " % (len(kps), descs.shape)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40

    C++ 实现:

    for(int i = 0; i < siftFeature.rows; i ++)
    {
        // Conver to float type
        Mat f;
        siftFeature.row(i).convertTo(f,CV_32FC1);
    
        normalize(f,f,1,0,NORM_L1); // l1 normalize
        sqrt(f,f); // sqrt-root  root-sift
        rootSiftFeature.push_back(f);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    2. 基于 RootSIFT 的相似图搜索

    在这里插入图片描述

  • 相关阅读:
    用HarmonyOS ArkUI来开发一个购物应用程序
    Echarts:双折线图的值一样,高度却不一样
    C++中冒号(:)、双冒号(::)的作用
    Docker系列--在容器中安装JDK的方法(有示例)
    【JDBC】-- PreparedStatement实现数据库查询操作
    Linux 命令行——文件查找:locate、find
    超越代写!5步教你轻松利用ChatGPT创作文本
    Flutter混合栈管理
    搞定面试官 - MySQL 中你知道如何计算一个索引的长度嘛?
    国内外17个学术论文网站推荐,记得收藏哦!
  • 原文地址:https://blog.csdn.net/T_T_T_T_/article/details/133831349
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号