【问题标题】:Sift features from Lire library从 Lire 库中筛选特征
【发布时间】:2014-03-17 22:40:11
【问题描述】:

我正在尝试为 lire 库找到一个 sift 实现。我唯一找到的是上面的链接feature。我试图了解我必须使用什么来提取图像的筛选特征。 知道我要在这里做什么吗? 我正在尝试类似:

 Extractor e = new Extractor();
    File img = new File("im.jpg");
    BufferedImage in = ImageIO.read(img);
    BufferedImage newImage = new BufferedImage(in.getWidth(),
            in.getHeight(), BufferedImage.TYPE_BYTE_GRAY);

     List<Feature> fs1 = e.computeSiftFeatures(newImage);
     System.out.println(fs1);

但我有一个空列表。

【问题讨论】:

    标签: java sift


    【解决方案1】:
    //Here is the revised answer for you it may help
    
    public class indexing {
    
        String directory="your_image_dataset";
        String index="./images__idex";//where you will put the index
    
       /* if you want to use BOVW based searching you can change the 
       numbers below but be careful */
         int numClusters = 2000; // number of visual words
         int numDocForVocabulary = 200; 
    
        /* number of samples used for visual words vocabulary building    
       this function calls the document builder and indexer function (indexFiles below)
       for each image in the data set */
    
      public void IndexImage() throws IOException{
          System.out.println("-< Getting files to index >--------------");
          List<String> images = FileUtils.getAllImages(new File(directory), true);
          System.out.println("-< Indexing " + images.size() + " files >--------------");
          indexFiles(images, index);    
    }
    /* this function builds Lucene document for each image passed to it for
    the extracted visual descriptors */
    
    private void indexFiles(List<String> images, String index) 
    throws FileNotFoundException, IOException {       
    
     //first high level structure 
    ChainedDocumentBuilder documentBuilder = new ChainedDocumentBuilder();
    //type of document to be created here i included different types of visual features,    
    //documentBuilder.addBuilder(new SurfDocumentBuilder());
    //here choose either Surf or SIFT 
    documentBuilder.addBuilder(new SiftDocumentBuilder());
    documentBuilder.addBuilder(DocumentBuilderFactory.getEdgeHistogramBuilder());
    documentBuilder.addBuilder(DocumentBuilderFactory.getJCDDocumentBuilder());
    documentBuilder.addBuilder(DocumentBuilderFactory.getColorLayoutBuilder());
    
    //IndexWriter creates the file for index storage 
    IndexWriter iw = LuceneUtils.createIndexWriter(index, true);
    int count = 0;
    /*then each image in data set  called up on the created document structure
       (documentBuilder above and added to the index file by constructing the defined 
       document structure) */
    
     for (String identifier : images) {
        Document doc = documentBuilder.createDocument(new 
        FileInputStream(identifier), identifier);
    
        iw.addDocument(doc);//adding document  to index
        iw.close();// closing the index writer
    
    /*  For searching purpose you will read the index and by constructing an instance of 
      IndexReader she you defined different searching strategy which is available in Lire
      Please check the brace and test it. */
    

    【讨论】:

    • 您能否详细说明您的答案。我正在尝试使用 LIRE 提取 SIFT 关键点的描述符。我使用了 extractor.computeSiftFeatures 并得到了一些浮点值,但我不知道它们是什么,也不知道这个函数的作用。您还提到我们需要一个文档生成器,您能解释一下原因吗?
    猜你喜欢
    • 2015-02-26
    • 2012-04-10
    • 2017-10-13
    • 2016-03-16
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 2014-07-23
    • 2018-06-01
    相关资源
    最近更新 更多