Jump to content

Reptorian's G'MIC Code Workshop


Reptillian

Recommended Posts

Some of you may notice that some of my filters has broke. That's because @G'MIC has updated gmic internals to have functions like fill(), and repeat(), and I had made a commit to replace for loop with repeat().

 

It's done because they are to be optimized. So, one should wait until next g'mic update to use them.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Decided not gonna release that filter because there is a problem with current implementation of quadrilateral distort. Particularly when the quad is so distorted that nan values start showing up.

 

So, I went to work into a random bars filter. One that will eventually be more flexible than @pyrochild gradient bars. None of his/her code has been used, it's entirely a new code.

 

bd2879e996da6a09c1b3a9710ea299c38f0eb89e

 

Spoiler

rep_random_gradient_bars:
skip ${11=}
#$1=Width#
#$2=Spacing#
#$3=Divisions#
#$4=Angle#
#$5=Skew_Angle#
#$6,$7=Position#
#$8=Gradient Shift#
#$9,$10=Gradient Min/Max Multiplier#
#$8=Grayscale#

specified_mode_out={narg($11)}


f "begin(
  const ww=w-1;
  const hh=h-1;
  const sd=max(ww,hh)/min(ww,hh);
  const sx=ww>hh?sd:1;
  const sy=ww>hh?1:sd;
  const wwsx=ww*sx;
  const hhsy=hh*sy;
  const pyth_img=sqrt(ww^2+hh^2);
  const ww_div_sx=ww/sx;
  const hh_div_sy=hh/sy;
  const cx=ww/2;
  const cy=hh/2;
  const ox=cx-(cx*$6);
  const oy=cy+(cy*$7);
  const skew_ang=($5/180)*pi;
  const mdist=tan(skew_ang)*pyth_img;
  const ang=($4/180)*pi;
  const cos_ang=cos(ang);
  const sin_ang=sin(ang);
  const cut_ang=atan2(cy,cy);
  const cut_ang2=pi-cut_ang;
  const total_width=$1+$2;
  const spacing=($2/(total_width-1))/2;
  
  rot_x(a,b)=a*cos_ang-b*sin_ang;
  rot_y(a,b)=a*sin_ang+b*cos_ang;
  fmod(a,b)=a-b*floor(a/b);
  
  const trimmed_ang=fmod(ang,pi);
  const nbars=((trimmed_ang>=cut_ang)&&(trimmed_ang<cut_ang2))?ceil((abs(1/sin(ang))*ww)/total_width):ceil((abs(1/cos(ang))*hh)/total_width);
  const shift_bars=int(nbars/2);
  
  v_base=vectornbars(0);
  v_shift=v_base;
  v_mult=v_base;
  v_modulo_mode=v_base;
  v_use_invert=v_base;
  
  $8!=0?fill(v_shift,u(-$8,$8));
  fill(v_mult,u($9,$10));
  fill(v_modulo_mode,round(u(0,2)));
  fill(v_use_invert,round(u(0,1))==1?1:-1 );
  if(narg($11),
   const outmode=$11%3;
   outmode==2?v_modulo_mode=vectornbars(2):
   v_modulo_mode=vectornbars(1);
  );
 );
 initial_x=(x-ox)/ww*sx;
 initial_y=(y-oy)/hh*sy;
 gradient=rot_y(initial_x,initial_y)*hh_div_sy/pyth_img;
 point_x=rot_x(initial_x,initial_y)*ww_div_sx+gradient*mdist;
 bars=(floor(point_x/total_width)+shift_bars)%nbars;
 spaces=abs(fmod(point_x,total_width)/total_width-.5)>=spacing;
 spaces?(
  new_gradient=gradient*v_use_invert[bars]*v_mult[bars]+v_shift[bars];
  fmod(new_gradient,10);
 );
 "

 

As you can see the code is different.

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

@Ego Eram Reputo @lynxster4 Thank you for the feedback.

 

So far, the gradient bars is nearly done. For proof (I got duotone color to work):

 

085ffd5a86889f3644d7c6ff251196b1f76ad0b7

 

TODO:

 

1. Add Duotone option for spaces.

2. Add animation support.

 

For such a simple idea, that's a lot of work. Maybe for just spaces filling, I could just make a separate command for that, and then combine both as a gui filter.

 

Side note:

 

Lyupanov Fractal is under work

 

unknown.png

Edited by Reptillian
  • Like 2

G'MIC Filter Developer

Link to comment
Share on other sites

You are busy, busy, busy @Reptillian!  Keep up the good work...we all appreciate very much!  👍 😊

 

Link to comment
Share on other sites

  • 2 weeks later...

Other than the Lyapunov, I had fixed the Random Gradient Bars, it is now more controllable there. But, this isn't noteworthy here because I had created the CodeLab version of the filter.

 

So, I will show that I made another coloring mode to Lyapunov Fractal.

 

31b82fd80403beb25b7318134bfe487a4b1d1f66

HzJdTxz.png

 

Here's what is missing with the Lyapunov Fracta.

 

1) Custom coloring support. That means 2 more modes are TODO. One mode for defining colorings of negative/positive, and the other is a map toward the ranges of the Lyapunov Fractal.

2) Grayscale Mode. This means that it'll be the default output or negative output.

Edited by Reptillian
  • Like 1
  • Upvote 1

G'MIC Filter Developer

Link to comment
Share on other sites

New Filter! - Weighted RGB To Grayscale

 

ak2k77hs4i771.png?width=584&auto=webp&s=

 

af503983e4ac9d13c877b20b99773c24ab1d6b29

 

Based on MJW Black and White + PDN plugin, I have decided to make my own twist based on some of the principles found in that plugin. This is my own take on the ideas founded on that plugin.

 

The main difference is that it doesn't support color interpolation, and it doesn't need to in context of some image editors as they do support high depth, and the way Min-Max Interpolation behave.

 

@MJW - Do you want me to add credits within the GUI since I had only made the code just on principles?

  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

  • 3 weeks later...

Now, I had pushed a new version of Diffusion Limited Aggregation.

 

Changes according to commit log:

 

Quote

Upgrade to Diffusion Limited Aggregation

 

Changes:

1. The use of meta-coding to generate proper multi-threaded code on the fly. Much of the behavior of the very old single-threaded rep_dla has been retained, and much better retained in this version.

2. It is now fast enough that preview makes perfect sense.

3. Filter can be applied to multiple images.

 

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

  • 3 weeks later...

That is so cool @Reptillian!  It looks like a skeletonized alien head. I love it!  🥰

I take it, this is for GMIC?

  • Like 1
Link to comment
Share on other sites

6 hours ago, lynxster4 said:

That is so cool @Reptillian!  It looks like a skeletonized alien head. I love it!  🥰

 

Agreed. It's very H R Geiger :devlish:

  • Like 1
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...