Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39307

Re: Near random colors to picture pixels, so that same color matches same random color.

Subject Re: Near random colors to picture pixels, so that same color matches same random color.
Newsgroups comp.lang.javascript
References <5c0399a6-d083-4269-b25b-5ce92f91ba2an@googlegroups.com> <0fa596ff-6c12-4626-9a39-172f47d91514n@googlegroups.com> <f38b61f2-9490-4175-8880-fdbc26b9cdc9n@googlegroups.com> <6esEH.15528$EY1.11782@fx42.iad> <3f997dc4-c4b3-4b4d-a078-585e3fb4a578n@googlegroups.com>
From Richard Damon <Richard@Damon-Family.org>
Message-ID <iHNEH.37773$R82.6210@fx46.iad> (permalink)
Organization Forte - www.forteinc.com
Date 2020-12-23 15:23 -0500

Show all headers | View raw


On 12/23/20 2:15 PM, Kristjan Robam wrote:
> Richard Damon kirjutas teisipäev, 22. detsember 2020 kl 21:59:08 UTC+2:
>> On 12/22/20 12:29 PM, Kristjan Robam wrote: 
>>> Michael Haufe (TNO) kirjutas pühapäev, 15. november 2020 kl 21:07:18 UTC+2: 
>>>> On Sunday, November 15, 2020 at 1:01:01 PM UTC-6, rob9999999...@gmail.com wrote: 
>>>>> Anyone can point to a place, where to download code for this ? 
>>>>>
>>>> I don't know what you mean. Can you give more details? 
>>> What I want to say is the following. 
>>> Function: 
>>> Renewing each picture color. 
>>> New picture colors must satisfy this: 
>>> 1. Each pixel color goes to random. 
>>> 2. Each same color pixel goes to same color, that is defined in point 1. 
>>>
>>> Basically what you would need is a reminder of assigned colors of picture pixels. 
>>>
>>>
>>>
>>> Actually I got that one programmed as far as I remember. 
>>>
>>> But what I would now need very much is a function, that turns colors to random so, 
>>> that the difference of near colors is the distance of the original colors of points A and B. 
>>>
>>> If you can help me with that, I would be very thankful. 
>>>
>>>
>>> Kristjan Robam 
>>>
>> If your requirements are that the 'spacing' between all colors in the 
>> original image and in the new image are preserved, your randomness is 
>> going to be greatly limited. One big question is how you want to define 
>> the distance between colors (largly which color space you want to 
>> measure in). If you presume that the image might be using a broad 
>> assortment of colors and distance measured but RGB distance, then the 
>> only general transformations that preserve distances would be swapping 
>> axis and reversing the direction of some of the axis. 
>>
>> Some other spaces might give slightly different options, but similar, as 
>> 'Hue' based color spaces have a polar axis which behaves a bit 
>> differently than a cartisian axis so can't really swap with another 
>> axis, but can have an arbitrary offset or can be flipped (so gives more 
>> options).
> 
> Hello guys.
> 
> Richard Damon, as you said I need 'spacing' preserved. And one more requrement. When all the color areas must mach with new random colors. 
> It could take any color that is the same far in my color distance sense.
> One base color R(red){others G and B. The alpha is not so important I think at the moment.} distance sqr((R1*R1+R2*R2)/2).
> It would take the "first" found R,G,B triple, whose difference is equal to original neighbour color distance.
> 
> Parimate tervitustega Eestist ( it is good hello's from Estonia),
> Kristjan Robam
> 

As I said, to map points in the RGB cube to other points in the RGB
cube, such that the spacing of all points stay the same, you are very
limited in what you can do (unless your set of colors used are very
carefully chosen).

You can first swap color axis in any of 6 way:

RGB -> RGB RBG GRB GBR BRG BGR

and then each of the 3 axis can individually be swapped end for end.

This gives 48 possible transformations and that is it.

The issue is that if you map one color at 'random', then choose a second
color from the right distance shell, and a 3rd color will be constrained
from a circle, and a forth will have just two possible values that have
the right distange. After that every point will have just a single
option that is the right distance from every other point. Then, unless
you chose the points to match one of the rules above, some of the colors
will be forced to be mapped outside the base RGB space, thus you will
need to reject that mapping. Unless the space of the input colors leaves
wiggle room inside the color cube you are stuck with just those
transformations.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Near random colors to picture pixels, so that same color matches same random color. K R <rob99999999999999999@gmail.com> - 2020-11-15 11:00 -0800
  Re: Near random colors to picture pixels, so that same color matches same random color. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-11-15 11:07 -0800
    Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-22 09:29 -0800
      Re: Near random colors to picture pixels, so that same color matches same random color. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-22 11:35 -0800
      Re: Near random colors to picture pixels, so that same color matches same random color. Richard Damon <Richard@Damon-Family.org> - 2020-12-22 14:58 -0500
        Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-23 11:15 -0800
          Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-23 11:17 -0800
          Re: Near random colors to picture pixels, so that same color matches same random color. Richard Damon <Richard@Damon-Family.org> - 2020-12-23 15:23 -0500
            Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-24 01:10 -0800
              Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-24 01:11 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <iiiiiiiiiiiia@bestmail.us> - 2020-12-24 04:49 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <iiiiiiiiiiiia@bestmail.us> - 2020-12-24 05:46 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-24 10:53 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-25 09:33 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <iiiiiiiiiiiia@bestmail.us> - 2020-12-25 23:17 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <iiiiiiiiiiiia@bestmail.us> - 2020-12-25 23:18 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <iiiiiiiiiiiia@bestmail.us> - 2020-12-25 23:33 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-12-26 08:30 -0800
                Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-27 07:57 -0800
                If somebody reads this again ..... I A <he12457@hotmail.com> - 2021-02-14 09:24 -0800
                Re: If somebody reads this again ..... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-02-15 05:55 -0800
                Re: If somebody reads this again ..... Minai Robam <mi23523523@fastmail.com> - 2021-03-30 09:02 -0700
                Re: If somebody reads this again ..... Minai Robam <mi23523523@fastmail.com> - 2021-03-30 09:37 -0700
                Re: If somebody reads this again ..... Minai Robam <mi23523523@fastmail.com> - 2021-03-30 09:39 -0700
        Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-23 11:24 -0800
        Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-23 11:27 -0800
        Re: Near random colors to picture pixels, so that same color matches same random color. Kristjan Robam <jippii1291983@gmail.com> - 2020-12-23 11:30 -0800

csiph-web