GIMP G'MIC Filter to Convolve Two Images?

(James Bowery) #1

I want to convolve an image with a kernel that is another image. The GIMP G’MIC “Convolve” filter provides an input field “Custom kernel” but it is not an image. Moreover, that’s the only filter that the search returns for “convolve” (other than “deconvolve”).

When I went to learn how to write my own filter, I ran into an error in the documentation for Windows preventing me from doing so.

Isn’t there some existing filter that does what I want?

(Aurélien Pierre) #2

In Python, you have scipy.signal.fftconvolve. That’s very specific, so you may have to script it yourself.


You can do this from console with:

gmic image1.tif image2.tif convolve_fft[0] [1]

where [0] and [1] specify the image position in the stack. Search for “convolve_fft” in the G’MIC documentation for more information.

Edit: I don’t think there’s a convolve GUI filter which uses FFT convolve, as you say you can create your own.

Edit2: the windows file should be named “user.gmic”


Save user.gmic here: C:\Users\username\AppData\Roaming

(G'MIC staff) #5

Note that convolve_fft will consider periodic boundary conditions, by nature of the FFT.
That may not what’s intended.
Command convolve does also the job, letting you choose between Dirichlet and Neumann boundary conditions, but requires the convolution kernel to be small enough otherwise the computation time explodes.