net.semanticmetadata.lire
Class ImageSearcherFactory

java.lang.Object
  extended by net.semanticmetadata.lire.ImageSearcherFactory

public class ImageSearcherFactory
extends java.lang.Object

Searching in an Index

Use the ImageSearcherFactory for creating an ImageSearcher, which will retrieve the images for you from the index.

 IndexReader reader = IndexReader.open(indexPath);
 ImageSearcher searcher = ImageSearcherFactory.createDefaultSearcher();
 FileInputStream imageStream = new FileInputStream("image.jpg");
 BufferedImage bimg = ImageIO.read(imageStream);
 // searching for an image:
 ImageSearchHits hits = null;
 hits = searcher.search(bimg, reader);
 for (int i = 0; i < 5; i++) {
 System.out.println(hits.score(i) + ": " + hits.doc(i).getField(DocumentBuilder.FIELD_NAME_IDENTIFIER).stringValue());
 }
 

// searching for a document: Document document = hits.doc(0); hits = searcher.search(document, reader); for (int i = 0; i < 5; i++) { System.out.println(hits.score(i) + ": " + hits.doc(i).getField(DocumentBuilder.FIELD_NAME_IDENTIFIER).stringValue()); }

This file is part of the Caliph and Emir project: http://www.SemanticMetadata.net
Date: 03.02.2006
Time: 00:30:07

Author:
Mathias Lux, mathias@juggle.at

Field Summary
static int NUM_MAX_HITS
          Default number of maximum hits.
 
Constructor Summary
ImageSearcherFactory()
           
 
Method Summary
static ImageSearcher createColorOnlySearcher(int maximumHits)
          Returns a new ImageSearcher with the given number of maximum hits which only takes the overall color into account. texture and color distribution are ignored.
static ImageSearcher createDefaultCorrelogramImageSearcher(int maximumHits)
          Create and return an ImageSearcher for the AutoColorCorrelogram image feature.
static ImageSearcher createDefaultSearcher()
          Returns a new default ImageSearcher with a predefined number of maximum hits defined in the NUM_MAX_HITS
static ImageSearcher createFastCorrelogramImageSearcher(int maximumHits)
          Create and return an ImageSearcher for the AutoColorCorrelogram image feature.
static ImageSearcher createSimpleSearcher(int maximumHits)
          Creates a new simple image searcher with the desired number of maximum hits.
static ImageSearcher createWeightedSearcher(int maximumHits, float colorHistogramWeight, float colorDistributionWeight, float textureWeight)
          Returns a new ImageSearcher with the given number of maximum hits and the specified weights on the different matching aspects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_MAX_HITS

public static int NUM_MAX_HITS
Default number of maximum hits.

Constructor Detail

ImageSearcherFactory

public ImageSearcherFactory()
Method Detail

createSimpleSearcher

public static ImageSearcher createSimpleSearcher(int maximumHits)
Creates a new simple image searcher with the desired number of maximum hits.

Parameters:
maximumHits -
Returns:
the searcher instance

createDefaultSearcher

public static ImageSearcher createDefaultSearcher()
Returns a new default ImageSearcher with a predefined number of maximum hits defined in the NUM_MAX_HITS

Returns:
the searcher instance

createColorOnlySearcher

public static ImageSearcher createColorOnlySearcher(int maximumHits)
Returns a new ImageSearcher with the given number of maximum hits which only takes the overall color into account. texture and color distribution are ignored.

Parameters:
maximumHits - defining how many hits are returned in max (e.g. 100 would be ok)
Returns:
the ImageSearcher
See Also:
ImageSearcher

createWeightedSearcher

public static ImageSearcher createWeightedSearcher(int maximumHits,
                                                   float colorHistogramWeight,
                                                   float colorDistributionWeight,
                                                   float textureWeight)
Returns a new ImageSearcher with the given number of maximum hits and the specified weights on the different matching aspects. All weights should be in [0,1] whereas a weight of 0 implies that the feature is not taken into account for searching. Note that the effect is relative and can only be fully applied if the extensive DocumentBuilder is used.

Parameters:
maximumHits - defining how many hits are returned in max
colorHistogramWeight - a weight in [0,1] defining the importance of overall color in the images
colorDistributionWeight - a weight in [0,1] defining the importance of color distribution (which color where) in the images
textureWeight - defining the importance of texture (which edges where) in the images
Returns:
the searcher instance or NULL if the weights are not appropriate, eg. all 0 or not in [0,1]
See Also:
DocumentBuilderFactory

createDefaultCorrelogramImageSearcher

public static ImageSearcher createDefaultCorrelogramImageSearcher(int maximumHits)
Create and return an ImageSearcher for the AutoColorCorrelogram image feature. Be sure to use the same options for the ImageSearcher as you used for the DocumentBuilder.

Parameters:
maximumHits - number of hits returned.
Returns:

createFastCorrelogramImageSearcher

public static ImageSearcher createFastCorrelogramImageSearcher(int maximumHits)
Create and return an ImageSearcher for the AutoColorCorrelogram image feature. Be sure to use the same options for the ImageSearcher as you used for the DocumentBuilder.

Parameters:
maximumHits - number of hits returned.
Returns: