Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image comparison algorithm that ignores brightness

I am looking for an algorithm that I can use to compare two images and determine if there is something significantly different between the two. By "significant", I mean, if you took two photos of a room and a large spider was clearly on the wall in one of them, you'd be able to detect it. I am not really interested in WHAT is detected or even where - just that there is something different. The algorithm would need to ignore brightness. If the room gets brighter or darker during the day, the algorithm should ignore it.

Even if you don't know of an algorithm, any hints in the right direction would help.

Thanks!

like image 887
Johann Avatar asked Jan 21 '13 07:01

Johann


People also ask

What is brightness in image processing?

Instead, in terms of digital image processing, brightness is more properly described as the measured intensity of all the pixels comprising an ensemble that constitutes the digital image after it has been captured, digitized, and displayed.

How do you find the brightness of an image?

Compute the laplacian of the gray scale of the image. obtain the max value using minMacLoc. call it maxval. Estimate your sharpness/brightness index as - (maxval * average V channel values) / (average of the hist values from 0th channel), as said above.

How can you tell if two pictures are similar?

You can use the imagehash library to compare similar images. Since the images are not exactly the same, there will be some differences, so therefore we use a cutoff value with an acceptable maximum difference. That difference between the hash objects is the number of bits that are flipped.


1 Answers

I'd try to perform a high-pass filtering of your 2d-data.

According to Fourier, every signal can be transformed to "frequency space" by analyzing which frequencies are in the signal. This also applies to 2d-signals, like images.

By the means of a "high-pass-filter", you remove all low-frequency parts, like constant offsets and slow gradients. If applied to an image it can serve as a simple "edge detection" algorithm. Looking at a sample might make it easier to understand:

High-pass filtering of images

I took an image of a spider on a wall from somewhere on the web (top-left). I then decreased the brightness of this image (lower-left). For both versions, I applied a high-pass filter using GIMP (This plugin). For both input images, the output looks very similar.

My recommendation: First apply a high-pass filter, then look at differences.

Possible problems

As requested, here are some problems that I can imagine.

  • No sharp edges: if the object you want to detect doesn'T have sharp edges you probably will filter it out using HF-pass filtering. But what objects could that be? They must be huge, flat (to not produce shadows) and unstructured.

  • Only color differs, not brightness: If the object only differs in term of its color, but the brightness is the same as the background, the grayscale-conversion might be a problem. But if you run into this problem, just analyse the R, G, B-data separately, then at least one channel should help detecting the object - otherwise, you can't see it anyway.

Edit As reply to ???, if you also adjust the levels of the high-pass filtered image (which of course is all around 0.5*256) by just normalizing it to the range 0, 256 again you get

With adjusted levels

Which probably isn't worse than your result. But, HP-filters are simple and, when using FFT, very fast.

like image 110
Thorsten Kranz Avatar answered Oct 09 '22 09:10

Thorsten Kranz