Jump to content

Reptorian's G'MIC Code Workshop


Reptillian

Recommended Posts

15 minutes ago, BoltBait said:

More like my brain after looking at G'MIC scripts... they literally make NO sense to me at all.

That how it was for me when I started out on G'MIC. There's actually a lot of different ways to do different things, and I had to learn basic things like f block (for x,y,z loop block), eval block, shared channels, etc and that with a vast command within gmic stdlib like index, sort, resize. It gets easier like with other programming language, and reading up on references makes it easier to understand over time. Fill block code is the easiest to understand because it's basically for x, for y, for z where begin can contain variable before for x,y,z and end can contain variable after the first part of for x,y,z loop. I know you don't plan to do gmic coding, but I'd just like to share details on how it was for me, and I'm also available if you'd like to convert a g'mic script into a pdn plugin.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

11 hours ago, LionsDragon said:

Frost on the windows!

 

I second that! 

  • Like 1
Link to comment
Share on other sites

Now, I am working on adding masking features to DLA filter.

 

72805d0f5c80e5a512c547d4ab334e7c422f8ffb

 

You see that it is growing around the test? The test letter is the image. And yes, I will add a option to erase the image mask though I have to figure out how to display only the "sprouts" or something.

 

EDIT: Solved it.

 

5ac0a9e22e1c88e85e8faf73fe3361ad8317c13d

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

New Filter! - Pseudorandom Noise

 

The advantage of this version over the Regular Noise Texture plugin is that it's far easier to use, and some bugs are addressed. There's also way more variety that is possible. I will say that the colors are not the same because of the underlying mathematical difference within c++,c# in context of float to int.

 

Note: There is a bug on the filter with double pixel axis mode, but single pixel axis looks better anyway, so I wouldn’t be so pressed about it. I will fix that bug when the time comes. It probably shows up with a specific dimension, so if you do come with the 3 pixel axis bug, let me know the dimension and which axis.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

I had created another new filter. @MJW did a existing filter called Posterize in HSV space. So, I coded it my own version that allows for indexing in HSX color space or posterize using mathematical operation. It'll come tomorrow. I can't really say it's interesting, but it's a good exercise to work with 3 dimensional cube with 3 color channel per pixels.

 

To clarify:

 

$hb,$scb,$lub,3,[floor(360/($hb-1))*x,y/($scb-1),z/($lub-1)]

 

$hb = Hue Band

$scb = Saturation Band

$lub = Luminosity Band

3 is the number of channel on that argument

[] defines the colors that exists within the band. x is of course x-coordinate of pixel, y is y-coordinate of pixel, and z is z-coordinate of pixel.

 

This is used for indexing colors based on the above box. Indexing can be pretty slow as you can do this with 50x50x50 which means indexing using 125000 colors.

 

Posterize doesn't really use 3-dimensional box.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

New Filter! - Tiled Zoom

 

It's pretty much only a slight upgrade to @Ed Harvey Multiview plugin. You can change the width and height independently. It doesn't have boundary option of original, etc because you can already do that with none and the existing layer, so it's pointless IMHO. I figured out how it works when I thought of the theory to have repeating row and column gradient that goes from -v,+v, and to use j which means offset away from current x,y within for x,y loop.

 

To expand:

 

Snippet of rep_tiled_zoom:

 ix=(x+iox)%"$sqr_w"-cx;
 iy=(y+ioy)%"$sqr_h"-cy;
 nx=ix*sd;
 ny=iy*sd;
 fx=nx-ix;
 fy=ny-iy;
 j(fx,fy,0,0,2,boundary);

 

iox,ioy means offset required for the window to be the same on edge.

cx,cy is half window size.

ix,iy creates the gradient.

nx,ny are scaled gradient.

fx is the difference.

j means away from pixel. so -1 means the color will be based on image pixel 1 pixel to the left.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

If you updated the filter now and see nothing, check by a day. Otherwise:

 

I added Fill Tool to Non-Isometric Tiler filter. Please read instruction to see how to use it. I have not enabled the fill for symmetry mode just yet and probably won't do so for some time. In most cases, you don't need to fill with symmetry conditions, and the current painting with symmetry mode does that job anyway if careful.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Decided to try to generate Chirikov-Taylor Standard Map.

 

A preview

 

$ rep_chirikov_taylor_map 5000,20000,pi/3,3610,1 n. 0,359.999 +f. i?1 . . *. 255 a c hsv2rgb r 500,500,100%,100%,5

 

a80abf855d5aa7d74088ddd1dd7d9cb69827e56c

For plugin authors:

Spoiler

Code for Chirikov-Taylor Map.


