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.










share|improve this question


























    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.










    share|improve this question
























      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.










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 at 5:57









      Vemboy

      1




      1
























          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






          share|improve this answer




























            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)






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              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

























              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






              share|improve this answer

























                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






                share|improve this answer























                  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






                  share|improve this answer












                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 at 6:12









                  Andreas

                  1,7641618




                  1,7641618
























                      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)






                      share|improve this answer



























                        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)






                        share|improve this answer

























                          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)






                          share|improve this answer














                          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)







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 14 at 14:33









                          Shudipta Sharma

                          1,071212




                          1,071212










                          answered Nov 14 at 6:20









                          MBo

                          45.7k22848




                          45.7k22848






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                              ComboBox Display Member on multiple fields

                              Is it possible to collect Nectar points via Trainline?