Reptorian G'MIC Filters

Can I create with gmic texture for landscape erosion like
https://wallup.net/wp-content/uploads/2015/12/212301-landscape-beach-nature-dune-sea-sand-Baja_California-wind-erosion-water-blue-Mexico-748x468.jpg

https://wantexpeditions.com/pic/trip00069/Magdalena%20Island%20II/Sand%20dunes%20on%20Magdalena%20Island%20in%20Baja%20California%20in%20Mexico%20in%202011%20February-32.jpg

I think there was experimental filter that uses values for displacement. @garagecoder is probably the author of one of them.

Also, please don’t get offtopic.

My interpretation is @hover is making feature requests. Is your thread open to them?

The thread is open, but in the end, I get to decide which feature request I feel like doing, and there are some that don’t make sense, so therefore they won’t be inserted. I have projects here - Projects · Reptorian1125/gmic-community · GitHub .

You’ve mentioned projects. Last time it was empty but now it is not. :slight_smile:

Thanks to @garagecoder for pointing me to a different interpretation of a code I made in one-liner, I had pushed 2 different versions of Majority which is basically erode/dilate based on condition. One of them use average, and the other use threshold to define to dilate or erode.

1 Like

I finally got it! Hip! Hip! Hooray!

That’s going to be my new filter. Now, all I need to do is to work out the proportion issue as it’s important to have accurate preview.

4 Likes

Is the lack of symmetry of all of the petals by design? What is this one called?

It’s by design. I didn’t make the original filter. It’s Newton Fractal made by MadJik at Paint.NET forum. Reverse engineered the original dll file, then converted into g’mic code. I have plans to convert many of his filters to g’mic.

Note: Permission been given as mentioned in Projects

Oh, Newton fractals are neat! See examples here:

1 Like

Hmm, it might be interesting to see someone attempt to do the newton fractal version of rep_thorn_fractal. Zooming, rotating, and then inserting custom formulas.


Just had pushed MJ Newton Fractal.


EDIT: Just have edited MadJik Newton Fractal code as in optimization. It now runs acceptable.

That Newton fractal render looks pretty cool, Rep. :grinning:

1 Like

I had forgotten to finish up my graduated filter, so I remember that now and therefore, finished it up. I’m sure photographers that use g’mic will love the option to use it. I pushed the finished graduated filter.

@hover I have tested your suggestion to add fibonacci sequence into thorn fractal. It didn’t really change the result all that much.

fibonacci=vector$3(0);
size1=0;size2=1;nextterm=0;
for(iter=0,iter<$3,iter++,
size1=size2;
size2=nextterm;
nextterm=size1+size2;
fibonacci[iter]=nextterm;
);

That goes below if($1>41,ff=$1-38;,ff=abs($1)-1;);.

vx+=vx<0?-fibonacci[v]:fibonacci[v];
vy+=vy<0?-fibonacci[v]:fibonacci[v];

This goes below the vx+= and vy+= series.

Doing it in altern fashion wouldn’t make much sense. You could replace v with altern.


Now, I got something here, but it’s not turning out quite right. I’m looking to try to fill inside the last layer.

size_sqr=50

mw=${-max_w}
mh=${-max_h}

lw={ceil($mw/$size_sqr)*$size_sqr+2}
lh={ceil($mh/$size_sqr)*$size_sqr+2}

$lw,$lh,100%,1,"x==0||x==w-1||y==0||y==h-1?1"

eval ${-math_lib}"

xx=1;
yy=1;
val=1;

selectable_2=vector2(0);
selectable_3=vector3(0);

const msize=3;

