feature request: guided filter with a different guide

hi,
a quick question for gmic gurus: would it be possible to modify the “smooth (guided)” gui command to be able to select a different guide image? for example by checking whether two layers are currently active, and using one of the two as guide and the other as source image. how difficult would this be? thanks in advance!

Very simple as it is a very simple filter.

fx_smooth_guided : skip ${5=0},${6=0}
  ac "repeat $3 guided $1,$2 done",$4

fx_smooth_guided_preview :
  gui_split_preview "fx_smooth_guided $*",${-3--1}

Basically, you need to pass the layer to the command and place it as a parameter in front of $1. Also when you use this modified command, you would need to select the input layers to active and above.

sorry if I’m being dumb: is the above the already-modified command? my knowledge of gmic is essentially zero…

No, it is what the current filter looks like.

@patdavid @paperdigits @darix Why does the preview start from L40441? Discourse bug?

so, if I understand you correctly, this is so trivial that you are leaving the details as an exercise to the reader, right? well, “RTFM” would have been a more concise answer :wink:

It is just that I don’t have time or energy and am in a lot of pain today to help further. Also implying that David could easily make the change right away if he had the time. But I wanted to give you something to go by for now. :slight_smile:

1 Like

Done.
It’s better to use at least version 2.7.2 of G’MIC, since I’ve used commands store and restore.

1 Like

Thanks a lot! I just tried using the latest GIMP appimage provided by @Carmelo_DrRaw, which includes a pre-release version 2.7.3 of G’MIC, but I get the following error:

*** Error in ./fx_smooth_guided/*if/ac/_apply_channels/*repeat/*local/_ac/ *** Command 'restore': Invalid binary encoding of variable '_guide'.

Any clue? I simply duplicated a layer, selected “All” as input layers, and “Top layer” as guide – basically what you show in the screenshot above

store and restore are new commands. Probably a bug.

PS I get

image

That looks like a bug, but I don’t understand why this could happen on Mac (I assume you are using the Mac version of the plug-in?), and not on Linux.
I’ll test it on Windows to see what happens.

Input Layers -> All layers

:blush: Right, I forgot to do it this time.

Works for me.

no, actually I’m using the gimp appimage on Linux (a variant of Ubuntu 16.04, that’s why I’m using the appimage and not a native package)

Well, I don’t know what is happening then.
I’ve tested on Windows too, with a fresh compil of the plug-in, and it works as expected.

That’s annoying. If I can’t reproduce the bug, I can’t fix it.

anything I can do to help you debugging?

It’s a feature of github - look at your URL and you can see it’s appended the relevant lines numbers:

https://github.com/dtschump/gmic/blob/master/src/gmic_stdlib.gmic#L40451-40475

Specifically, the internal anchor links to #40451-40475.

If you just want to link the file entirely you can omit those.

@patdavid The issue is that the box shows lines 40441-40461 instead, though it rightly highlights 40451.

image

Maybe a first step, could you try to copy/paste this:

+store foo
to $foo
restore foo
a x

in the filter Various / Custom Code [global] , and tell me if you get something similar to this:

still get an error:

1 Like

I really don’t know what is happening.
Maybe @Carmelo_DrRaw should check if the sources he is using to compile G’MIC are indeed the latest ones ? I’m not able to reproduce this bug on Linux, nor on Windows, so I suspect that maybe the binary you are using has been compiled at a time where there was a bug in the repository.
Definitely not sure on how to handle this.
If you have the possibility to recompile the plug-in by yourself, directly from the latest development sources, it would really help.