rep_chirikov_taylor_map:
skip ${2=5000},${3=1.52},${4=100},${5=.25}
#$1==size#
#$2==loop#
#$3==k#
#$4==lines#
$1,$1,1,1
eval ${-math_lib}"
const pts=$2;
const k=$3;
const dpi=2*pi;
const lines=$4;
fmod(a)=a-dpi*floor(a/dpi);
xi=0;
iy=expr('x/w*2*pi',lines,1);
for(n=0,n<lines,n++,
 yi=iy[n];
 for(ptn=0,ptn<pts,ptn++,
  yi=fmod(yi+k*sin(xi));
  xi=fmod(xi+yi);
  i(#-1,round(xi/dpi*w#-1),round(yi/dpi*h#-1))=n;
 );
);
"

 

 

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

New Filter! - Chirikov

 

Additional comment:

Right now, I would say that this is practical for use though preview isn't always accurate. This is based off Chirikov Standard Map, and I have implemented the symmetry modification after reading a paper made by Artur I.Karimov, Denis N. Butusov, Vyacheslav G. Rybin, Timur I. Karimov within Department of Computer Aided Design at Saint Petersburg Electrotechnical University. Furthermore, this isn't limited to square ratios, and you have so many different ways of coloring.

 

Just a note : Coloring based on last image is a TODO.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

I tested Chirikov-Taylor on G'MIC-QT 2.9.2. As some of you noticed, there is a error that says this:

 

Quote

Command 'eval': Unrecognized function call 'expr('x/w*2*pi',lines,1)' in expression '...iy=expr('x/w*2*pi,lines,1)...'.

 

expr is only available on g'mic-qt 2.9.3 and higher. So, this cannot be used. I don't test my filters on pdn since krita and gimp takes priority since gmic-qt are almost always updated in those.

G'MIC Filter Developer

Link to comment
Share on other sites

Update on RPG Tiler Tool. I added undo state for row/column editing mode. Now, if you delete row/column, you can undo. If you shift row/column, you can undo. I think I know how to do multiple undos for the tool though that would take a lot of time. I just would need to create 3-dimensional image containing changes done to the image, and work with that. That would take time if I can bother with it.

 

Update takes time to come to g'mic. Check by hour, then a day.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

  • 2 weeks later...

A more advanced version of the plugin I have updated is coming to g'mic-qt. I'm not updating the c# version as it's easier to add multiple color space as well as doing other things within g'mic-qt.

 

4e4f937b5ba28b24a0264b96c5d666ad0ec03ae8

e0604eb26f54046575f24b32405e7906c66c7d27

As you can see, you can blend layers' channels individually or do modulus operation with a number. And this with the option of using different values per channels per 2 layers. The top one is RGB, and the bottom one is HSV.

 

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Modulos Operation has been upgraded. Essentially a more advanced version of the plugin I created. So, if anyone wants more option to that plugin, I will direct them to this filter instead.

 

https://github.com/dtschump/gmic-community/commit/e6bc8afacaf673e37bbc4d4aa5af2ce0566231de

 

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

@kratom the tree

 

I'm gonna work on a filter based off Isometric Tiler tool concept. I will address the option to use any size, and this will naturally be addressed too :

 

Quote

If the canvas is not large enough to fit all the tiles they will not be added to the canvas.

 

Here's the proof of work:

 

lAywxJt.png

Right now, my only problem is that this works with only power of 2. 8,16,32,64,128,256.... Probably not that big of a deal considering those size are standard.

 

rep_shape_isometric_tiles:
size={int($1/4)}
$size,$size,1,1,begin(hh=h-1;);(x+1)>(hh-y)?1
r. 200%,100%,100%,100%,1
ww={w}
hh={h}
$1,{$1/2},100%,100%,((x>=$ww)&&(y>=$hh)?i(#-1,$ww-x%$ww-2,h#-2-y%$hh-2):y>=h#-1?i(#-1,x,$hh-y%$hh-2):(x>=$ww?i(#-1,$ww-x%$ww-2,y):i(#-1)))
rm..

 

  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

  • 3 weeks later...

Well, I'm still stuck working with my laptop. I did managed to upgraded Tiled Form. There is only one new option - `Fit Tile?` which would preserve the shape of your chosen form. It is 2x faster now.

 

In addition, Popcorn Fractal has been upgraded to be faster a while ago, but you'd probably know that if you visited my Popcorn Fractal thread. Popcorn use unsafe multithreaded processing, so I have yet to see if there's going to be a problem here. On larger image, it can be 150% to 200% faster than c# version.

 

Commit - Upgraded TIled Form/rep_form_pixel

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

I'm adding a new feature to Tiled Form. It is going to take a while as I will factor into the existence of alpha channel and cmyka.

 

b187cf9315ac7abc896b81f9107f4ad13855090e

 

The left is original, the middle left, the middle right is max, and the right is average.

 

Also, here is how the min/max features work after getting some help from @G'MIC - https://discuss.pixls.us/t/return-maximum-value-coordinates-based-from-the-sum-of-channel-in-a-window-in-context-of-fill-block/21370/6

 

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

  • 4 weeks later...

I think I'm gonna ditch the min/max/average mode in favor of z_convolve. Here's why:

 

KFtC6BC.png

The left is what you get without z_convolve, and the right is what you get with z_convolve enabled. This will also be transferred to G'MIC-C# version when I'm finished with the gmic version. It looks better, right?

 

For programmer, z_convolve is basically convolving along z-axis within a 3D image. Yes, the coloring of each tile utilize a small 3D image, and each z represent the weighed average of inside and outside of shape.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

14 hours ago, Reptillian said:

I think I'm gonna ditch the min/max/average modes in favor of z_convolve. Here's why:

 

The right image simply looks much clearer.  👍

 

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...