`

LIRE的使用:创建索引

阅读更多

LIRE(Lucene Image REtrieval)提供一种的简单方式来创建基于图像特性的Lucene索引。利用该索引就能够构建一个基于内容的图像检索(content- based image retrieval,CBIR)系统,来搜索相似的图像。LIRE使用的特性都取自MPEG-7标准: ScalableColor、ColorLayout、EdgeHistogram。

 

使用DocumentBuilderFactory 创建 DocumentBuilder,例如DocumentBuilderFactory.getCEDDDocumentBuilder()

将图片加入索引index 需要以下2步:

  • 使用 DocumentBuilder 创建Document:builder.createDocument(FileInputStream, String).(第一个参数是图片文件)
  • 将document 加入 index.

 LIRE支持很多种的特征值。具体可以看 DocumentBuilderFactory 类的源代码。也可以使用 ChainedDocumentBuilder 同时使用多种特征值。

创建索引的方法如下代码所示

/**
 * Simple index creation with Lire
 *
 * @author Mathias Lux, mathias@juggle.at
 */
public class Indexer {
    public static void main(String[] args) throws IOException {
        // Checking if arg[0] is there and if it is a directory.
        boolean passed = false;
        if (args.length > 0) {
            File f = new File(args[0]);
            System.out.println("Indexing images in " + args[0]);
            if (f.exists() && f.isDirectory()) passed = true;
        }
        if (!passed) {
            System.out.println("No directory given as first argument.");
            System.out.println("Run \"Indexer <directory>\" to index files of a directory.");
            System.exit(1);
        }
        // Getting all images from a directory and its sub directories.
        ArrayList<String> images = FileUtils.getAllImages(new File(args[0]), true);
 
        // Creating a CEDD document builder and indexing al files.
        DocumentBuilder builder = DocumentBuilderFactory.getCEDDDocumentBuilder();
        // Creating an Lucene IndexWriter
        IndexWriterConfig conf = new IndexWriterConfig(LuceneUtils.LUCENE_VERSION,
                new WhitespaceAnalyzer(LuceneUtils.LUCENE_VERSION));
        IndexWriter iw = new IndexWriter(FSDirectory.open(new File("index")), conf);
        // Iterating through images building the low level features
        for (Iterator<String> it = images.iterator(); it.hasNext(); ) {
            String imageFilePath = it.next();
            System.out.println("Indexing " + imageFilePath);
            try {
                BufferedImage img = ImageIO.read(new FileInputStream(imageFilePath));
                Document document = builder.createDocument(img, imageFilePath);
                iw.addDocument(document);
            } catch (Exception e) {
                System.err.println("Error reading image or indexing it.");
                e.printStackTrace();
            }
        }
        // closing the IndexWriter
        iw.close();
        System.out.println("Finished indexing.");
    }
}

 原文:

http://www.semanticmetadata.net/wiki/doku.php?id=lire:createindex

1
2
分享到:
评论

相关推荐

    lire 图片索引工具

    结合lucene,开发搜图片的搜索自动陪陪图片相似度。

    LIRE-CIBR:测试使用 LIRE 库为基于内容的图像检索创建基于 Lucene 的检索索引

    里拉-CIBR 测试使用 LIRE 库为基于内容的图像检索创建基于 Lucene 的检索索引 这是我的项目,我想在其中使用一些基于内容的图像检索。 我使用了 LIRE 库并修改了内容以适合我的领域

    LireDemo (LIRE的例子)

    LIRE(Lucene Image REtrieval)提供一种的简单方式来创建基于图像特性的Lucene索引。LIRE使用的特性都取自MPEG-7标准: ScalableColor、ColorLayout、EdgeHistogram。 这是一个完整的例子程序。

    LIRE:开源库,用于基于内容的图像检索,视觉信息检索

    LIRE(Lucene图像检索)是一个基于内容的图像检索的开源库,这意味着您可以使用LIRE来实现搜索外观相似图像的应用程序。 除了提供多种通用和最新的检索机制外,LIRE还允许在多个平台上轻松使用。 LIRE被积极地用于...

    LIRE 源代码

    LIRE(Lucene Image REtrieval)提供一种的简单方式来创建基于图像特性的Lucene索引。利用该索引就能够构建一个基于内容的图像检索(content- based image retrieval,CBIR)系统,来搜索相似的图像。LIRE使用的特性都...

    LIRE-0.9.5

    LIRE(Lucene Image REtrieval)提供一种的简单方式来创建基于图像特性的Lucene索引。利用该索引就能够构建一个基于内容的图像检索(content- based image retrieval,CBIR)系统,来搜索相似的图像。LIRE使用的特性都...

    Lire图片搜索示例

    lire 图片检索

    最新LIRE以图找图 java实例

    最新LIRE以图找图 java实例。先通过indexer产生索引,再通过searcher和源图片比对相似度。输出值在30以下未相似图片

    基于Lire库搜索相似图片源码

    使用Lire来进行图片的搜索示例代码,包括创建索引和搜索。博客链接:https://blog.csdn.net/u010889616/article/details/81155701

    基于lire的图片搜索功能demo.zip

    基于lire的图片搜索功能demo,代码简洁高效,免费开源。

    lire图片搜索图片样例

    通过lire工具,进行图片搜索图片的样例,先通过indexer产生索引,再通过searcher和源图片比对相似度。输出值在30以下未相似图片

    Lire图片检索

    Lire是基于Lucene而开发的一个开源的图片检索引擎,功能强大。

    LIRE(Lucene Image REtrieval)最新开发包

    LIRE(Lucene Image REtrieval)提供一种的简单方式来创建基于图像特性的Lucene索引。利用该索引就能够构建一个基于内容的图像检索(content- based image retrieval,CBIR)系统,来搜索相似的图像,提取图像特征,...

    lire图形检索

    LIRE有一套比较成熟的API,依附于Lucene实现。其中利用这个DocumentBuilder是建立Document的接口类,Document就是lucene中的文档,它建立的文档包含了图像的某个特征和图像的标识字符串两个Field。通过调用create...

    ParllImgProc:使用 LIRE 的图像数据库特征提取管道

    组件LIRE:luecene 图像检索库 JAVACV:openCV 应用程序的 java 包装器。 Hadoop:并行处理框架测试数据集: 待执行算法的待办事项清单-- 边缘检测器 Harris Canny Sobel Laplacian-- 斑点检测器 LoG DoG MSER-- ...

    image-similarity-with-lire:图像相似度

    有图像的图像相似性这是我的旧博客文章的源代码,请参阅

    mpeg 7 demo(LIRE)

    JAVA 实现的mpeg7标准的demo

    elasticsearch-image-1.0-SNAPSHOT.zip elasticsearch插件 以图搜图 LIRE

    使用方法:将插件解压到elasticsearch 的plugins目录下即可。 存储数据时 ColorLayout surfFeature = new ColorLayout(); surfFeature.extract(ImageIO.read(imgfilepath)); JSONObject o = new JSONObject(); o....

    Images similarities searcher:首先按内容对图像进行索引,然后在索引中搜索相似性-开源

    基于Lire和Lucene的JavaFX GUI。 首先按内容对图像进行索引,然后在... LIRE:http://www.semanticmetadata.net/lire/ LUCENE:http://lucene.apache.org/core/控制台模式,设计为易于解析器分析的输出(安静模式)。

    lire获取index

    lire如何获取检索用的index,方便下一步检索用,注意编译运行的java环境是java1.7版本的

Global site tag (gtag.js) - Google Analytics