r/computervision • u/Grouchy_Signal139 • Oct 08 '26
Help: Project OpenCV template/pixel difference detection: why do false detections follow the same shape
I’m using OpenCV to compare a reference image of an empty tray with another image of the same empty tray.
There are no ICs/objects in either image, but when I use pixel difference (absdiff), I still get noticeable differences.
I’ve taken multiple images under the same setup, and the difference pattern seems to have a similar shape each time.
What could cause this? Is it mainly camera noise, lighting variation, or slight movement/alignment between the two images?
Any advice on how I should investigate this would be appreciated.





9
u/tdgros Oct 08 '26
I might be wrong, but it seems like the fake detections might be in the regions where the luminance is different: the center with a noticeable brightness bump and the glare on the bottom right. If this seems right to you, you could try another metric to find differences, one that is robust to coarse brightness changes like a normalized cross correlation (NCC).
If the images are not aligned, this is something you can visually check first. You can even simulate it: take your reference, move it around, run your test and see how your metrics behave. The way metrics will change depends on the content: smooth/blurry content will be affected less than content with large gradients, intuitively.
4
u/TimelyStill Oct 08 '26 •
Bro if you're gonna do computer vision you should learn to take a screenshot.
1
u/nemesis1836 Oct 08 '26
This looks like an alignment issue
1
u/potatodioxide Oct 08 '26
i think you need to normalize the images first. reflections and layout etc
1
u/datanaut Oct 08 '26 edited Oct 08 '26
You didn't really explain what you are doing, what red boxes mean, what green means, what the five images are, if they show anything different. And you didn't do the very obvious thing of display the diff image. You want us to root cause a diff image without showing us a diff image? How could we possibly know the difference between image A and image B if you only give us image A? (and a shitty picture of a monitor for image A)
I don't understand what help you think you can possibly get given the extremely limited information provided. If you just uploaded the images someone would have probably already solved the problem for you for free but you give this half assed explanation with some cell phone images of little to know value for solving the problem.
1
u/galvinw Oct 08 '26
Glare
1
u/Ashuiegi Oct 09 '26 edited Oct 09 '26
use pca , take one component of the ref image like the vertical one , use the horizontal one from the sample image and rebuild an image with it.
It should be less sensible to missalignement and good enough to see the ICs if you center well the detection window and make it a small as possible.
Since the pattern repeat you could look at DCT to detect the different pattern aswell.
But also try to fix the lighting and make a small alignement script with corner or line detection.
Dont use the flash for the pictures and use a diffuser in front of the light.
Pixel detection will be suceptible to change in lighting like a cloudy day could mess up the detection.
1
u/exitcactus Oct 12 '26
Light difference I guess
1
u/[deleted] Oct 09 '26
[removed] — view removed comment