简体   繁体   中英

I need to implement Image Indexing on a color palette using Lucene

Given a directory containing images only, I need to index the files using Lucene Indexing (using inverted indexing). Assuming we are provided with a tool to extract color percentage(not specific RGB percentage), how should I use the Lucene library so that when I query for images having green colour, I get the result set as Images having green color percentage in descending order?? How should I modify the Fields files? If I create a new ColorField File what can be its data-type to facilitate minimum changes? I also need to modify the analyzers files?

I would index the the percentages you want to search by as separate fields. Using an IntField , DoubleField , FloatField , LongField or similar, would probably make the most sense.

For instance:

Document doc = new Document();
doc.add(new StoredField("path",path));
doc.add(new FloatField("green",percentageGreen,Field.Store.NO));
doc.add(new FloatField("red",percentageRed,Field.Store.NO));
//etc.

The details, such as which numeric field to use, whether to store the percentages, etc. would depend on your requirements.

You could then search those percentages using a NumericRangeQuery , or Sort based on them with the appropriate IndexSearcher.search call , such as:

Sort sort = new Sort(new SortField("green",SortField.Type.FLOAT));
TopDocs docs = searcher.search(query,maxResults,sort);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM