Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Image Analysis?

Name: Anonymous 2008-05-02 0:10

Sup /prog/

I have a problem whereby I need to identify (with any degree of accuracy) whether or not an image is a resized version of another image. ``Resize'' is defined as a constant aspect-ratio downscale with (hopefully) a cubic sampling. I haven't been able to turn up any reasonable material on image analysis, which means I'm left to my own devices.

I think one viable option might be to consider the proportions of colors within the image. A ``color'', for my purposes, is defined as a set of three ranges (one range for each RGB channel). The algorithm would essentially go through each pixel, keeping a tally of how many of each color there are, then sort by occurance. Two images with similar proportions of the top 5 colors or so are flagged as identical.

The colors would necessarily be ranges because of the cubic sampling -- since one of the images is a downscaled version of another, the set of colors from the two images won't be the same. A pathological example: a large image consisting of alternating white and black pixels gets downscaled, the resultant image has gray -- a color which was not present in the original image.

I had some other weird ideas, like taking the diagonals, downscale one at runtime to fit the other, then compare the deltas.

I dunno. Anyone have ideas/suggestions/links?

Name: Anonymous 2008-05-02 10:04

>>25
Yeah, 7x7 of one channel would have about the same storage requirements as a 2x2 of RGB. My only concern would because this pretty explicitly splits the images into two groups (grayscale and RGB), the heuristic for discerning between them would have to be pretty accurate.

Most of the methods I can think of to determine whether an image is gray scale require much more granularity than just smushing it all together, simply because images with complementing colors will get smushed to gray too. Checking to see if every pixel is "close enough" to a pure gray is probably overkill.

The problem with checking too many pixels is that it's slow as hell to do with forced indentation, which means I'll end up writing a C module to do it. I'm using PIL for all the image heavy work (thumbnailing, interpolating down to 2x2 images, etc). Since PIL is written in C it's not unreasonably slow.

Any ideas on heuristics to determine between black & white images and RGB images with reasonable accuracy and speed? Basically, a good sampling method (since determining whether a pixel is gray is simple when it's a HSV tuple).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List