I am using EmguCV and am trying to subtract 2 images to create a filter similar to AForge .NET's MoveTowards filter.
This is what my slightly modified version from the above URL tries to do. Given 2 images, the source and the overlay - it slowly moves the source image towards the overlay. It does this based on the following:
result = source + movementFactor * (overlay - source);
where result, source and overlay are images and movementFactor is the rate of change in the range 0 to 1.
When I tried this in code with movementFactor equal to 1, the results looked messed up (there was something like a motion trail). To test it further, I removed movementFactor from the above equation, and made result = source + overlay - source. I expected to see the overlay image as the result, which I did, but along with one region of the image that was flashing.
I am guessing that pixel intensities get clipped in the upper or lower bounds when addition/subtraction takes place.
I can accomplish what I want with this:
for (int i = 0; i < src.Height; i++)
{
for (int j = 0; j < src.Width; j++)
{
res[i, j] = new Gray(src[i, j].Intensity + movementFactor * (ovr[i, j].Intensity - src[i, j].Intensity));
}
}
But this significantly slows down the processing. How can I overcome the addition/subtraction problem or the speed problem with the above? Thanks for your answers!