Java 从Lire库筛选特征

Java 从Lire库筛选特征,java,sift,Java,Sift,我正试图为lire库找到一个sift实现。我唯一找到的就是上面的链接。我试图了解我要用什么来提取图像的筛选因子。 你知道我在这里要做什么吗? 我正在尝试类似于: Extractor e = new Extractor(); File img = new File("im.jpg"); BufferedImage in = ImageIO.read(img); BufferedImage newImage = new BufferedImage(in.getWidth()

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

 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);
提取器e=新提取器();
文件img=新文件(“im.jpg”);
BuffereImage in=ImageIO.read(img);
BuffereImage newImage=新的BuffereImage(在.getWidth()中,
在.getHeight()中,buffereImage.TYPE_BYTE_GRAY);
列表fs1=e.computeSiftFeatures(新图像);
系统输出打印LN(fs1);
但是我有一个空列表。

//这是修改后的答案,可能会有帮助
//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. */
公共类索引{ String directory=“your\u image\u dataset”; String index=“./images\uu idex”;//将索引放置在何处 /*如果要使用基于BOVW的搜索,可以更改 下面是数字,但要小心*/ int numClusters=2000;//可视单词数 int numdocfor词汇=200; /*用于可视化词汇表构建的示例数 此函数调用文档生成器和索引器函数(下面的索引文件) 对于数据集中的每个图像*/ public void IndexImage()引发IOException{ System.out.println(“-<获取文件到索引>----------------”; List images=FileUtils.getAllImages(新文件(目录),true); System.out.println(“-<索引“+图像.size()+”文件>----------------”; 索引文件(图像、索引); } /*此函数为传递给它的每个图像构建Lucene文档,以便 提取的视觉描述符*/ 私有void索引文件(列表图像、字符串索引) 抛出FileNotFoundException,IOException{ //第一高级结构 ChainedDocumentBuilder documentBuilder=新的ChainedDocumentBuilder(); //这里要创建的文档类型我包括了不同类型的视觉特征, //addBuilder(新的SurfDocumentBuilder()); //在这里选择冲浪或筛选 addBuilder(新的SiftDocumentBuilder()); documentBuilder.addBuilder(DocumentBuilderFactory.getEdgeHistogramBuilder()); documentBuilder.addBuilder(DocumentBuilderFactory.getjcdocumentbuilder()); documentBuilder.addBuilder(DocumentBuilderFactory.getColorLayoutBuilder()); //IndexWriter为索引存储创建文件 IndexWriter iw=lucenutils.createIndexWriter(index,true); 整数计数=0; /*然后在创建的文档结构上调用数据集中的每个图像 (documentBuilder),并通过构造定义的 (文件结构)*/ 用于(字符串标识符:图像){ 文档文档=documentBuilder.createDocument(新建 FileInputStream(标识符),标识符); iw.addDocument(doc);//将文档添加到索引 iw.close();//关闭索引编写器 /*为了进行搜索,您将读取索引,并通过构造 IndexReader她定义了Lire中可用的不同搜索策略 请检查支架并测试它*/
//这是修改后的答案,可能会有帮助
公共类索引{
String directory=“your\u image\u dataset”;
String index=“./images\uu idex”;//将索引放置在何处
/*如果要使用基于BOVW的搜索,可以更改
下面是数字,但要小心*/
int numClusters=2000;//可视单词数
int numdocfor词汇=200;
/*用于可视化词汇表构建的示例数
此函数调用文档生成器和索引器函数(下面的索引文件)
对于数据集中的每个图像*/
public void IndexImage()引发IOException{
System.out.println(“-<获取文件到索引>----------------”;
List images=FileUtils.getAllImages(新文件(目录),true);
System.out.println(“-<索引“+图像.size()+”文件>----------------”;
索引文件(图像、索引);
}
/*此函数为传递给它的每个图像构建Lucene文档,以便
提取的视觉描述符*/
私有void索引文件(列表图像、字符串索引)
抛出FileNotFoundException,IOException{
//第一高级结构
ChainedDocumentBuilder documentBuilder=新的ChainedDocumentBuilder();
//这里要创建的文档类型我包括了不同类型的视觉特征,
//addBuilder(新的SurfDocumentBuilder());
//在这里选择冲浪或筛选
addBuilder(新的SiftDocumentBuilder());
documentBuilder.addBuilder(DocumentBuilderFactory.getEdgeHistogramBuilder());
documentBuilder.addBuilder(DocumentBuilderFactory.getjcdocumentbuilder());
documentBuilder.addBuilder(DocumentBuilderFactory.getColorLayoutBuilder());
//IndexWriter为索引存储创建文件
IndexWriter iw=lucenutils.createIndexWriter(index,true);
整数计数=0;
/*然后在创建的文档结构上调用数据集中的每个图像
(documentBuilder),并通过构造定义的
(文件结构)*/
用于(字符串标识符:图像){
文档文档=documentBuilder.createDocument(新建
FileInputStream(标识符),标识符);
iw.addDocument(doc);//将文档添加到索引
iw.close();//关闭索引编写器
/*为了进行搜索,您将读取索引,并通过构造
IndexReader她定义了Lire中可用的不同搜索策略
请检查支架并测试它*/

请您在回答中进一步展开。我正在尝试使用LIRE提取SIFT关键点的描述符。我使用了extractor.computeSiftFeatures并获得了一些浮点值,但我不知道它们是什么,不,我找不到该函数的功能。此外,您提到我们需要一个文档生成器,您能解释一下原因吗?请您展开m我正在尝试使用LIRE提取SIFT关键点的描述符。我使用extractor.computeSiftFeatures并获得一些浮点值b