compare two pictures of color

asked 2020-07-26 07:17:32 -0500

bgengine gravatar image

updated 2020-07-29 09:45:28 -0500


Whats the best method to compare two pictures of mainly black color , (or two pictures of mainly red color) I'm looking at a specific location on an image and am hoping to see a black colored wire ( or a red coloured wire) in that location. If the wire is not in that location i would see either a gray backround (or a green backround if looking for red cable) .

What I want to ensure is every time I check the location I see a Black shade ( which indicates a Black wire) and must ensure there is no gray backround seen. If all gray background is seen then this indicates the wire is not present if some gray background is seen then this indicates the wire might be present , but is not in the exact correct location.

Bearing in mind that in my picture Black can sometimes how up as dark gray, what the best way to distinguish between the cable and the background and whats the best method to ensure there is no background in the image.

I'm looking at template match , but from what i see it does not quite compare colors.

Can I get the average of value of colors in an image and do a comparision against a master image ? how could I do this ? would it work ?

all help greatly appreciated thanks



The Picture above has black wires turning at an almost 90 degree angle, this is bad. The first picture has wires turning gradually , this is good.

I'd like to inspect each and ensure the wires turn gradually, and indicate a filure if they do not.

I was thinking of first identifying and location the component ( shown in Green below) and then selecting 2 X ROI relative to that green area. shown in red. THen compare the color in these read boxes against the colors of of the backgrounds ( with no wires) ... is this possible how could i do it ? I know hoe to identify the 2 X ROI but not sure how i can compare the colors . Also, one red box has a backround that is very similiar to the cable.


edit retag flag offensive close merge delete


you probably should show your images here ;)

berak gravatar imageberak ( 2020-07-26 07:22:10 -0500 )edit

Indeed. Please post your images.

sjhalayka gravatar imagesjhalayka ( 2020-07-26 20:32:03 -0500 )edit

To start you off with: to find the difference between two images, you can use subtraction (subtraction is literally, the difference operator, like how addition is the sum operator).

sjhalayka gravatar imagesjhalayka ( 2020-07-26 21:09:59 -0500 )edit

Hi , Yes, Sorry , have just added the pictures now.

all suggestions most welcome

bgengine gravatar imagebgengine ( 2020-07-29 09:34:33 -0500 )edit

1st thing to do - fix both camera & board, so you get exactly the same image roi

berak gravatar imageberak ( 2020-07-29 10:41:38 -0500 )edit