Discuss Scratch

MrBucket-Youtube
Scratcher
79 posts

RGB Values Not Making Sense

I made a script in the project https://scratch.mit.edu/projects/704138486/
which is supposed to compare a color value to the 7 colors of the rainbow and find which value its closest to, and it almost works, but it chooses the wrong value that is actually 3rd place for it, oh and its stuck as the last color for the color selector.
awesome-llama
Scratcher
1000+ posts

RGB Values Not Making Sense

A basic colour comparison can be done in RGB colour space. You need to separate the colour channels.

Then you can find the difference per channel and get a single final value through a method such as what Wikipedia provides:



If you are needing to compare colours so that the difference matches what humans see perceptually, you would have to convert the RGB values into a different set of channels, such as L*a*b* though be warned when you reach this or even more accurate colour spaces, the maths gets a bit complicated and there's a lot of theoretical knowledge you would need beforehand.

deck26
Scratcher
1000+ posts

RGB Values Not Making Sense

I think you need to make the scanning sprite's costume a little bigger.
MrBucket-Youtube
Scratcher
79 posts

RGB Values Not Making Sense

awesome-llama wrote:

A basic colour comparison can be done in RGB colour space. You need to separate the colour channels.

Then you can find the difference per channel and get a single final value through a method such as what Wikipedia provides:



If you are needing to compare colours so that the difference matches what humans see perceptually, you would have to convert the RGB values into a different set of channels, such as L*a*b* though be warned when you reach this or even more accurate colour spaces, the maths gets a bit complicated and there's a lot of theoretical knowledge you would need beforehand.

Thank you.

Powered by DjangoBB