do( selectable_size=0;brk_point=0;

    if(!i(#-1,xx-1,yy),selectable_size++;);
    if(!i(#-1,xx+1,yy),selectable_size++;);
    if(!i(#-1,xx,yy+1),selectable_size++;);
    if(!i(#-1,xx,yy-1),selectable_size++;);
    
    if(selectable_size==4,dir=round(u(0,3));
    ,if(selectable_size==1,
            if(!i(#-1,xx-1,yy),dir=0;);
            if(!i(#-1,xx+1,yy),dir=1;);
            if(!i(#-1,xx,yy+1),dir=2;);
            if(!i(#-1,xx,yy-1),dir=3;);
       ,
            if(!i(#-1,xx-1,yy),brk_point++;);
            if(!i(#-1,xx+1,yy),if(selectable_size==2,selectable_2[brk_point]=1;,selectable_3[brk_point]=1;);brk_point++;);
            if(brk_point<selectable_size,if(!i(#-1,xx,yy+1),if(selectable_size==2,selectable_2[brk_point]=2;,selectable_3[brk_point]=2;);brk_point++;););
            if(brk_point<selectable_size,if(!i(#-1,xx,yy-1),if(selectable_size==2,selectable_2[brk_point]=3;,selectable_3[brk_point]=3;);););
            
            if(selectable_size==2,
                sdir=round(u(0,1));
                dir=selectable_2[sdir];
            ,
                sdir=round(u(0,2));
                dir=selectable_2[sdir];
            );
        );
    );
    
    mdist=round(u(1,msize));
    cl=0;
    
    if(dir==0,
        do(xx--;i(#-1,xx,yy)=val;cl++;,cl<mdist||!i(#-1,xx-1,yy));,
    if(dir==1,
        do(xx++;i(#-1,xx,yy)=val;cl++;,cl<mdist||!i(#-1,xx+1,yy));,
    if(dir==2,
        do(yy++;i(#-1,xx,yy)=val;cl++;,cl<mdist||!i(#-1,xx,yy+1));,
        do(yy--;i(#-1,xx,yy)=val;cl++;,cl<mdist||!i(#-1,xx,yy-1));
    );
    );
    );
    
    val+=1;,!i(#-1,xx-1,yy)||!i(#-1,xx+1,yy)||!i(#-1,xx,yy-1)||!i(#-1,xx,yy+1)
);

"

Ok, I ended up with filters that can do these.

Those rectangle and squares are generated from a mini-image containing labeled values.

Just one problem, if the max length for both side is over 1, there’s going to be areas that are not rectangles or squares. I only got this tiny image to go by. And the only things I can think of to extract shape is tones {iM}. What I’m having trouble is thinking how I can add a crop to the shape, find if the average is equal to 1, and if it is no change, but if it not, return random values into the shape. After all random values has been inserted to non-quad, label them.

image

1 Like

That filter reminds me on something like mondrian pattern

Could you try to iterate different part of the fractal? Iterating with some other variable to see if you come up with new fractal.

Yes, I will be trying that. I been thinking of using total v as a variable for seeing if the fibonacci sequence leads to different changes, elsewise I may have to allow it just for custom function for you to see how it goes.

That being said, I have pushed the “Mondrain Pattern” filter. I’ll be releasing the image mapping version of it later.

Looks like ministick to me, Rep; would be cool to have a Fibonacci version. :slight_smile:

I’m not ready to update my own filters yet, so instead, I’m leaving commands here. I ended up making a faster prime command.

#@cli rep_primelist:
#@cli : Return vector of boolean values up to the maximum image value rounded. Values are found by whether the argument number within vector is a prime.
rep_primelist:
maxn=0
repeat $!
    maxn={round(max($maxn,max(abs(im#$>),iM#$>)))}
done
u {"
prime=vector"$maxn"(1);
for(k=0,k<="$maxn",k++,
        if(k<=3,prime[k]=k>1?1:0;
        ,if(!(k%2)||!(k%3),prime[k]=0;
            ,for(m=4,m<=k/2,m++, 
                    if(k%m==0, 
                            prime[k]=0;
                            break(); 
                       );
                );
            );
        );
    );
(prime)
"}
#@cli rep_prime_surface: _width,_height,_negate= { 0=do_not_negate | 1=negate },_mirror
#@cli : Creates a simple prime surface by combining rep_primelist and spiralbw. Due to the time-consuming nature, this command will only create a new prime surface once.
#@cli : Default values: '_width=last_image_width','_height=last_image_height'
rep_prime_surface:
skip ${1=w},${2=h},${3=1},${4=0}
spiralbw {abs($1)},{abs($2)}
l.
    if $3 negate. fi
    if abs($4)==1 mirror. x
    elif abs($4)==2 mirror. y
    fi
    f "begin(prime=["${-rep_primelist}"];);
    prime[round(abs(i))];
    "
endl

I’m stepping back to work on Krita now. For that program, I decided to work on inserting box filtering, then guided filtering. After that, I’ll be working on Krita filters instead.

1 Like

Taking a break from Krita development for a while. I’m fixing grouped-pixel axis-based shift filter.

ss={s-1}
f "i(x,y,z,"$ss")>128?i:0"
{w},{h},1,1,i(#-1,x,y,0,$ss)?1
{w},1,1,1,sum(crop(#-1,x,0,0,0,1,h#-1,1,1))
{w#-2},{h#-2},1,1

eval ${-math_lib}"
for(xx=0,xx<w#-1,xx++,
    N=0;
    continue=0;
    if(i(#-2,xx)&&i(#-2,xx)<h#-1,
        for(yy=h#-1-1,yy>-1,yy--,
            if(yy==h#-1-1,
                N=i(#-2,xx);
                if(!i(#-3,xx,yy),
                    nyy=yy;
                    v=0;
                    do( v++;
                            nyy--;
                    ,(!i(#-3,xx,nyy))&&nyy>-1
                    );
                    i(#-1,xx,yy)=v;
                    i(#-3,xx,nyy)=0;
                ,
                    N--;
                    i(#-3,xx,yy)=0;
                );
            ,
                if(N,
                    if(!i(#-3,xx,yy),
                        nyy=yy;
                        v=0;
                        do( v++;
                            nyy--;
                        ,(!i(#-3,xx,nyy))&&nyy>-1
                        );
                        i(#-1,xx,yy)=v;
                        i(#-3,xx,nyy)=0;
                    ,
                        N--;
                        i(#-3,xx,yy)=0;
                    );
                ,break();
                );
            );
        );
    );
);
"
f[0] "j(0,-1*i(#-1,x,y,0,0));"
rm[-3--1]

See progress above. Use the code on code[global] or code[local] using a image with alpha. I’ll be finished soon.

Also, I find that the above is far too slow because it’s looping through pixel by pixel. I think I can fix that, but maybe later as well as the fix is also maybe later due to my plan.

EDIT: Posted faster code.

EDIT: Actually, I have a idea.
@afre @David_Tschumperle
Let’s say I want to process the above code with different threads at once. Each image is split either horizontally or vertically to the amount of threads available, and the code is ran. Is that possible? It would speed up the process. Of course, after the split, join them together.