LIRE(Lucene Image REtrieval)

zz from: http://hi.baidu.com/johnsoncr/blog/item/953d9f95f9aab9057af48078.html

 

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

官方网址:http://www.semanticmetadata.net/lire/

文档
 网址:www.semanticmetadata.net/wiki/doku.php

 

Creating an Index with Lire

Use the DocumentBuilderFactory to create a DocumentBuilder, for instance withDocumentBuilderFactory.getExtensiveDocumentBuilder(). Add images to an index using following steps:

  • With this  DocumentBuilder Lucene documents can be created from images, for instance with builder.createDocument(FileInputStream, String).
  • Eventually enrich the documents with your own data.
  • Add the document to an index.

For a really big index use .getFastDocumentBuilder() method from DocumentBuilderFactory, otherwise the.getDefaultDocumentBuilder() or the .getExtensiveDocumentBuilder(). Following MPEG-7 descriptors are used by the different DocumentBuilders:

  • Fast: ColorLayout
  • Default: ColorLayout and EdgeHistogram
  • Extensive: ColorLayout, EdgeHistogram and ScalableColor

For more information please consult the Java API Doc. Sample code is available in the sources, take a look at the JUnit test classes.

 

Sample Code

Note that the way of opening an index with the IndexReader and IndexWriter of Lucene has changed with Lucene 3.0. I assume to use LIRe v0.8, which already supports Lucene 3.0.1

 

Searching with Lire

Use the ImageSearcherFactory for creating an ImageSearcher, which will retrieve the images from the index. This can be done by calling ImageSearcherFactory.createDefaultSearcher(). The ImageSearcher will query for an image, given by an InputStream or a BufferedImage, or a Lucene Document describing an image, for instance with the method search(BufferedImage, IndexReader) or search(Document, IndexReader).

Please note that the ImageSearcher uses a Lucene IndexReader and does the retrieval with a linear search in the index. The results are returned as ImageSearchHits object, which aims to simulate a Lucene Hits object.

Note also that the IndexSearcher only uses image features, which are available in the specific Document in the index. If documents only have been indexed with the fast DocumentBuilder there is no ColorHistogram or EdgeHistogram feature available in the indexed documents, only the ColorLayout feature.

 

Searching with Weights

Within the ImageSearcherFactory one can use the method createWeightedSearcher(int maximumHits, float colorHistogramWeight, float colorDistributionWeight, float textureWeight) to adjust the weights for searching. Note that the extensive DocumentBuilder has to be used to build the index to discover the full potential of weighting.

Also note that only weights in [0,1] are allowed and the sum of the weights has to be greater than 0. 

 

 

 

Sample Code for a Simple Search Implementation

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值