# [racket] Kernel size for flomap-gaussian-blur

 From: Neil Toronto (neil.toronto at gmail.com) Date: Tue May 14 14:02:45 EDT 2013 Previous message: [racket] Kernel size for flomap-gaussian-blur Next message: [racket] Kernel size for flomap-gaussian-blur Messages sorted by: [date] [thread] [subject] [author]

```On 05/11/2013 01:56 PM, Dmitry.Cherkassov.dcherkassov at gmail.com wrote:
> Hi. Can't find convolution kernel dimensions in the docs, neither they can be
> specified via arguments.
>
> Any ideas what they are?

A kernel centered at x with standard deviation σ has its minimum at
floor(x-3*σ) and its maximum at ceiling(x+3*σ). (Same for y and its
standard deviation.) So the width (resp. height) is

1 + ceiling(3*σ) - floor(-3*σ)

This can be simplified, but I took it directly from the code and didn't
want to risk getting it wrong. It's in "images/private/flomap-blur.rkt"
if you want to look it up.

If you want more control over convolution, you should use `array-fft'
from `math/array'. To get good performance from that, you'll want to use
Typed Racket, at least for writing image processing functions. Here's a
function that converts arrays to flomaps:

(: array->flomap ((Array Real) -> flomap))
(define (array->flomap arr)
(let ([arr (array->flarray arr)])
(define ds (array-shape arr))
(match ds
[(vector h w)  (flomap (flarray-data arr) 1 w h)]
[(vector h w c)  (flomap (flarray-data arr) c w h)]
[_  (error
'array->flomap
"expected array with 2 or 3 dimensions; given shape ~e"
ds)])))

The other direction is similarly simple, because `FlArray' and `flomap'
both store data in row-major order.

Neil ⊥

```

 Posted on the users mailing list. Previous message: [racket] Kernel size for flomap-gaussian-blur Next message: [racket] Kernel size for flomap-gaussian-blur Messages sorted by: [date] [thread] [subject] [author]