A bit more work:
The only roadblocker is getting a workaround to the issue of macro and preferring it to be treated as function.
A bit more work:
The only roadblocker is getting a workaround to the issue of macro and preferring it to be treated as function.
I think I will skip over that since the macro part is a problem. There’s a more a interesting version provided by @weightt_an which by the way is the same person I referred to.
EDIT: Added color example.
EDIT: Removed code as now it’s more than just a code translation. Last two examples are custom expression which is on work.
EDIT: I believe I finished this work. Only GUI is to go.
New Filter! Lavander Binary Map
Here’s a result:
The current GUI filter consists of annoying paper cut bugs. There are some “bugs” cases that can’t be avoided due to how the algorithm work. If you were to use auto on different size image, different result is to be expected.
Also, if you were to look at the code in here - New Filter! Lavander Binary Map · GreycLab/gmic-community@662fa88 · GitHub
You can tell how difficult it was to make the GUI filter. There’s some TODO there too, and it took me 2 days to implement symmetry. It would take more than 1 or 2 weeks to finish up the TODO.
Imagine doing this without Python help, and I use Python in Pycharm to automate G’MIC coding processes.
@David_Tschumperle I noticed the changes in auto-commit release. That is going to prevent the filter from working as the other _0 variables are used to store temporary variables for comparison purpose. I’m guessing I should replace the spaces with  ?
I’ll take a look tonight.
I had to comment those lines, because they apparently has an incorrect syntax, and it breaks the filter update script.
It has been (partially) fixed. There seems to be a bug in the math parser when long strings are defined. I’ve done a workaround but I need to understand what is going on.
Is the error this?

Looking at the update:
#@gui :Python Source Code=_text(1,"def m_show(m,size = 4,cmap = 'afmhot'):\n import matplotlib.pyplot as plt\n from numpy import array\n cmaps = ['binary','gist_yarg','gist_gray','gray','bone',\n 'pink','spring','summer','autumn','winter','cool',\n 'Wistia','hot','afmhot','gist_heat','copper']\n plt.figure(num = None,figsize=(size,size),dpi=300)\n plt.axis('off')\n plot = plt.imshow(array(m),cmap = cmap) #,interpolation='bicubic' )\n plt.show()\n plt.close()\n\nfrom tqdm import tqdm\n\ndef get_matrix_bin(s):\n n = len(s)\n mat = [[0]*n for i in range(n)]\n for x in tqdm(range(0,n)):\n for y in range(0,n):\n f = format((s[x] ^ s[y]),'b').count('10')\n mat[x][y] = f\n #mat[y][x] = f\n return mat\n\nbig_n = 11\n\npows = [i for i in range(0,2**big_n)]\npows = sorted(pows,key = lambda k: format(k,'b').count('01'))\nadj_m = get_matrix_bin(pows)\n\nm_show(adj_m)")
#@gui :Stored Text=_text(1,"def m_show(m,size = 4,cmap = 'afmhot'):\n import matplotlib.pyplot as plt\n from numpy import array\n cmaps = ['binary','gist_yarg','gist_gray','gray','bone',\n 'pink','spring','summer','autumn','winter','cool',\n 'Wistia','hot','afmhot','gist_heat','copper']\n plt.figure(num = None,figsize=(size,size),dpi=300)\n plt.axis('off')\n plot = plt.imshow(array(m),cmap = cmap) #,interpolation='bicubic' )\n plt.show()\n plt.close()\n\nfrom tqdm import tqdm\n\ndef get_matrix_bin(s):\n n = len(s)\n mat = [[0]*n for i in range(n)]\n for x in tqdm(range(0,n)):\n for y in range(0,n):\n f = format((s[x] ^ s[y]),'b').count('10')\n mat[x][y] = f\n #mat[y][x] = f\n return mat\n\nbig_n = 11\n\npows = [i for i in range(0,2**big_n)]\npows = sorted(pows,key = lambda k: format(k,'b').count('01'))\nadj_m = get_matrix_bin(pows)\n\nm_show(adj_m)")_0
It is supposed to be {} instead of ().
First step, isolate the bug ![]()
Here it is:
bug :
srand 1 100,100,1,1,"round(u(32,126))" txt={t} rm.
expr={"['"$txt"']"}
That should be perfectly valid, but I get:
*** Error in ./bug/ (file '/home/tschumperle/.gmic', line #242) *** Item substitution '{['W/h|WpZf&$2-`NhsmstvV=/0K8b=(...)6t@dMd;}N3sEMM<Y;0.(j;i_Ky[']}': Unbalanced parentheses/brackets, in expression '['W/h|WpZf&$2-`NhsmstvV=/0K8b=t{xx@sj2`XGc6N&*MrbtDMP/sZ<Q|(...)'.
Indeed, so another thing to fix on my side.
That should be OK now.
I think I know what’s going on.
When you do “$txt”, you are converting the string as a expression to be evaluated. That’s a trick I have done so many time. Hopefully, your fix doesn’t hurt that. It’s quite a pro of G’MIC to have dynamic expression support.
No actually, it was simpler than expected.
As $txt was containing some single and double quotes, the expression was actually wrong.
The correct expression is:
expr={"['"{/$txt}"']"}
that uses the construct `{/string}’ to generate an “escaped”-version of the string.
I’m glad it’s found, but I can’t help but laugh at the construct… any more brackets or quoting we could fit in there? ![]()
I can confirm that Lavander Binary Map works as expected.
You should have a look at regex.
Here’s my case of utilizing regex within Python to make easier G’MIC coding.
level_0=r'(\#@gui\s*:|\)\,(?=([A-Z]|[0-9])))(.*)=(int|float|choice|text|bool|button|point|color|folder|file|text|_int|_float|_choice|_text|_bool|_button|_point|_color|_folder|_file|_text)(\(.*\)|{.*})(.*)'
level_1=r'((?<=\)),(?=[A-Z])|(?<=\}),(?=[A-Z])|(?<=\)),(?=[0-9])|(?<=\}),(?=[0-9]))'
level_2=r'(.*)=(int|float|choice|text|bool|button|point|color|folder|file|text|_int|_float|_choice|_text|_bool|_button|_point|_color|_folder|_file|_text)(\(.*\)|{.*})(.*)'
Yikes if you ask me.
Yup we’ve all had to work with awkward regex at some point I expect, but it’s not so common to get 6 nested levels of quotes/brackets…
I added a feature to Lavander Binary Map which allows you to copy and paste onto cmd (I’ll add color support soon). The limitation of clipboard feature is why I added this, and these don’t work for either Lavander Binary Map or Transfer Color Reduced Color. That being said. I would like to know if I should escape the " for other OS or terminals, particularly Linux is my concern.
See this output with the new feature:
+rep_lavander_binary_map 10,0,11,10,520325,\"xor(min(xor(x(),y()),xor(ix(),iy())),ix()|iy())\" rep_symmetrize_xy 3
I fixed Lavander Binary Map, I think I did. Learned a few things too working with strings, and debugging.
Now that I added enough features to separate Lavander Binary Map from how it works, I believe I should change the name of the filter. You can have a idea of how it works for the most part via the provided Python code in Lavander Binary Map GUI filter.
OCSBSC Map. Optional-Count-Sort Binary String Counting Map.
OCSA BSCM? Optional-Count-Sort-Array Binary-String Counting Map?
There are no good names. 
The part of optional implies there would be a internal array to find value to use, and in addition, it is count-sorted. Not mandatory.
Any other names?
It’s probably not the name you’re looking for, but I’m thinking: “Magic Carpet”. 