Answer the question
In order to leave comments, you need to log in
Comparing the similarity of two images?
Hello colleagues!
I have never particularly encountered computer vision, but a simple, at first glance, task arose.
There is a camera that takes a picture at intervals, say once a minute, and adds it to the server.
I would like to have a process hanging on the server that browses the specified directory and, when a new snapshot appears, compares it with the previous one. If more or less significant changes have occurred in the image, do something.
Now the snag is, how do you tell if a snapshot has changed? Accurately counting by pixels is not an option. I'm not interested in a slightly twisted branch of a tree. But for example, a person passing close to the cameras is interesting. Or a car parked within the view of the camera. That is, I want to respond only to changes in more or less large objects.
Actually, what is the best way to calculate such changes, taking into account some error?
Answer the question
In order to leave comments, you need to log in
For example, one of the ways is to determine the area where changes can occur, for example, you are not interested in the sky and you do not consider pixels in height above a certain border, compress the image, for example, 10 times in height and width. You have a compressed cropped photo at time t and the second one at time t + 1, then you can get the brightness characteristic of each pixel color Y = 0.299 * R + 0.587 * G + 0.114 * B (this is to simplify the calculation a little), you will get two matrices from these brightness characteristics - one for photo t and the second for t + 1. Subtract the matrix t from the matrix t + 1, get the difference, get a set of elements that differ, with small changes there should be elements close to 0. Then you can already calculate the standard deviation, well, or come up with something.
The simplest task, in fact :)
1. Select the brightness channel (the formula was given by artyomst).
2. Press your megapixels down to a 100x75 mininail or something like that; in fact, even 36x24 will be enough here.
3. Compare the pixels of the penultimate and last image in pairs. The absolute value of the brightness difference ( abs(ab) ) will do just fine. You count the number of pixels whose brightness has changed by more than, say, 5 or 10 units. Smaller changes can be caused by camera noise and natural lighting changes over time.
4. See how many percent of your pixels have changed dramatically. If more than some limit percentage, say 1% or 5%, panic-panic turns on. But here it is already necessary to look at the situation, for a universal solution, this parameter must be taken out in the program settings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question