How to compare images with same structure but different color patterns

Asked by Sepid

Hello,

I'm trying to compare two images that have the same structure but different color patterns. I looked at the forum posts, there were some related questions, but all of them are related to images that have solid colors. Therefore, none of the suggested methods worked for me, like color picking or increasing similar value to 0.99 or other suggestions.
My images do not have single solid colors. They have different color patterns. I put my images here in this link:
https://drive.google.com/open?id=0B0HOjfpxPc67ZUViZGVpNzJYc0E

When I try Sikuli find or exist method, these two images look the same, even with similarity 0.99.

Any help would be highly appreciated.

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

Do you mean this question?
https://answers.launchpad.net/sikuli/+question/632850

In this question, idea of checking colore of center of image is shown.
I think that you can check the color of a characteristic position over a certain width instead of only center of image.

The check range can be acquired by the following method.
m = find(some_image)
m.getTopLeft(), m.getTopRight(), m.getBottomLeft(), m.getBottomRight()

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I made different tests with your 2 images.

According to the general recommendations for good shots, one should concentrate on the important aspects of the image (in your case the colored area).
case 1: search image cropped to a rectangle containing only the coloured portion
case 2: search image cropped to a rectangle containing only part of the coloured area (no background)

In both cases the images are found in the other image (your uploaded images) with a score of less than 0.95.

Even if I use your uploaded originals the second (horizontally coloured) image is found in the first one with a score of only 0.94

So using an optimised pattern with a wanted score of 0.99 should work in your case to select the wanted image.

Revision history for this message
RaiMan (raimund-hocke) said :
#3
Revision history for this message
Sepid (sce2020sahaf) said :
#4

Thanks Raiman for your quick and complete reply.
As you said, if I crop the image and not include the background, it can detect the colors with the score of 0.99 . But since I'm running my tests on different machines (with different graphic configurations), that score of 0.99 would cause issue for me, and tests fail with little changes. That's why, I was looking for other solutions.

Currently I'm using SikuliX 1.1.0. Since you suggested to use SikuliX 1.1.1, I wanted to know if there is any change in this version regarding the color detection problems.

Revision history for this message
Sepid (sce2020sahaf) said :
#5

Thanks Masuo for your quick help.

Unfortunately, the idea of picking color for a certain location does not work well for me. The reason is that I'm running my tests on different machines with different screen resolutions and sizes. And a specific location would be interpreted differently in different machines. And since, my images do not have solid colors, different locations (even neighbor locations) would come up into different colors.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#6

@Sepid

--- about 1.1.1
I am rather sure, that using this version will not change much with your situation.
But using it instead of 1.1.0 would raise your chance to get help from my side in case of problems.

--- running my tests on different machines with different screen resolutions and sizes
Since with SikuliX everything is about pixels, using a set of images on other machines works as long as the pixels of that image seen on the other machine has the same size in pixels and has the same pixels. So you only are in trouble if on another machine the rendering process leads to a different image in this sense (less or more pixels and/or different pixels). In this case you need a different set of images anyways (one that fits the other situation).

So I think, you have to step back, really understand, how SikuliX works, to finally decide about a suitable concept for your case or leave SikuliX behind for this.

... and please stop to talk about "color detection problems" - it is nothing about that. The match score is simply a floating point value between 0 and 0.999999999999...., as result of some statistical analysis across all pixels, that gives a measure about similarity (see the respective method matchTemplate() of OpenCV).

All the best.

Revision history for this message
Sepid (sce2020sahaf) said :
#7

@RaiMan

Thank you very much for your help.

Revision history for this message
Sepid (sce2020sahaf) said :
#8

Thanks RaiMan, that solved my question.