Glitch Art Filters?


(dumb) #61

I can’t seem to fix this ‘endl hell’ that I’m getting. It keeps saying that there’s missing endlocals no matter where I put them. https://pastebin.com/FcGuqScu


(G'MIC staff) #62

Not sure what is the exact problem here, but several ideas to make the whole thing cleaner:

  • Indent your code ! All the lines of your filter code are starting from the first column, and it becomes very hard (for such a long code) to understand in which control structure each instruction is running in.
  • Look at the error messages closely, the scope of the instruction that caused the error is displayed. For instance, if you get something like:
[gmic]-1./fx_self_glitching_cascade_preview/fx_self_glitching_cascade/*repeat/*local/*local/*repeat/ *** Error (file '/home/dtschump/.gmic', line #490) *** Command 'endlocal': Not associated to a 'local' command within the same scope.

then it means you have tried to put a endlocal to end a block that was not started by a local, but by a repeat. So you probably missed one done somewhere.

  • Also, be careful that your $iter appearing in your fill expression is probably not correct (variables are not substituted in strings, whereas command arguments are. So basically, you write something like: "...expression...; y = $8; x = "$iter"; ...." instead of "...expression...; y = $8; x = $iter; ....".

(dumb) #63

Thanks, I’ve fixed that but now I’ve walked into another problem: f "val = i;"{$8}"||"{$>}"==$7?(val*$20+$21%$22*$23+$24):val%256;" doesn’t do anything.


(dumb) #64

For my next failed conjuring trick (which is an attempt to fix the problem of the next fill command not doing anything; what I’m looking for is a choice to get the post-shifting multiplication, addition and modulo operations working either with each iteration or at the end), I’m trying to use a string concatenation thing but cats() does not like it at all:

image

Also that vtos() should be an stov().

Besides that, I want to extend the functionality some more so that it can manipulate the values based on whole ranges of images, cycling through them for each iteration.


(G'MIC staff) #65

I don’t understand what is your goal here, sorry.
Could you write a minimal example of what you are trying to achieve ? It would be simpler for me to get the idea on a simple example rather than a full-length filter code.


(dumb) #66

In the version that’s currently bundled with G’MIC, there’s a multiplication, modulo and addition - these are the ‘post-operations’. What happens (in some sort of pseudocode):

repeat iterations
	fill "operations,post-operations"
done

What I’m after is an option to make the post-operations either run on only the last iteration rather than all of them or all iterations but I don’t want to end up duplicating a ton of code. The only way that I can think of is to turn the list of operator arguments (variable $19 in the new one, $11 in the old one) and the modulo functions into strings, concatenate the strings and then parse the values. cats() screams at me when I do that.

Beyond that, I’m looking to have the filter run each iteration with different images (as layers) altogether for user-defined ranges of images, for example: for shift iteration 1, use layer 3 to get val; for shift iteration 2, use layer 4… Layer 0 would be the starting image. I’m also planning an option to reverse the progression through the range.


#67

And screaming cats() are no good for anyone :smiley:

It seems you’re reaching a level of intricacy with your filters that’s difficult for anyone else to debug or assist with! At some point, the separation between specification and code becomes very small…

What I can suggest is to look at alternative program control structures such as do… while, or do something by referencing the current loop iteration. In a repeat… done, the current iteration can be had with $> (or another variable of your choosing). That way you can say “if the iteration number is the last, do or don’t do something”.

Within a fill (which automatically loops over all pixels in an image) you can equally say “if I’m on the last pixel” by comparing to whds. Or you can create your own for loop in an eval and avoid the “automatic” looping altogether.


(G'MIC staff) #68

I would also suggest defining your operator as a new macro in the math expression, something like:

my_op(mode,x,y) = (mode==0?(x + y):
                   mode==1?(x - y):
                   ...
                   mode=10?(x%y));

And then you can use it twice (or more) with different parameters :

my_op($1,val,i);  # Do some operation with 'val' and 'i'.
..
my_op($2,val,i); # Do another operation with 'val' and 'i'.

EDIT : Also functions init() and end() can be used in a fill expression to execute functions only once (at the start and end of the expression evaluation, not for each pixel).


(dumb) #69

Noted, the filter is fixed. First, apologies for not setting up GitHub; I’m focussing more on the filters than configuring that correctly. I have some stuff to sort out with it first. Second, my attention is turning to the multiple images idea that I have. I’ll detail it more:

I want to make a filter that’s just like this but it takes multiple images as layers (using a selected range of images with an option for positive or negative increment) and then blends the layers like this one does.


#70

How to emulate ‘Convert RGB to YUV and Convert YUV to RGB’

To emulate this in either Krita or GIMP -

  1. Copy and paste your preferred image.
  2. Decompose into YUV with no multiple layers (if using Krita)
  3. Replace the UV channel with GB Channel.
  4. Recompose YUV
  5. You have your image similar to the Paint .NET plugin

3/4 Channels only G’MIC plugin would be easier to do. In the case of CMYK, it does require a slight different coding. Even better idea. Instead of only having the option recomposing after channel has been replaced, there should be a bool operation which enables the option to recompose using another color space instead of the original one picked to replace with the secondary channel.


Codebook Section

Found something interesting

Codebook filter link - https://blog.filippo.io/the-ecb-penguin/
More link - https://doegox.github.io/ElectronicColoringBook/

I’m not sure if that’s link useful to replicate codebook. It almost like there’s databending involved. You can databend with audacity. I wonder if G’MIC supports databending.

@David_Tschumperle - Do G’MIC support databending?

If I’m not mistaken about the 2nd link, I suppose you can change colors, and treat them as another value, and then change it back.

Also, I am largely suspecting that the above details could help lead to a codebook filter for G’MIC. Here’s PDN image.

Here’s an animated PNG showing codebook filter.


(dumb) #71

I was about to ask something similar regarding databending; I also wonder whether it can read raw files as well (though I think this was partly already brought up regarding the replication of GLIC’s PNG-munging capabilities).

As for the colour space stuff, I put something together very quickly.


#72

I think the name should be Color Space Channel Swap.


(dumb) #73

CSG has been updated again with a change to its core. The functionality hasn’t changed but I’ve spotted an opportunity to expand it immensely: since it copies the image, shifts the copy to use it for image mangling and then deletes it, I want to get two custom command boxes in there, one before the self-glitching and one after. I’m also looking to somehow get $> in the custom commands to be replaced with the iteration number of the overall filter if it’s outside any nested looping functions. The problem is that the existing custom command filters seem way too complicated for me to understand what goes where.

Edit: if I use this attempt of an update and I try to enter anything in the first box (ignore the stuff for the second), it only sets $25 to everything before the first space. I can’t fix it at all and the code in the custom code filter looks almost exactly the same. What am I missing?


#74

I have no idea what’s going on, but neither of your pastes works on the last post for me. Interference on the latest post than the last post with filters doesn’t work on Krita which is my primary software.


(dumb) #75

I use the GIMP plugin. I’m not sure about Krita; I’ll try to test that later if I can.


#76

Krita and GIMP do have filters where they fail, but Krita a little more so. Let me know what do you plan to do with G’MIC to maximize choices and options for people.


(dumb) #77

Bumping this good old thread because I want more from the JPEG artefacts filter. Turns out there’s multiple kinds of encoding that can be used. The GIMP 2.10 dialog that shows up whenever someone tries to save an image as a JPEG is as follows:

image

The manual goes on about different subsampling methods for the CbCr channels (8x8, 8x16, 16x8, 16x16) as well as different DCT methods. I still have no idea how the current filter works but I think it’s using 8x8 subsampling for the chroma.


(dumb) #78

Another thing I’ve thought about: trying to run a preview (not the gui_split_preview!) of an image with more than 4 channels leads to some interesting results:

image

Images are squashed towards the left, decolourised and placed alongside heavily-distorted images. The effect depends on the dimensions and values of the image (including the number of channels) alongside the preview zoom factor. I know that it’s an error but I want to exploit it for artistic purposes. The image below can be used to mine patterns from:

image

Edit: in the meantime, have a weird little experiment of mine:

f "begin(switchx=0;col=u*w;switchy=0;row=u*h);
u>=0.999?switchx=1;
u>=0.999?switchy=1;
switchx==1?col=(u*w);
switchy==1?row=(u*h);
switchx=0;
switchy=0;
j(col,row,0,0,0,2)"