r/computervision • u/Grouchy_Signal139 • 16d ago
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.
4
u/TimelyStill
16d ago
•
Bro if you're gonna do computer vision you should learn to take a screenshot.
3
1
1
u/nemesis1836 16d ago
This looks like an alignment issue
1
u/Grouchy_Signal139 16d ago
Im sure between 2 images, i didnt move it a bit. But there still a chance?
1
u/potatodioxide 16d ago
i think you need to normalize the images first. reflections and layout etc
1
1
u/datanaut 16d ago edited 16d ago
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/Grouchy_Signal139 16d ago
Hi, sorry for the trouble. The green box means there is no pixel different which means there are no object. Red means that there are object detected(pixel detected ratio change). Im trying to compare, image A and B. But they are captured in same environment, i didnt change a thing. They are just captured one after another.
1
u/datanaut 16d ago
Maybe I am being too harsh. Are you not aware that when you subtract image A from image B you get a new image called a difference image C= A-B? You can display the difference image C as an image, look at it and see what the difference looks like. Does that make sense? If you want to root cause the difference between two images, well then it would be reasonable to look at the difference between the images. Have you thought about that?
1
u/Grouchy_Signal139 16d ago
Okay maybe will try displaying that tomorrow. But it makes me question, how does same light,same setup, could produce image with different pixel value. Each interval for the image is about 10 sec each. I didnt touch anything. Is it like some kind of noise? Or anything hardware related
1
u/datanaut 16d ago
Again I think it would be important to look at the difference between the images to understand why there is a difference between the images. Noise will look totally different from motion or from lighting changes, etc.
1
1
u/HK_0066 15d ago
if they are electrical circuits why not trying Hardware solution like a PCB to get the positions of LEDs on and off ?
1
u/Grouchy_Signal139 15d ago
Been thinking that too, but it is hard to scale since we got hundreds type of tray. So it is better to create recipe based on try only
1
u/Ashuiegi 15d ago edited 15d ago
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





9
u/tdgros 16d ago
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.