Reptorian's Smaller G'MIC Thread: Small quality of life things.

Well, as you all know I’m not making new filters for production, mainly because I decide to focus on re-factorization and improvement to my G’MIC scripts. There are still two roadblocks that I have to go through before that can even happen. And they’re not even small roadblocks, they’re huge.

So, I decide to make a new thread, specifically not to announce new filters, but small quality of life improvement. And some missed things too.

Here will there be some ideas that I have in mind for improvement of my old filters, and possibly be useful for others.

Some few recent commands I have pushed into gmic-community:

rep_pf_args # Return argument with prefix/postfix added
rep_substr_ret_args # Return arguments that contains substring
rep_concat_imgs_vals_uniq # Output concatenated image values. Actually, I don't know why would you use it, but it's something I thought about.
rep_uniq_args # Return unique arguments
rep_sug_args # Return arguments that are close

These don’t do much for image processing. However, those are pretty good for making error messages, which is why I have made them. So, hence, they do provide a small quality of life improvement though 3rd one is questionable, but I can use that as a workaround if G’MIC ever receive direct unicode support and being able to get around 0-255 annoyance.

Some missed bit:

#@cli rep_digamma:
#@cli : Return the Logarithmic deritative of the Gamma function
#@cli : Original code has been made by Mark Johnson. Permission has been granted to use his code. Link to source - http://web.science.mq.edu.au/~mjohnson/code/digamma.c
rep_digamma:
eval "
	digamma(n)=(
		result=0;
		p=n;
		while(p<7,
			result-=1/p;
			++p;
		);
		x0=p-(1/2);
		xx=1/x0;
		xx2=sqr(xx);
		xx4=sqr(xx2);
		result+=log(x0)+(1./24)*xx2-(7/960)*xx4+(31/8064)*xx4*xx2-(127/30720)*xx4*xx4;
	);
	digamma($1);"

This one I made it to calculate digamma, but I think I would rather have this seen in the math parser language.

Finally, I made this recently as there is a code that I have which has the following string: “1,1,1,2,2,2,3,3,3,4,4,4,5,5,5”. That can be shortened to ${rep_ls\ 1,5,5,3}.

#@cli rep_ls: start_num,end_num,size_of_array,repeat
#@cli : Return linear space sequence.
rep_ls:
check isfinite($1)&&isfinite($2)&&isint($3,1)&&isint(${4=1},1)
if $3==1 u $1 return fi
u {expr('$1+y*{($2-$1)/($3-1)}',$4,$3)}

Result of this:

C:\Windows\System32>gmic e ${rep_ls\ 2,10,5}
[gmic]./ Start G'MIC interpreter (v.3.7.3).
2,4,6,8,10
[gmic]./ End G'MIC interpreter.
C:\Windows\System32>gmic e ${rep_ls\ 1,5,5,3}
[gmic]./ Start G'MIC interpreter (v.3.7.3).
1,1,1,2,2,2,3,3,3,4,4,4,5,5,5
[gmic]./ End G'MIC interpreter
1 Like

Hi, nice things here. But when I tried the rep_concat_imgs_vals_uniq it gave me info about the first 415 images of the sequence, then it crashed before it could parse the remaining 50 or so images… must be a memory thing on my underpowered Android tablet, but I was wondering if there could be a workaround for this, perhaps?

I deleted that command recently. The thing is it’s not for normal images. It’s for tiny image because the helper command is designed for strings, so (20 pixels at most). What sizes were the images at and why did you need it? And yes, there is a workaround involving remove_duplicates and eval copy() as remove_duplicates doesn’t use hash (This makes it work on normal images).

@Mushy : I brought it back.

Optimized for normal images. A caveat, values can exceed 1<<24. In which case, you’d need to compile G’MIC to use 64-bit precision images.

1 Like

Sorry for the delay.

‘What sizes were the images at and why did you need it?’

They were all 1280x800, to be honest I was merely trying it out, as I had little idea about what it was for apart from your descriptive comment:

# Output concatenated image values. Actually, I don't know why would you use it, but it's something I thought about.

So the reason I used it was simply: because it was there !
But now I have a better idea what it’s all about, thanks for that. :smiley:

I have added some bit of combinatorics tools in my library.

Actually, there’s a unpublished reference here - gmic-community/reference/gmic-community-reference/Reptorian/Combinatorics at Reptorian1125-combinatorics-library-reference · GreycLab/gmic-community · GitHub

It’s bigger than itertools, bigger than moreitertools. Possibly the second largest combinatorics library out there. Only rivaled by Mathematica and friends.

It’s unpublished because I want it to be clear, so review is on hold.

I plan to use RDE series for Markus-Lyapunov because of the string structure in its input.

In Markus-Lyapunov, you have input strings that contains the following conditions:

  • String with only { A, B, C } at least once of any length for 3D.
  • String with only { A, B } at least once of any length for 2D.

I did added return quantity for all the possibilities for each combinatorics, so I can do math things with them to make GUI interfaces.