Jump to content

Reptorian's G'MIC Code Workshop


Reptillian

Recommended Posts

$1 is not defined in the way that C# does it. If you place $1, it becomes it own variable. $1 would be distortion_main in cli, and Distortion Factor for the GUI. If I set $1 to 0, it goes from log(10^-8)*$1 = -18.40*0 = 0. If someone wants to define a variable for $name, this is how one would do it for g'mic.

test={5*10}

$test

Then, $test becomes 50. Does this explain thing? I know there's sometimes a language barrier between programmers with two very different programming languages.

 

----

EDIT: @Ego Eram Reputo I found the problem. It has to do with angle, which confuses me, but now I know where it lies.

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Got news, it seem like my health is on decline as it has been for years due to a nose problem. At this point, I can’t effectively can’t work on filters until I get resolved. I will be available, regardless. So, I’ll have to hold back on this for a good while. Maybe a half a month.

G'MIC Filter Developer

Link to comment
Share on other sites

  • 3 weeks later...

It didn't seem like the nose was the problem in the end though I still have a surgery appointment for that. Maybe, I had a cold and that ended up in me suffering for 1 week with 1 hour of sleep (gotten past that). So, I am writing filters again.

 

Maybe I shouldn't really be doing this and take more rest. But, I'll probably do anyway.

if 1 to_gray fi #One Channel#
3,3,1,1
f. "
ang=pi*(50/180);
ix=x-1;
iy=y-1;
IX=ix*cos(ang)-iy*sin(ang);
IY=ix*sin(ang)+iy*cos(ang);
ix=IX;
iy=IY;
sur=(atan2(abs(ix),iy)-pi/2)/(pi/2);
!((x==1)&&(y==1))?sur*2:0;
"
convolve.. .,1,1 k.. blur 5 n -1,1
if 1 + 1 * 127.5 fi #if 8bit, then 0#

Paste this to code filter to see what I'm working on. It's a better version of emboss filter of my own as it applies to multiple channels at once. I'll probably have to add something in the end for legacy support or something.

G'MIC Filter Developer

Link to comment
Share on other sites

Nah, I don't think I"ll be interested into doing emboss. I'm having legit trouble trying to create the bias factor, and normalizing it. So, That's on hold. As a matter of fact, I do have a workaround to that.

 

Now, I think I actually got something here, but it's different. Paste it within code[global] or code[local] to see how this works.

repeat $! l[$>]
Sublevel=1
Angle_Stitch=75
Thickness=1
Interpolation=3
Intensity=100
Boundary=1
iw={w}
ih={h}
ang={pi*($Angle_Stitch/180)}
ang2={pi*(($Angle_Stitch+90)/180)}
r {($Sublevel+1)*100}%,{($Sublevel+1)*100}%,100%,100%,1
{w},{h},1,1,sur=x*cos($ang)+y*sin($ang);floor(sur/($Thickness*($Sublevel+1)))
{max(1,round(iM,1,1))},1,1,1,u(1) round. map.. . rm. -. {iM/2} f. i<0?-1:1
repeat s#0 sh[0] $>
f. "sx="$Intensity"*cos("$ang2")*i#1;sy="$Intensity"*sin("$ang2")*i#1;sx+=x;sy+=y;i(sx,sy,z,c,"$Interpolation","$Boundary")" rm. done rm.
r {$iw},{$ih},100%,100%,{$Interpolation}
endl
done

Based off the principle of @pyrochild Stitch plugin. I will be adding more options, and enabling multiple angles(not just two).

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

New updates will come soon. Just bug fixes, and removal. These changes will come by next week as it's Saturday. Right now, this update isn't here yet, but letting y'all know.

  1. Spiral Matrix Transform has been removed. It is obsoleted by Joan Rake's Spiral Matrix Transform. That also works on images bigger than 4096x4096. So, no reason to keep this anymore.
  2. Logarithmic Distortion has been fixed. There should be no crash.
  3. Nebulous has further fixes, and a slight upgrade.

 

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

