org.imageterrier.locfile
Class QLFDocument<F extends org.openimaj.feature.local.quantised.QuantisedLocalFeature<?>>

java.lang.Object
  extended by org.imageterrier.locfile.QLFDocument<F>
Type Parameters:
F -
All Implemented Interfaces:
org.terrier.indexing.Document

public class QLFDocument<F extends org.openimaj.feature.local.quantised.QuantisedLocalFeature<?>>
extends Object
implements org.terrier.indexing.Document

A concrete Document implementation for documents built up of a list of visual terms in the form of QuantisedLocalFeatures.

Author:
Jonathon Hare

Nested Class Summary
protected  class QLFDocument.DistEntry
           
 
Field Summary
protected  F current
           
protected  List<F> featureList
           
protected  Iterator<F> iterator
           
protected  Map<String,String> props
           
protected  String termPrefix
           
protected  String termSuffix
           
 
Constructor Summary
QLFDocument(byte[] bytes, Class<F> clz, String docno, Map<String,String> extraProps)
          Construct a new QLFDocument instance from the contents of the given byte array.
QLFDocument(File file, Class<F> clz, String docno, Map<String,String> extraProps)
          Construct a new QLFDocument instance from the contents of the given file.
QLFDocument(List<F> list, String docno, Map<String,String> extraProps)
          Construct a new QLFDocument instance from the contents of the given feature list.
 
Method Summary
 boolean endOfDocument()
           
 void filter(org.openimaj.math.geometry.shape.Rectangle rect)
          Convenience methods to filter all features that have spatial locations outside the given rectangle.
 Map<String,String> getAllProperties()
           
 int[] getCurrentNearestNeighbourTIds(int limit)
          Get the spatially nearest neighbouring terms to the current term.
 int[] getCurrentNearestNeighbourTIdsKD(int limit)
          Get the spatially nearest neighbouring terms to the current term.
 List<F> getEntries()
          Get the underlying list of features.
 Set<String> getFields()
           
 org.openimaj.feature.local.Location getLocation()
          Get the location associated with the current term pointer.
 List<F> getNearestNeighbours(F target, int nNeighbours)
          Get the spatially nearest neighbouring terms to the target term.
 int[] getNearestNeighboursKD(F target, int nNeighbours)
          Get the spatially nearest neighbouring terms to the target term.
 String getNextTerm()
           
 String getProperty(String name)
           
 Reader getReader()
           
 void reset()
          Reset the document to its default state, with the current term pointer just before the first term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureList

protected List<F extends org.openimaj.feature.local.quantised.QuantisedLocalFeature<?>> featureList

iterator

protected Iterator<F extends org.openimaj.feature.local.quantised.QuantisedLocalFeature<?>> iterator

props

protected Map<String,String> props

termPrefix

protected String termPrefix

termSuffix

protected String termSuffix

current

protected F extends org.openimaj.feature.local.quantised.QuantisedLocalFeature<?> current
Constructor Detail

QLFDocument

public QLFDocument(File file,
                   Class<F> clz,
                   String docno,
                   Map<String,String> extraProps)
            throws IOException
Construct a new QLFDocument instance from the contents of the given file. The file contents must be compatible with FileLocalFeatureList.

Parameters:
file - the file to read
clz - the class of QuantisedLocalFeature.
docno - the document identifier or number
extraProps - a map of properties to store in the metadata index
Throws:
IOException

QLFDocument

public QLFDocument(byte[] bytes,
                   Class<F> clz,
                   String docno,
                   Map<String,String> extraProps)
            throws IOException
Construct a new QLFDocument instance from the contents of the given byte array. The byte array contents must be compatible with MemoryLocalFeatureList.

Parameters:
bytes - an array of bytes from which to read the features.
clz - the class of QuantisedLocalFeature.
docno - the document identifier or number
extraProps - a map of properties to store in the metadata index
Throws:
IOException

QLFDocument

public QLFDocument(List<F> list,
                   String docno,
                   Map<String,String> extraProps)
Construct a new QLFDocument instance from the contents of the given feature list.

Parameters:
list - the feature list
docno - the document identifier or number
extraProps - a map of properties to store in the metadata index
Method Detail

getNextTerm

public String getNextTerm()
Specified by:
getNextTerm in interface org.terrier.indexing.Document

getFields

public Set<String> getFields()
Specified by:
getFields in interface org.terrier.indexing.Document

endOfDocument

public boolean endOfDocument()
Specified by:
endOfDocument in interface org.terrier.indexing.Document

getReader

public Reader getReader()
Specified by:
getReader in interface org.terrier.indexing.Document

getProperty

public String getProperty(String name)
Specified by:
getProperty in interface org.terrier.indexing.Document

getAllProperties

public Map<String,String> getAllProperties()
Specified by:
getAllProperties in interface org.terrier.indexing.Document

getEntries

public List<F> getEntries()
Get the underlying list of features.

Returns:
the feature list

filter

public void filter(org.openimaj.math.geometry.shape.Rectangle rect)
Convenience methods to filter all features that have spatial locations outside the given rectangle. It is assumed that the 0th ordinate of the feature location is the x-ordinate, and the 1st is the y ordinate.

Parameters:
rect - the rectangle.

reset

public void reset()
Reset the document to its default state, with the current term pointer just before the first term.


getLocation

public org.openimaj.feature.local.Location getLocation()
Get the location associated with the current term pointer.

Returns:
the current location.

getNearestNeighbours

public List<F> getNearestNeighbours(F target,
                                    int nNeighbours)
Get the spatially nearest neighbouring terms to the target term. It is assumed that the 0th ordinate of the feature location is the x-ordinate, and the 1st is the y ordinate.

Parameters:
target - the target term.
nNeighbours - the number of neighbours.
Returns:
a list of neighbouring terms

getCurrentNearestNeighbourTIds

public int[] getCurrentNearestNeighbourTIds(int limit)
Get the spatially nearest neighbouring terms to the current term. It is assumed that the 0th ordinate of the feature location is the x-ordinate, and the 1st is the y ordinate.

Parameters:
limit - the number of neighbours.
Returns:
an array of neighbouring terms ids

getNearestNeighboursKD

public int[] getNearestNeighboursKD(F target,
                                    int nNeighbours)
Get the spatially nearest neighbouring terms to the target term. It is assumed that the 0th ordinate of the feature location is the x-ordinate, and the 1st is the y ordinate. This method uses an underlying KD-Tree to speed the neighbour operation.

Parameters:
target - the target term.
nNeighbours - the number of neighbours.
Returns:
a list of neighbouring terms

getCurrentNearestNeighbourTIdsKD

public int[] getCurrentNearestNeighbourTIdsKD(int limit)
Get the spatially nearest neighbouring terms to the current term. It is assumed that the 0th ordinate of the feature location is the x-ordinate, and the 1st is the y ordinate. This method uses an underlying KD-Tree to speed the neighbour operation.

Parameters:
limit - the number of neighbours.
Returns:
an array of neighbouring terms ids


Copyright © 2011 The University of Southampton. All Rights Reserved.