gemini-testing / looks-same

Node.js library for comparing images
MIT License
669 stars 55 forks source link

Can there be more tolerance if the patterns are very similar? #100

Closed crapthings closed 8 months ago

crapthings commented 1 year ago
image

i m using this for now, but the block is very hard to solve like this image

const { equal } = await looksSame(image1, image2)

what is tolerance value for such scene?

const {equal} = await looksSame('image1.png', 'image2.png', {tolerance: 5});
DudaGod commented 1 year ago

Hello. I didn't understand your question. I see one image with strange hand-drawn rings. And I don’t see the image with which it is compared. Can you send images separately from each other?

in most cases it is recommended to use tolerance with 2.3 (with this value the eye does not see the difference between images).

crapthings commented 1 year ago

i'm making a puzzle game

image

the problem is those piece is very hard to solve, because solid color looks same

https://www.text2puzzles.com/solve/2d8f81ef-46b7-425a-aed8-364f0e6d3847-u1

image

the backend image is made by stable diffusion, its very hard to control if it has solid background or similary pattern

image
crapthings commented 1 year ago

Hello. I didn't understand your question. I see one image with strange hand-drawn rings. And I don’t see the image with which it is compared. Can you send images separately from each other?

in most cases it is recommended to use tolerance with 2.3 (with this value the eye does not see the difference between images).

i will try~

DudaGod commented 1 year ago

Ok, I understood. You have puzzle pieces that are almost indistinguishable from each other and you need to make sure that each of them is in the correct sequence. But if there is no difference between them with tolerance=2.3 (i.e. the human eye cannot distinguish), then I would consider that the puzzle is put together correctly. Otherwise the user will have to move pieces of puzzle at random.

Perhaps with canvas you can assign IDs to each piece of the puzzle and validate their correctness by position. But in this case it is necessary that each piece be different from each other (for example, add uniqueness by connecting elements, like in real puzzles).

crapthings commented 12 months ago
image

tried to 5 but still not equal

the piece sent will not include that split line, its copy from the canvas to one image

DudaGod commented 12 months ago

tried to 5 but still not equal

Of course they are not the same. I can see the difference with my eye without any approximation.

You need to either take a reference after cutting the image or use another validation mechanism (I wrote the options above).

DudaGod commented 8 months ago

It seems that the problem has been sorted out here. No problems were found with the looks-same. In your place, I would use this option:

Perhaps with canvas you can assign IDs to each piece of the puzzle and validate their correctness by position. But in this case it is necessary that each piece be different from each other (for example, add uniqueness by connecting elements, like in real puzzles).