I want to make sure of this. Is it worth improving Vibrato and OOBS? I don't feel like they're used all that much. I know exactly how I can improve Vibrato, but it seem fine for one color image as you can get abstract there. I'm about to extend Modulo Texture further.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Decided to extend my existing Color Modulo Texture after reading more of @MadJik thread. I was basing my older version off the one that I had. Now, here's the cli options.

#@cli rep_color_modulo_texture: 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
_diagonal_flip= { 0=not flipped | 1 = flipped },_subpixel_processing_level>0,0<=_interpolation<=5,0<=_colorspacemode<=12,_contain_alpha= { 0=no_alpha | 1=alpha },\
0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4

And a image to go with the upgrade of my own Color Modulo Texture.

 

image.png.b62ccb3304fe6e4a8c6c9c554bac8246.png

 

That's CMYK color modulo texture with everything centered and no angle change using continuous divisive modulo mode. Beautiful, huh?

 

For those who wants the code early before G'MIC can actually update again :

 

@cli rep_colmt: (eq. to rep_color_modulo_texture)
rep_colmt: rep_color_modulo_texture $*
#@cli rep_color_modulo_texture: 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize },\
_diagonal_flip= { 0=not flipped | 1 = flipped },_subpixel_processing_level>0,0<=_interpolation<=5,0<=_colorspacemode<=12,_contain_alpha= { 0=no_alpha | 1=alpha },\
0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4
#@cli: Inspired by MadJik's Color Modulo Texture for Paint.NET, this is a extension of that filter converted into G'MIC form. New features is being able to change color space, allow alpha, anti-aliasing...
rep_color_modulo_texture:
repeat $! l[$>]
lcmod_1=$38
lcmod_2=$39
lcmod_3=$40
lcmod_4=$41
cs=$36
alp=$37
diag=$33
interpolation=$35
subpixel=$34
subpixel+=1
tc={$cs!=3?3+$alp:4}
iw={w}
ih={h}
maxv={max(w,h)}
sd={min(w,h)/max(w,h)}
sx={w<h?$sd:1}
sy={h<w?$sd:1}
msx={.5*$sx}
msy={.5*$sy}
center=1
f 0 r {$interpolation?$subpixel*100:100}%,{$interpolation?$subpixel*100:100}%,100%,$tc
($lcmod_1,$lcmod_2,$lcmod_3,$lcmod_4)
l. 
    s x ti=$! remove_duplicates 
    if $!!=$ti v + error "Invalid channel inputs!" v - fi a x 
