Reptorian G'MIC Filters

When you finish this would there be a way to add custom functions and/or maps for the gravity to follow?

Well, I consider it finished right now despite the bugs as I can’t solve them, but it works for the most part.

But, theoretically, it is doable. The way the current version of the filter works is using rectangular-polar transformation, and g’mic supports curves. So, if you figure out how to create a curve and make a shape out of it, and then find the point perpendicular to each end. But, that’s a bit complicated.

The other solution is to use a layer as a aid, and then erase based on the information found from the reference layer. Kind of a guide layer. If you can find the weighted center based on the reference layer. You can have the filter automatically find the point. I supposed I can use a pass argument to do this.

@Joan_Rake1 is getting restless. :slight_smile:
Me awaiting for the next creation. :crossed_fingers:

There will be only bug fixes for now and code refactoring. I think you noticed I have added const recently. I decided to focus back on Krita development.

At most, I will add neumann shifting to the tiler tool and grid option to tileset window.

If I feel like it, I’ll make a way to generate isometric tiles from image(s).

Why is this error showing up? Debug tells me zilch.

Operator '=': Invalid name specified for argument 1 when defining macro 'orddith()', in expression '... ); orddith(8ipx,cc,coefcount,ditherpattern)=int((((cc-1)*c(...)...'.```
#@cli rep_lpasc_ordith: 'eq to. rep_loupasc_ordered_dithered' : (+)
rep_lpasc_ordith: rep_loupasc_ordered_dithered $*
#@cli rep_loupasc_ordered_dithered : _dither_method={ 0=checkerboard | 1=dispersed | 2=arcade | 3=ordered | 4=lines | 5=custom | 6=rand }, _palette={ 0=Binary | 1= EGA | 2= Web-safe | 3=12-bit }
#@cli: Color reduction with dithering using algorithm provided by Pascal Ollive.
rep_loupasc_ordered_dithered:
f "begin(
    color_count=[2,4,6,16];
    custom_matrix=[34,14,3,22,6,27,21,8,26,13,30,1,29,18,33,5,20,12,9,0,19,28,10,32,16,31,7,17,2,25,4,24,15,35,23,11];
    line_matrix=[8,9,6,7,1,0,3,2,4,5,9,8,2,3,0,1,4,5,7,6,1,0,3,2,4,5,8,9,6,7,0,1,4,5,7,6,9,8,2,3,4,5,8,9,6,7,1,0,3,2,7,6,9,8,2,3,0,1,4,5,6,7,1,0,3,2,4,5,8,9,2,3,0,1,4,5,7,6,9,8,3,2,4,5,8,9,6,7,1,0,4,5,7,6,9,8,2,3,0,1];
    mat_rev(n)=(
        n = int(n);
        n = (n & 0x55555555) << 1 | (n >> 1) & 0x55555555;
        n = (n & 0x33333333) << 2 | (n >> 2) & 0x33333333;
        n = (n & 0x0f0f0f0f) << 4 | (n >> 4) & 0x0f0f0f0f;
        n = (n << 24) | ((n & 0xff00) << 8) | ((n >> 8) & 0xff00) | (n >> 24);
    );
    orddith(8ipx,cc,coefcount,ditherpattern)=int((((cc-1)*coefcount+1)*8ipx+255*ditherpattern-1)/(255*coefcount));
    randdit(8ipx,cc,nx,ny)=(
        sd=(mat_rev(ny)>>23)<<22|mat_rev(nx)>>10;
        ditp=(48271*sd)%2147483647;
    );
    if($1==0,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,2,xor(nx,ny)&0x1);,
    if($1==1,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,4,((xor(nx,ny)&0x1)<<1)|(ny&0x1)),
    if($1==2,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,8,2+(ny&0x3));,
    if($1==3,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,5,line_matrix[20*(ny%5)+2*(nx%5)]>>1);,
    if($1==4,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,10,line_matrix[10*(ny%10)+(nx%10)]);,
    if($1==5,appdit(8ipx,cc,nx,ny)=orddith(8ipx,cc,36,custom_matrix[6*(ny%6)+(nx%6)]);,
             appdit(8ipx,cc,nx,ny)=randdit(8ipx,cc,nx,ny);
    );
    );
    );
    );
    );
    );
    const cc=color_count[$2];
    const cs=255/(cc-1);
);
appdit(i,cc,x,y);
"

A variable name cannot start with a number.

1 Like

Yeah, that what I found out. Obvious solution here. Feeling dumb now.


New filter Ordered Dithering! There’s some limitation, and there’s a source code.

I have a question here. Would anyone appreciate a filter something akin to apply_channels, but for every layers that a command has been applied to, they get cropped to their original dimension, and you can specify their relative location?

I am not sure if I understand completely. There are lots of things that I do for which I don’t have a command. If you think it would be useful as a generally purpose command, by all means go ahead.

It’s a command that crops to original after a command has been applied. I think I’ll just do that.

I attempted this command.

rep_kod :
_gmic_s="$?" v + _rep_keep_original_dimension $"*"
rep_keep_original_dimension:
_gmic_s="$?" v + _$0 $"*"
_rep_keep_original_dimension:
image_count={$!*3}
imgs={$!}
eval "
const lc="$image_count";
dimension_list=vectorlc(0);
for(imgc=0,imgc<"$imgs",imgc++,
dimension_list[3*imgc+0]=w#imgc;
dimension_list[3*imgc+1]=h#imgc;
dimension_list[3*imgc+2]=d#imgc;
);
(dimension_list)
"
dimensions_info=[${}]
$1
repeat $imgs 
    r[$>] {($dimensions_info)[$>*3+0]},{($dimensions_info)[$>*3+1]},{($dimensions_info)[$>*3+2]},100%,$2,$3,$4,$5,$6 
done

It didn’t work because ${2-6} are undefined. So, how do I get around that?

I don’t see where your inputs would be. Just look at stdlib for examples. Maybe try using skip ...,${2=},...

The inputs is basically "command", _interpolation, _boundary_conditions, _ax, _ay, _az, _ac

Same as resize except for the first 4 commands which is truncated to command. The idea is to allow users to preserve original dimension using a command. That way, I can depreciate this technique used elsewhere in my filters. I’m not sure why the undefined $2 shows up.

Give me an example so that I can run it and see what pops up.

Ok, it seems that I am using command-based cli wrong. How would you go by making this work in Windows cli?

gmic sp lena sp dog sp cat foo ac "blur 5",0

It gives me undefined argument ‘$2’ error.

You need to escape the quotations like so \".

1 Like

Thanks, my command now works, and I will proceed to finish up rep_kod and depreciate this technique on some of my other filters.

I am confused by your use of depreciate.

There are some commands where I made the option to keep resized image or autocrop to original dimension. This allows me to remove those part of those commands.


@afre I found success right now.

#@cli rep_kodl: eq. to 'rep_keep_original_dimension_and_or_layer' : (+)
rep_kodl:
_gmic_s="$?" v + _rep_keep_original_dimension_and_or_layer $"*"
#@cli rep_keep_original_dimension_and_or_layer: "command",_mode={ 0=mode_0 | 1=mode_1 | 2=mode_2},_interpolation, _boundary_conditions, _ax, _ay, _az
#@cli : Apply command to image(s), then have the option to preserve dimensions and/or resized layer.
#@cli : (eq. to 'rep_kodl').\n
#@cli : Default values: _preserve_resized_layer=0,_interpolation=0,_boundary_conditions=3,_ax=0.5,_ay=0.5,_az=0
rep_keep_original_dimension_and_or_layer:
_gmic_s="$?" v + _$0 $"*"
_rep_keep_original_dimension_and_or_layer:
skip ${2=0},${3=0},${4=3},${5=.5},${6=.5},${7=0}
image_count={$!*3}
imgs={$!}
eval "
const lc="$image_count";
dimension_list=vectorlc(0);
for(imgc=0,imgc<"$imgs",imgc++,
    dimension_list[3*imgc+0]=w#imgc;
    dimension_list[3*imgc+1]=h#imgc;
    dimension_list[3*imgc+2]=d#imgc;
);
(dimension_list)"
dimensions_info=[${}]
m "apply_filter:$1" 
rm.
if abs($2)>=0&&abs($2)<=2
    repeat $! l[$<]
        if abs($2)>=1
            +apply_filter
            r.. {w#-1},{h#-1},{d#-1},100%,${3-7}
        fi
        if abs($2)==2||!$2
            r[0] {($dimensions_info)[$<*3+0]},{($dimensions_info)[$<*3+1]},{($dimensions_info)[$<*3+2]},100%,${3-7}
        fi
    endl done
fi
uncommand apply_filter

$ gmic sp lena sp dog sp cat rep_kodl \"r2dx 200% blur 5\",1

See how this can be so useful? I can blend layers with effect and no effect, I can apply effects and restrain to original dimension only.

@David_Tschumperle I have a question.

vxf(a,b)=([${14--1}])[altern*2];
vyf(a,b)=([${14--1}])[altern*2+1];,
vxf(a,b)=(vec=[${14--1}];vec[altern*2]);
vyf(a,b)=(vec=[${14--1}];vec[altern*2+1]);,

They’re different, right?