5

I'm looking for a way to programatically identify if an image is likely to be a photograph vs an illustration/logo/diagram. The images are always JPEG's so I can't use the format metadata on it's own to differentiate (I've also looked at using the dimensions too but that hasn't helped in the scenario I'm working with where they are all of a similar ratio, they are also typically stripped of camera metadata already).

Specifically I want a way to screen out the <10% of images I come across which are not photographs, though the approach doesn't need to be full proof (if it works ~9 times out of 10, that would be a significant improvement over doing nothing).

I don't mind what programming language or platform a solution uses. It would be ideal to be able to use an existing high level library or an easily implementable (i.e. as few LoC as possible ;) low level approach that could be replicated in multiple languages. I'd also appreciate being pointed at examples of open source projects that do this, even if what they do is hacky.

I haven't had a great deal of luck searching for techniques for doing this. I note a number of search engines provide this option when searching through images, with varying degrees of success.

NB: I'm getting existing images from a range of sources, this is being done for R&D purposes and is in compliance with local copyright laws (before anyone asks).

If there aren't any libraries to do this I might end up writing one (maybe estimating probability based on max unique colours, solid blocks of colour, etc) but I'm hoping someone has published something useable for this already and I just haven't found it!

Iain Collins
  • 6,774
  • 3
  • 43
  • 43
  • 3
    Maybe have a look here http://stackoverflow.com/questions/26807303/how-can-i-automatically-determine-whether-an-image-file-depicts-a-photo-or-a-gr/26807785#26807785 – Mark Setchell Nov 09 '14 at 19:58
  • 2
    Have a look at the work of [Hany Farid](http://www.cs.dartmouth.edu/farid/). – Maurits Nov 09 '14 at 21:22
  • 1
    One thing I might consider would be to look for noise introduced by the image sensor. It should be different on each channel, which may make it easier to detect. JPEG compression may complicate things, though. Also, http://stackoverflow.com/questions/9354744/how-to-detect-if-an-image-is-a-photo-clip-art-or-a-line-drawing and http://birds-are-nice.me/programming/photo-art-class.shtml – Mitch Nov 09 '14 at 22:44
  • 1
    Thanks @MarkSetchell that very promising! I'll try the simple approach of looking for entropy first (then maybe colour counting) and will update with how I get on. Thanks also Mitch! – Iain Collins Nov 10 '14 at 10:09
  • 2
    Counting the number of distinct colours would work for many kinds of illustrations, logos and cartoons. prehaps convert the image from RGB to HSI (or HSV) format, allocated the hues to a suitable number of bins, and count how many bins are occupied. Illustrations may also contain fewer distinct saturation values. – Simon B Nov 10 '14 at 15:18
  • @MarkSetchell This ended up up being the right solution for us - thank you for pointing me at that! – Iain Collins Sep 21 '15 at 11:39

1 Answers1

1

Following on from what Maurits suggested in the second comment above, I had a look into Hany Farid's site which led me something he linked to.

Have a look at this service, it might be helpful.

http://www.izitru.com/

According to their site, they describe a service/tool that can analyze a file to determine how likely it is that the file is an original photograph or not. The returned result is what they call a 'trust rating'.

They appear to have an API which handles JPEG files

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Danoz
  • 977
  • 13
  • 24