0 votes

Hey Guys!

Im working on a programm that compares two 16x16 tiles of an image to see if they are unique to each other.

But the approach I am using right now is a little bit flawed.

I am looping through every pixel of a tile and add the RGB values of each together, but this leads to the problem that i cant distinguish the location of the pixels, if for example the tiles have the same amount of black and white pixels but in another location.

Is there any way to add the RGB values together so that the location of the individual pixels are considered?

Or even better is there another way to compare two tiles with each other?

Godot version v3.2.3
in Engine by (17 points)

Can you show us the code of your compare-method?

1 Answer

+2 votes
Best answer

To achieve what you want, you may have to implement an image similarity algorithm like SSIM/DSSIM in GDScript. This algorithm isn't trivial, so you'll probably have to look at a Python library implementing it and port it to GDScript.

Alternatively, if you're certain that the images are in the same format, you could compare the checksums of the image data's PoolByteArrays.

by (10,271 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.