← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242881]: How to differentiate 2 similar images based on color???

 

Question #242881 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/242881

Eugene S proposed the following answer:
When trying to find a solution to similar problem I have noticed that
often there are slight differences in similarity coefficient in 2
similar images of different color.

So what you can do is that:
1. Create a pattern of one of the images. For example "image1.png"
2. Locate it on the screen (within the relevant region), for example:
   find("something.png").nearby(x).find("image1.png)

You will get something like that:
   M[529,157 123x10]@S(0)[0,0 1280x1024] S:1.00 Center:590,162 for 1.0 secs

3. Take a note of whatever value appears in the Similarity (S) field.
4. Now use the same pattern to find the other image (for esxample "image2.png").
5. Again, take a look at whatever value is appearing in the Similarity (S) field. 

At this stage, hopefully, you will see that the similarity value is slightly different that 1.00. For example:
   M[512,134 123x10]@S(0)[0,0 1280x1024] S:0.97 Center:570,142 for 1.0 secs

Now, you can exploit the fact that there is a difference between the
similarity values of the 2 images and base your actions on that.

To check the similarity coefficient of a certain pattern you can use
this command:

   im = find("image1.png")
   similarityCoeff = im.getScore()


Regards,
Eugene

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.