Roberto Adarve
Roberto Adarve

Reputation: 167

Algorithm for sorting images by relevance

I'm developing a feature on a forum site that will allow to include a link and other type of content on a post (for clarifying the question or answer).

Related to the link feature implementation, I have several things to work on:

  1. Validate the URI entered (well formed, valid scheme, etc.)
  2. Validate that the remote resource exists
  3. Extract images from within the remote page
  4. Show to the user the set of images and let him choose one

Here comes the challenge. Previous to step 4, it would be great to sort this set of images in order of 'relevance'. I know that it's a goal quite ambiguous :-) but I can explain what I've gone through with the results given in step 4 and you will know why I'm dealing with this solution.

Many times, I get this kind of things into the set of images:

I decide to clean up this mess removing tiny images and sorting them by size, but I know that will be far away from a good solution.

Any ideas on that???

Thank you very much!

Upvotes: 3

Views: 810

Answers (2)

Alix Axel
Alix Axel

Reputation: 154603

You could sort by saturation (which is a good indicator of how interesting an image might be), take a look at the question "Image Classification - Detecting Floor Plans" for a sample implementation.

The hardest thing is separating image ads from regular images (since they are designed to look very interesting), to do this I suggest one or more of the following possible solutions:

  • ignore images that have standard dimensions of ads
  • query the page twice and ignore the images that change (ads tend to be dynamic)
  • ignore images hosted on external sites (watchout for CDNs!) or specific ad-serving URLs

To overcome the problem of duplicated images in resolution you could resize them all to a very low resolution (like 8x8 or 4x4) and if two or more images are alike ignore the small(er) one(s).

Upvotes: 2

Amber
Amber

Reputation: 527043

You might also want to sort images by where they're hosted - on-site hosted images first, off-site images second. Most ad images these days are served from 3rd-party servers, so oftentimes local images are the more relevant ones.

Upvotes: 0

Related Questions