Anyone can read 1977 codes here?

Still thematically similar in colour but I understand it is a WIP. :stuck_out_tongue:

Here it is. Iā€™ll be happy to explain any part of it. Coordinates x and y are converted to indices into a matrix. Every time a matrix element is hit, it is incremented by one. The matrix is displayed as a heatmap.

function run(tries=1000; h = 400, w = 400)
    Z = zeros(Int, h, w)
    for _ in 1:tries
        sercir!(Z)
    end
    imagesc(Z)
end

# values outside the "viewport" are shifted back into it.
function wraparound(x, xm, xM)
    while x < xm
        x += xM-xm
    end
    while x > xM
        x -= xM-xm
    end
    return x
end

function sercir!(Z,
                 # initial value
                 xi   = 6*rand()-3,
                 yi   = 6*rand()-3;
                 # "viewport"
                 xr   = (-2.0, 2.0),
                 yr   = (-2.0, 2.0),
                 reps = 10000)

    h, w = size(Z)
    x, y = xi, yi
    xm, xM = xr[1], xr[2]
    ym, yM = yr[1], yr[2]

    for _ = 1:reps
        x = x - y/2
        y = y + x/2

        xi = wraparound(x, xm, xM)
        yi = wraparound(y, ym, yM)

        # map `x, y` coordinates to a matrix location
        col = (xi-xm)/(xM-xm)*(w-1)+1
        row = (yi-ym)/(yM-ym)*(h-1)+1

        c = round(Int, col)
        r = round(Int, row)

        Z[r, c] += 1
    end
end

I canā€™t reproduce Reptorianā€™s plots with this code, though ā€“ all ellipses I get are centered in the origin; only their size changes.

1 Like

Can you show us the output? I canā€™t run it.

EDIT:

The only problem I now have is revealing outside of the boundary, and I have to say, that is probably impossible. I only have hints of that.

What do you mean by ā€œreveal outside the borderā€?

Hereā€™s one example, with random initial values between -3 and 3, with viewport between -2 and 2; values outside the viewport are mirrored back. This is 60 ellipses.

image

See here:

The left and right side are unfilled. It definitely would be nice if there is another expression that generates similar image, but being able to fill outside of border. But, I wonā€™t look at finding how as basic search for solution havenā€™t been found, and mathematically, itā€™s not possible (probably).

This could be a nice design for some bohemian hippie headscarf :grin:

1 Like

I finalized the CLI version. Just wish there was percentile-based cut though. Hereā€™s a mixture of 3 Serendiptous Circle.

I recall a command named percentile and another that addresses percentile cuts, but maybe not what you are askingā€¦ I am not sure what you are askingā€¦

Basically, what Iā€™m looking for a command that cuts based on the frequency vs dimension ratio. $1 would be the parameter to find the lowest value that has a frequency higher than $1, and $2 would be the parameter to find the highest value that has a frequency higher than $2. Then, cut based on the found values. Thatā€™s something I requested on Gā€™MIC 3.1 thread.

Like a band pass/stop? There is a bandpass command that you could use as a starting point.

bandpass:
    _min_freq[%],_max_freq[%]

  Apply bandpass filter to selected images.

  Default values: 'min_freq=0' and 'max_freq=20%'.

  Example:
    [#1] image.jpg bandpass 1%,3%

  Tutorial: https://gmic.eu/oldtutorial/_bandpass

That doesnā€™t give me the output I want. I want to cut instead. Let me see. I could try to do a custom command involving sorting, and then find the frequency of each value, and cut based on those.

The world doesnā€™t have enough graphics languages, so hereā€™s a solution in ā€œalfimā€, a language I am developing. I call sercir() only once, so there is only one ā€œcircleā€. It is based on code above by @mbs, but with smaller initial (xi,yi) and without wraparound.

function sercir ()
  variables
    WW = %[fx:w],
    HH = %[fx:h],
    xi = %[fx: 4 * rand() - 2],
    yi = %[fx: 4 * rand() - 2],
    xmin = -2,
    xmax = +2,
    ymin = -2,
    ymax = +2,
    xmult = %[fx: (%{WW}-1) / (%{xmax}-(%{xmin})) ],
    ymult = %[fx: (%{HH}-1) / (%{ymax}-(%{ymin})) ],
    rep = 1,
    col,
    row,
    x = %[fx: %{xi} ],
    y = %[fx: %{yi} ]
  endvariables

  -fill White

  while %[fx: %{rep} < 1000 ] do

    assign x = %[fx: %{x} - %{y}/2 ]
    assign y = %[fx: %{y} + %{x}/2 ]

    assign col = %[fx: (%{x}-(%{xmin})) * %{xmult} + 1 ]
    assign row = %[fx: (%{y}-(%{ymin})) * %{ymult} + 1 ]

    -draw "point %{col},%{row}"

    assign rep = %[fx: %{rep} + 1]
  endwhile

endfunction

-size 400x400 xc:Black
call sercir ()
+write x.png

x

3 Likes

Sounds like youā€™re talking about statistical relative frequency? A histogram ought to manage thatā€¦

What I understand here is what you name ā€œfrequencyā€ is actually the ā€œoccurenceā€, right ?
(Frequency in image often refers to Fourier decomposition in image processing).

as @garagecoder suggests, computin the histogram is probably the key here.
But what do you want to do with the values below or above a certain occurence threshold. What value should be used to replace the old one ?

These become the values used for cut(). A partial work on this:

> gmic sp cat to_gray +pixelsort +,yx +area. 0,0 +label.. a[-3--1] c colormap. 0 sh. 2 pixelsort.. +,x,. rm.

The first channel is the value of image, the second channel is the occurence, and the third channel is the label value of the image. If the occurence is greater or equal to 5% starting from the left, then corresponding image pixel value becomes the cut value 1. If the occurence is greater or equal to 5% starting from the right, then the corresponding image pixel value becomes the cut value 2. So, with those found value, it is the cut values.

I have done something similar for tone re-mapping (the ranking and smoothing). The challenge is making it fast. E.g., colormap on large colourful images takes a while to process.

The speed issue is why I brought it up. I also think something like this could also apply to the math parser on a vector as well.

Beautiful name! If you replace ā€œmā€ with ā€œoā€ then you get my first name :slight_smile:

Iā€™m interested. Could you tell us a bit more about it? Design and goals ?