Reputation: 597
I am looking for a solution to easily compute the pixel coordinate from two images.
Question: If you take the following code, how could I compute the pixel coordinate that changed from the "QVector difference" ? Is it possible to have an (x,y) coordinate and find on the currentImage which pixel it represents ?
char *previousImage;
char *currentImage;
QVector difference<LONG>;
for(int i = 0 ; i < CurrentImageSize; i++)
{
//Check if pixels are the same (we can also do it with RGB values, this is just for the example)
if(previousImagePixel != currentImagePixel)
{
difference.push_back(currentImage - previousImage);
}
currentImage++;
}
EDIT: More information about this topic:
The main objective here is to clearly know what is the new value of a pixel that changed between the two images and to know which pixel is it (its coordinates)
Upvotes: 0
Views: 315
Reputation: 89232
There is not enough information to answer, but I will try to give you some idea.
You have declared char *previousImage;
, which implies to me that you have a pointer to the bytes representing an image. You need more than that to interpret the image.
Upvotes: 1
Reputation: 5087
From what I understand, you want compute the displacement or motion that occured between two images. E.g. for each pixel I(x, y, t=previous)
in previousImage
, you want to know where it did go in currentImage
, and what is his new coordinate I(x, y, t=current)
.
If that is the case, then it's called motion estimation and measuring the optical flow. There are many algorithms for that, who rely on more or less complex hypotheses, depending on the objects you observe in the image sequence.
The simpliest hypothesis is that if you follow a moving pixel I(x, y, t)
in the scene you observe, its luminance will remain constant over time. In other words, dI(x,y,t) / dt = 0
.
Since I(x, y, t)
is function of three parameters (space and time) with two unknowns, and there is only one equation, this is an ill defined problem that has no easy solution. Many of the algorithms add an additional hypothesis, so that the problem can be solved with a unique solution.
You can use existing libraries which will do that for you, one of them which is pretty popular is openCV.
Upvotes: 1