Finding a second color knowing the distance
up vote
-1
down vote
favorite
I'm doing a project where im finding the patterns of 1 color duo and trying to find the unkown second color of the second color duo.
If for example i have 2 colors (first duo):
RGB(60, 90, 80)
RGB(70, 50, 120)
By using the simplest algorithim i find that:
distance = sqrt((r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2)
where distance is 57.
Then i have the second color duo:
RGB(80,45,150)
RGB(x,y,z)
Finding the second color here by only knowing first color + distance is a bit unrealistic, any suggestions on how i could find something like this, or any good insight on workarounds.
algorithm colors rgb similarity
add a comment |
up vote
-1
down vote
favorite
I'm doing a project where im finding the patterns of 1 color duo and trying to find the unkown second color of the second color duo.
If for example i have 2 colors (first duo):
RGB(60, 90, 80)
RGB(70, 50, 120)
By using the simplest algorithim i find that:
distance = sqrt((r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2)
where distance is 57.
Then i have the second color duo:
RGB(80,45,150)
RGB(x,y,z)
Finding the second color here by only knowing first color + distance is a bit unrealistic, any suggestions on how i could find something like this, or any good insight on workarounds.
algorithm colors rgb similarity
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm doing a project where im finding the patterns of 1 color duo and trying to find the unkown second color of the second color duo.
If for example i have 2 colors (first duo):
RGB(60, 90, 80)
RGB(70, 50, 120)
By using the simplest algorithim i find that:
distance = sqrt((r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2)
where distance is 57.
Then i have the second color duo:
RGB(80,45,150)
RGB(x,y,z)
Finding the second color here by only knowing first color + distance is a bit unrealistic, any suggestions on how i could find something like this, or any good insight on workarounds.
algorithm colors rgb similarity
I'm doing a project where im finding the patterns of 1 color duo and trying to find the unkown second color of the second color duo.
If for example i have 2 colors (first duo):
RGB(60, 90, 80)
RGB(70, 50, 120)
By using the simplest algorithim i find that:
distance = sqrt((r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2)
where distance is 57.
Then i have the second color duo:
RGB(80,45,150)
RGB(x,y,z)
Finding the second color here by only knowing first color + distance is a bit unrealistic, any suggestions on how i could find something like this, or any good insight on workarounds.
algorithm colors rgb similarity
algorithm colors rgb similarity
asked Nov 14 at 5:57
Vemboy
1
1
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Welcome to StackOverflow!
If there is only 1 possible second color, you could calculate the distance simply by the difference of each R, G, and B elements. Therefore, the distance between RGB(60, 90, 80) and RGB(70, 50, 120) is (-10, +40, -40).
If the first color is RGB(80,45,150), then the second color with the same distance is RGB(90, 5, 190)
Another way is to use the distance as radial distance, however this will results in infinitely many possible second colors
add a comment |
up vote
0
down vote
You have a spherical surface around the first color point in RGB
space (cutted sphere if distance is too long). For exact distance you have integer equation
dr^2 + dg^2 + db^2 = distance^2
that might have: no solutions, and symmetrical cases: 4 solutions, 8 solutions, 16/24 solutions, perhaps more. So task is to find triplets giving needed sum (c.f. Pythagorean triples for 2D case - there are 4 neighbors for distance 2, 8+4 neighbors for distance 5, no neighbors for distance 1.5 and so on).
If some tolerance is allowed, then you can find even more possible solutions.
Seems you need some kind of constraints to limit results.
Also it might be useful to consider another color model like HSV
(if color perception is important)
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Welcome to StackOverflow!
If there is only 1 possible second color, you could calculate the distance simply by the difference of each R, G, and B elements. Therefore, the distance between RGB(60, 90, 80) and RGB(70, 50, 120) is (-10, +40, -40).
If the first color is RGB(80,45,150), then the second color with the same distance is RGB(90, 5, 190)
Another way is to use the distance as radial distance, however this will results in infinitely many possible second colors
add a comment |
up vote
0
down vote
Welcome to StackOverflow!
If there is only 1 possible second color, you could calculate the distance simply by the difference of each R, G, and B elements. Therefore, the distance between RGB(60, 90, 80) and RGB(70, 50, 120) is (-10, +40, -40).
If the first color is RGB(80,45,150), then the second color with the same distance is RGB(90, 5, 190)
Another way is to use the distance as radial distance, however this will results in infinitely many possible second colors
add a comment |
up vote
0
down vote
up vote
0
down vote
Welcome to StackOverflow!
If there is only 1 possible second color, you could calculate the distance simply by the difference of each R, G, and B elements. Therefore, the distance between RGB(60, 90, 80) and RGB(70, 50, 120) is (-10, +40, -40).
If the first color is RGB(80,45,150), then the second color with the same distance is RGB(90, 5, 190)
Another way is to use the distance as radial distance, however this will results in infinitely many possible second colors
Welcome to StackOverflow!
If there is only 1 possible second color, you could calculate the distance simply by the difference of each R, G, and B elements. Therefore, the distance between RGB(60, 90, 80) and RGB(70, 50, 120) is (-10, +40, -40).
If the first color is RGB(80,45,150), then the second color with the same distance is RGB(90, 5, 190)
Another way is to use the distance as radial distance, however this will results in infinitely many possible second colors
answered Nov 14 at 6:12
Andreas
1,7641618
1,7641618
add a comment |
add a comment |
up vote
0
down vote
You have a spherical surface around the first color point in RGB
space (cutted sphere if distance is too long). For exact distance you have integer equation
dr^2 + dg^2 + db^2 = distance^2
that might have: no solutions, and symmetrical cases: 4 solutions, 8 solutions, 16/24 solutions, perhaps more. So task is to find triplets giving needed sum (c.f. Pythagorean triples for 2D case - there are 4 neighbors for distance 2, 8+4 neighbors for distance 5, no neighbors for distance 1.5 and so on).
If some tolerance is allowed, then you can find even more possible solutions.
Seems you need some kind of constraints to limit results.
Also it might be useful to consider another color model like HSV
(if color perception is important)
add a comment |
up vote
0
down vote
You have a spherical surface around the first color point in RGB
space (cutted sphere if distance is too long). For exact distance you have integer equation
dr^2 + dg^2 + db^2 = distance^2
that might have: no solutions, and symmetrical cases: 4 solutions, 8 solutions, 16/24 solutions, perhaps more. So task is to find triplets giving needed sum (c.f. Pythagorean triples for 2D case - there are 4 neighbors for distance 2, 8+4 neighbors for distance 5, no neighbors for distance 1.5 and so on).
If some tolerance is allowed, then you can find even more possible solutions.
Seems you need some kind of constraints to limit results.
Also it might be useful to consider another color model like HSV
(if color perception is important)
add a comment |
up vote
0
down vote
up vote
0
down vote
You have a spherical surface around the first color point in RGB
space (cutted sphere if distance is too long). For exact distance you have integer equation
dr^2 + dg^2 + db^2 = distance^2
that might have: no solutions, and symmetrical cases: 4 solutions, 8 solutions, 16/24 solutions, perhaps more. So task is to find triplets giving needed sum (c.f. Pythagorean triples for 2D case - there are 4 neighbors for distance 2, 8+4 neighbors for distance 5, no neighbors for distance 1.5 and so on).
If some tolerance is allowed, then you can find even more possible solutions.
Seems you need some kind of constraints to limit results.
Also it might be useful to consider another color model like HSV
(if color perception is important)
You have a spherical surface around the first color point in RGB
space (cutted sphere if distance is too long). For exact distance you have integer equation
dr^2 + dg^2 + db^2 = distance^2
that might have: no solutions, and symmetrical cases: 4 solutions, 8 solutions, 16/24 solutions, perhaps more. So task is to find triplets giving needed sum (c.f. Pythagorean triples for 2D case - there are 4 neighbors for distance 2, 8+4 neighbors for distance 5, no neighbors for distance 1.5 and so on).
If some tolerance is allowed, then you can find even more possible solutions.
Seems you need some kind of constraints to limit results.
Also it might be useful to consider another color model like HSV
(if color perception is important)
edited Nov 14 at 14:33
Shudipta Sharma
1,071212
1,071212
answered Nov 14 at 6:20
MBo
45.7k22848
45.7k22848
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293980%2ffinding-a-second-color-knowing-the-distance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown