码农知识堂 - 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 的相似图搜索

    在这里插入图片描述

  • 相关阅读:
    企业架构LNMP学习笔记49
    python之图形用户界面,如何安装wxPython
    如何将 Docker 镜像大小从 1.43 GB 减少到 22.4 MB
    万圣节习俗南瓜灯Jack-o’-lantern!
    MicroPython Server网页LED开关
    【C++编程能力提升】
    Android——gradle构建知识片-散装版
    JavaWeb的基本概念
    文件加密,数据防泄密软件
    【JAVA学习笔记】64 - 坦克大战1.4,限制坦克发射子弹,敌方击中我方坦克爆炸
  • 原文地址:https://blog.csdn.net/T_T_T_T_/article/details/133831349
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号