detecting non-photographic imagery in .jpg files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: detecting non-photographic imagery in .jpg files

Post by fmw42 »

smagdali wrote:It's well known that the jpg format is optimised for photography, and that lineart is not really appropriate for it.

On our site, we have many users who upload lineart or illustration as jpgs anyway, which causes problems for us, and reduced quality for them.

My question is, is there a way to detect, using imagemagick, whether a particular jpg is actually a photo or not?

(I understand that, given the range of possible inputs, it might not be 100% accurate, but something would be better than nothing)

stef
If the images are mostly white, with black (or some color) lines and text, you could check the histogram or mean statistic to see what percentage is white and use that as a threshold. The distribution of other colors might also help refine your work.

See string formats for %[mean], %[min], %[max], %[standard-deviation] at http://www.imagemagick.org/script/escape.php

See histogram at http://www.imagemagick.org/Usage/files/#histogram


Can you post some examples of both situations --- photos vs line art?
Last edited by fmw42 on 2009-03-04T17:12:35-07:00, edited 2 times in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: detecting non-photographic imagery in .jpg files

Post by anthony »

I have some notes of ideas people have had on determine different types of images.
generaly so this was for image comparing but you have the same type of problem.

See Comparing Images, Sorting Images by Type
http://www.imagemagick.org/Usage/compare/#type_general

I would look specifically on Cartoon vs Real Life though not much is there.

If you or others have been practical ideas for categorizing images please post or mail me.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply