Skip to content

2D convolution

2 messages · Kjetil Kjernsmo, Brian Ripley

#
Dear all,

I have an image that I need to filter, and so I'm looking for a method to
convolve it with a matrix. If I understood the docs for convolve
correctly, it only works in 1D (and I have tried to convolve, it didn't
look good).

So, I wondered if anybody have implemented 2D convolution in R, or have
any good advices to share (beyond having a look at mvfft), before I go
hacking?

Best,

Kjetil
#
On Mon, 4 Jun 2001, Kjetil Kjernsmo wrote:

            
How about don't?  That is, do it at C/Fortran level.  2D convolution tends
to be expensive and edge effects can be much trickier.  When we had to do
it in earnest (2D optical astronomy from CCD arrays, pre-R) fortunately
the objects of interest were in the centre of the image, so edge effects
were small, and we wrote Fortran routines to do it in place (also based on
Singleton's code).

Note that mvfft does not do 2D transforms: it's fft that does so (as I
read the docs).