Not to discuss of an abstract mathematical problem, but from a practical image processing viewpoint:

is there a way to transform graphics created in a circle like the attached sample in squared graphics? (to be used for instance as frames around an image?). Thanks.
Merry Christmas to everybody.

Yes, it is possible mathematically. I’m not sure yet how to do it though. But, I’m way too busy solving string-related problem in G’MIC for my next year continuation of refactor and improvement of my G’MIC filters.

Off the top of my head, using polar coordinates centered on the circle, I would say that a point at (ρ,θ) is moved to

(ρ/(max(abs(sin(θ)),abs(cos(θ)))),θ)

The problem is that you probably want the inverse transformation (ie, given a point in the target, where is the corresponding point in the source) but if you divide the image in 4 quadrants (delimited by diagonals), then a point at (ρ,θ) corresponds to the point at

(ρ*abs(sin(θ),θ) in the top & bottom quadrants

(ρ*abs(cos(θ),θ) in the side quadrants

Converting to Cartesian coordinates is left as an exercise to the reader

This perhaps could done with a displace map in Gimp (to quote a famous French movie line, I’m not sure enough to bet, but I would give my word of honor)

Wow! Fantastic!
David, could you store this process under G’MIC for future use by filters?
Thanks a lot.

P.S. Just seen that you have already created this filter in G’MIC; my fault not to have checked (Square to Circle has also the choice Circle to Square). Happy to have it already available. Thanks and sorry again.

You’re probably not considering doing this, but as you asked for filters before, I think you could consider trying to code in G’MIC and making solutions for others.

That being said, I think something like this is doable as a border filter tool as it is now, you just gotta make your target image fit.

This is not the same as the previous Square to Circle filter, because the new one (Square to Circle [alt]) transforms each centered circle to square and vice-versa. The previous filter (without the alt) was doing this only for the image border.

The code of this new filter:

#@gui Square to Circle [alt] : fx_square_circle_alt,fx_square_circle_alt(1)
#@gui : Mode = choice("Square to Circle","Circle to Square")
#@gui : Center = point(50,50,0,1)
#@gui : Zoom (%) = float(0,-100,100)
#@gui : Interpolation = choice(1,"Nearest Neighbor","Linear")
#@gui : Boundary = choice("Transparent","Nearest","Periodic","Mirror")
#@gui : Adapt to Image Ratio = bool(1)
#@gui : sep = separator()
#@gui : note = note("<small>Author: <i>David Tschumperlé</i>. Latest Update: <i>2023/12/24</i>.</small>")
fx_square_circle_alt :
mode,centerx,centery,zoom,interpolation,boundary,ratio=${1-7}
if !$boundary to_a fi
f. "const interpolation = $interpolation;
const boundary = $boundary;
const zoom = 10^($zoom%);
const cx = w*$centerx%;
const cy = h*$centery%;
const fx = $ratio?w:1;
const fy = $ratio?h:1;
x = (x - cx)/fx;
y = (y - cy)/fy;
t = atan2(y,x);
r = norm(x,y);
phi = (t + pi/4)%(pi/2) - pi/4;
nr = ($mode?r*cos(phi):r/cos(phi))/zoom;
nx = cx + fx*nr*cos(t);
ny = cy + fy*nr*sin(t);
i(nx,ny)"