endl
repeat $tc sh[0] {i(#1,$>,0)} done rm[1]
f[1] ang=pi*($4/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IX+=!$6?$msx;IX*=$maxv;ix=IX;ix/$subpixel abs[1] modf[1] $1,$2,{$3/$2} 
    if {$8&&($1<2)} +[1] {$3<$2?$3} fi 
    if $7 negate[1] fi 
    temp={im#1} -[1] $temp modf[1] 4,{iM#1},$5 +[1] $temp
f[2] ang=pi*($12/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IY=ix*sin(ang)+iy*cos(ang);IY+=!$14?$msx;IY*=$maxv;iy=IY;iy/$subpixel abs[2] modf[2] $9,$10,{$11/$10} 
    if {$16&&($9<2)} +[2] {$11<$10?$11} fi 
    if $15 negate[2] fi 
    temp={im#2} -[2] $temp modf[2] 4,{iM#2},$13 +[2] $temp 
f[3] ang=pi*($20/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IY=ix*sin(ang)+iy*cos(ang);IX+=!$22?$msx;IX*=$maxv;IY+=!$22?$msx;IY*=$maxv;ix=IX;iy=IY;($diag?(abs(ix)+abs(iy)):abs(abs(ix)-abs(iy)))/$subpixel modf[3] $17,$18,{$19/$18} 
    if {$24&&($17<2)} +[3] {$19<$18?$19} fi 
    if $23 negate[3] fi 
    temp={im#3} -[3] $temp modf[3] 4,{iM#3},$21 +[3] $temp 
if $tc==4 
    f[4] ang=pi*($28/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IY=ix*sin(ang)+iy*cos(ang);IX+=!$30?$msx;IX*=$maxv;IY+=!$30?$msx;IY*=$maxv;ix=IX;iy=IY;(!$diag?(abs(ix)+abs(iy)):abs(abs(ix)-abs(iy)))/$subpixel modf[4] $25,$26,{$27/$26} 
    if {$32&&($25<2)} +[4] {$27<$26?$27} fi  
    if $31 negate[4] fi 
    temp={im#4} -[4] $temp modf[4] 4,{iM#4},$29 +[4] 
fi
k[0]
if $interpolation&&($subpixel>=2) r $iw,$ih,100%,100%,$interpolation fi
if $cs!=3
    if $cs!=0 sh 0,2 fi
    if $cs==1 ryb2rgb.
    elif $cs==2 cmy2rgb.
    elif $cs==4 hsi82rgb.
    elif $cs==5 hsl82rgb.
    elif $cs==6 hsv82rgb.
    elif $cs==7 lab82rgb.
    elif $cs==8 lch82rgb.
    elif $cs==9 yiq8rgb.
    elif $cs==10 yuv82rgb.
    elif $cs==11 yuv82rgb.
    elif $cs==12 xyz82rgb.
    fi
    if $cs!=0 rm. fi
else
    cmyk2rgb
fi
endl done

For some reason, rep_colmt didn't work. Paste this to userxxxx.gmic, then go into code[local] and paste this to get the result like I had - rep_color_modulo_texture 3,255,64,0,0,1,0,0,3,255,64,0,0,1,0,0,3,255,64,0,0,1,0,0,3,255,64,0,0,1,0,0,1,1,3,3,1,0,1,2,3

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Even though 2.7.0 is not available for Paint.NET and you won't see this update, during the meantime, I"ll post changes that'll be coming.

 

New Changes: 50 new palettes, fixes to distortion filters - For details - Fixes to distortion filters, and 50 new palettes #196

 

EDIT: Next up, I"ll probably make a way to export those palettes. But, it's more likely I"ll work on modulo and continue into developing the concrete texture.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

More updates coming. New Filter named Stitch. Based off the principles of @pyrochild Stitch Paint.NET plugin. There's more features to the G'MIC version that I have made than the stitch paint.net plugin. You can have 12 stitch angle, make stitching random or uniform, anti-aliasing, change subpixel processing level, change the repeat level.

 

- Here how it looks like below -

 

image.png.04d02f22318319ce6f2cc65fd46533ff.png

 

 

  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

New filter is in work

 

55e577345fee52125bae851a24fc4b75588cabfd

 

Based off TR Tiled Pixels. New features would be:

 

- Custom tile width and height

- Subpixel processing

- Rotation of shape / Flip Shape

- Alter how much shape fill the tile

- Support for custom shapes, you have to make a new layer and use grays only for this(more on that when released to github)

-20+ shapes support

 

It's a bit slower than @TechnoRobbo filter when subpixel processing are done. 

 

I haven't looked at his algorithm or source code, but this filter of mine is based off weighted averaging using shape, and the last channel is treated as shape cropped. GUI filter will convert to rgba if 3 channels are used, but that only affects GIMP.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

  • 2 weeks later...

Well, looks like the tiles_shape will be on hold. I decided to make it even faster, and awaiting skip bug fix on g'mic. Meanwhile, I made the g'mic version of object pruner though it might need more work. Is anyone interested into alpha based on shape separation and their size? I might extend the g'mic version to support filter object based on mode of colors rather than plain black and white. I guess Object Pruner can be extended this way, but I can't speak for the developer of it.

 

@MJW Decided to call since I'm sharing idea here, and made something based on the principle of the Object Pruner plugin.

 

Early code development of g'mic version of object pruner (not representative of current code). I also can make the alpha depending on pixel size. I'm sure that can be of use. vv is just going to be used to determine if alpha variance is the same, and therefore skip the code if variance is zero. I can't explain the begin thing or the >i in f blocks, I was just testing values and seeing how they work, but I don't know how as I copied from blend_shapeaverage0 code found in user.gmic. The rest is easier to understand. f is basically equivalent to function most of the time. Label assigns unique number to shapes of repeating values, and shapes are also treated as object. rm removes layers. channels is used to extract a channel. sh created a linked copy where specified number is a channel or ranges of channel.

val_a=0
val_b=.01
minv={min($val_a,$val_b)}
maxv={max($val_a,$val_b)}
vv=0
+channels {s-1}
f. i==0?0:1 .
f[2] "begin(A = resize([ 0,(s-1)/s ],s,3));I+A" norm[2] round[2] 0.01 label[2] 0 {iM+1},1,1,{0,1}
f[1] ">i(#3,i(#2,x,y,z,0),0,0,c)+=i;i" map[2] . rm[1,3] n. 0,100 sh[0] {s#0-1}
f. ma=$minv*iM#-2;mb=$maxv*iM#-2;(i#-2<ma)||(i#-2>mb)?0:i
rm[1,2]

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

  • 4 weeks later...

New Filter - Kaleidoscope [Polar]

 

I know it already exist in G'MIC, but this is my own version based on @Xhin Polar Kaleidoscope. Basically extended version of the G'MIC and his version.

 

@Xhin - You might be interested into looking at the code to see how to finish the filter. I can't translate the i(...) part into codelab code, but the rest should be do-able in codelab.

 

Code is in this link - https://github.com/dtschump/gmic-community/pull/200/commits/6ddf5111842c4e6c537c4a9f67e01ccc99f03a1c

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

My version of Polar Kaleidoscope has been pushed.

 

Also, I have made my own version of Object Pruner by @MJW. Functionally, they act the same for the most part, but mine has the option to work with any RGB or RGBA color besides just alpha, black, or white. Another difference is that even if you're seeing what is going to be erased, the objects will disappear upon applying filter. That been pushed too. So, you should have those filters soon.

 

For reference, rep_objvf can work on any color space. It always use last channel unless color is specified and in that case, it finds that color and a new channel is processed, then delete the new channel.

 

Edited by Reptillian
Clarifying...
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Extended version of @TechnoRobbo Tiled Pixels 1.2 is certainly coming in less than a week. With img2var and var2img just implemented, I been able to overcome speed limitation with using layer as reference. It supports custom transform, rotation per tile, anti-aliasing, dynamic shapes, non-square tiles, 25 shapes including layer as one of those shape.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Link to comment
Share on other sites

Well, I submitted a few fix to my recent filters. Added Tiled Pixels as well.

 

Here's the link to pull request - Fixes to recent filters, and new filter #201

 

And, decided to add a picture to show off

 

image.png.000d18a227c3aba937d66bdda776cfce.png

 

Result of Tiled Pixels being processed on HSL colour space with polygon dynamic option set to 5

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

offset_x=0
offset_y=-0*-1
mode=0; #HARD;MEDIUM;SOFT;DESTROY#
{w},{h},100%,4,0
#Formula creates the basic donut#
f. "
ang=110;
ang=pi*(ang/180);
r=max(w,h)/min(w,h);
xx=((x/w-.5)*2)*(w>h?r:1);
yy=((y/h-.5)*2)*(h>w?r:1);
sph=sqrt(xx^2+yy^2);
mv1_sph=1;
mv2_sph=.4;
max_val_sph=max(mv1_sph,mv2_sph);
min_val_sph=min(mv1_sph,mv2_sph);
sph_bnd=sph>max_val_sph||sph<min_val_sph?0:1;
nv_sph=((1/((max_val_sph-min_val_sph)/1))*(sph-max_val_sph)+max_val_sph);
nv_sph-=.5;
nv_sph=cos(nv_sph*pi)*sph_bnd;
XX=xx*cos(ang)-yy*sin(ang);
YY=xx*sin(ang)+yy*cos(ang);
xx=XX;
yy=YY;
xx/=2*(w>h?r:1);
yy/=2*(h>w?r:1);
xx+=.5;
yy+=.5;
[nv_sph,sph_bnd,xx,yy];
"
shift. {($offset_x*100)/2}%,{($offset_y*100)/2}%
f.. "
donut_x=i2#-1+"$offset_x"/2;
donut_y=i3#-1+"$offset_y"/2;
donut_opacity=i1#-1;
donut_depth=i0#-1;
xx=(x/w);
yy=(y/h);
donut_xx=donut_opacity>0?donut_x:xx;
donut_yy=donut_opacity>0?donut_y:yy;
xx=donut_xx*donut_depth+xx*(1-donut_depth);
yy=donut_yy*donut_depth+yy*(1-donut_depth);
i(xx*w,yy*h,z,c,2,3);
"
k..

Now, I'm working on extending the donut distortion filter made by @MadJik. Paste this to code[local]/code[global] to see what happens.

 

From what I see, here is what can be extended

  1. Distortion Inversion Option
  2. Offset (even outside boundary)
  3. Boundary Condition
  4. Bi-cubic Interpolation
Edited by Reptillian
Code fixed.

G'MIC Filter Developer

Link to comment
Share on other sites

Another new filter coming up - Non-existent Color Noise Filter

 

The above is the target image, and bottom are all colors that don't exist within the target image. That includes the gap color. This filter was made to an answer a problem a user was having which was to create random colors that does not exist in a image. Colors might look similar until you check with color dropper, they are all different colors.

 

Pull Request - https://github.com/dtschump/gmic-community/pull/202/commits/2acc9d18a2d3f392ec7549f6e06e10a5926e933d

 

The thread of inspiration -

@FiveShipHUN Just in case you still need it even though it been a long time.

 

Using the image found in that thread, here's what I get

 

None of these colors exist in the image made by @FiveShipHUN

Edited by Reptillian
Deleting attachment picture.
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Only a post to notify that the new filter 'Tiled Form' filter has arrived in the latest g'mic. Now you can create tiled forms with even more options than the original plugins. Though the colors won't be the same because of different algorithm being used. TR version uses coordinates to find color while my version samples the average colors. Special note - HCY seem to be the best color space channel to process 'Tiled Form' on.

 

Some few other changes

-Fixed 'Object Size Filtering' Alpha processing. Now it is consistent with elimination options. Also, clarified more on which gets eliminated.

-Extended Polar a bit more

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Some news. Those changes will come to 2.7.2. G'MIC QT 2.7.1 is no longer supported.

 

- Color Existence Distribution [RGB8] gui filter has been created. That means by the time it gets here, I'll explain how it works on paint.net in this tutorial below (You can still do this without the update as I provided the code to use in code[local] or code[global] in the gui filter):

- A slight fix has been made to Group Pixels Axis... to make it a bit more compatible with color existence distribution. At this point, I'm thinking of rewriting this filter to make it work with color existence distribution.

- rep_isprime, and rep_prime_surface cli command has been created. Just a warning, you may not want to make 1024x1024 prime surface because it takes so damn long to generate as it's using this code (see below). It uses for loop to determine if a number is prime.

 

#@cli rep_isprime:
#@cli: Checks if all values are prime number. The fill function rounds float number to nearest value.
rep_isprime:
f "isP=1;
for(in=2,in<=int(round(abs(i)))/2,++in,isP=round(abs(i))%in==0?0:1;if(isP==0,break()));
isP=round(abs(i))>1?isP:0;
"
#@cli rep_prime_surface: _width,_height,_negate= { 0=do_not_negate | 1=negate },_mirror
#@cli: Creates a simple prime surface by combining rep_isprime 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)}
if $3 negate. fi
if abs($4)==1 mirror. x
elif abs($4)==2 mirror. y
fi
rep_isprime.

Some other news - I'm fixing my color modulo texture command. It'll be faster, and it's using shared rather than separate channel.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...