Comparing pictures with different light levels
March 23, 2022 4:56 PM   Subscribe

I have a bunch of images of the same objects from the same angle but at slightly different light levels. I'd like to identify pictures of the same objects -- I would normally use color histograms as a rough pass, but I'm unsure how to modify the histograms to adjust for different levels.

The obvious thing would be to express all of the histograms in terms of a common light level and compare them from there. But the how escapes me.

There are about 16,000 images so automation is key.
posted by Tell Me No Lies to Technology (5 answers total)
 
SIFT is out of patent and in OpenCV. I’d start there.
posted by Alterscape at 5:00 PM on March 23, 2022


Response by poster: In retrospect I just realized I can normalize the light level before I take the histograms.

SIFT is out of patent and in OpenCV. I’d start there.

I played with various feature recognition schemes for this, but comparing histograms (when the photos have the right light levels) has been by far the fastest and most accurate technique.
posted by Tell Me No Lies at 5:38 PM on March 23, 2022


Best answer: Well, you can pre-normalize the images and/or adjust the histogram afterwards. This will of course leave you with issues when you under/over expose.

Really I suppose what you’re looking for is similar histogram shapes, right? But illumination will cause a multiplicative effect and therefore stretch the histogram. So: take the log of the images before you histogram, which will cause illumination changes to have a constant shift. Then you can do a 1d cross correlation of histograms to determine match quality.

If that doesn’t work, going back to OpenCV, they have some object detectors in there that work around HOGs (histograms of oriented gradients). It’s quite reliable and might represent a nice midpoint between full computer vision land and basic histograms.
posted by Maecenas at 1:07 AM on March 24, 2022 [1 favorite]


Best answer: As noted by Maecenas, Pearson correlation is basically concerned with shape. A change in level shouldn't have an effect, but changing to get on a linear scale may help. Combining a correlation by color with a correlation by brightness might be better than color alone.

One thing you might experiment with is restricting the comparison by cropping the image on the theory that you will be using relatively less data that is not the desired object of the search.
posted by SemiSalt at 5:58 AM on March 24, 2022


I thought about this some more. I'm pretty good on programming and statistics, but not so good on the physics of light and the physiology of vision, so a lot of what follows is speculation, but I think it's pretty reasonable.

1) The color information in your files is probably some sort of RGB encoding, i.e. three numbers representing red, green, and blue. The numbers may be between 0 and 256. There are subtleties involved in this encoding to cope with the idiosyncrasies of human vision.

2) I assume your histograms are created by a function that changes RBG encoding to frequency values for different colors, or something equivalent to that. A quick search reveals that is more than one way to do this. Your histogram is a column chart with, say, 100 columns. Each column is assigned a range of frequencies, and the height is the number (or perhaps %) of cells with frequencies in that range. The width of each range is designed to have a non-confusing result, so, for instance, if the picture is of a color spectrum, the histogram values with be pretty even.

The conclusion that I draw from this is that the designer of the histogram program has probably already dealt with the kind of problem we had discussed in the previous answers.
posted by SemiSalt at 7:54 AM on March 25, 2022


« Older Am I selfish for wanting my father to wear clean...   |   Who asked, "Why don't they remake *bad* movies?" Newer »
This thread is closed to new comments.