Function ialogfilter

Synopse

Laplacian of Gaussian filter.

  • g = ialogfilter(f, sigma)
    • g: Image.
    • f: Image. input image
    • sigma: Double. scaling factor
01. from numpy.fft import fft2, ifft2
02. from numpy import *
03. 
04. def ialogfilter(f, sigma):
05.     from ialog import ialog
06.     from iaifftshift import iaifftshift
07.     from iaisdftsym import iaisdftsym
08. 
09.     if len(shape(f)) == 1: f = f[newaxis,:]
10.     h = ialog(shape(f), map(int, array(shape(f))/2.), sigma)
11.     h = iaifftshift(h)
12.     H = fft2(h)
13.     if not iaisdftsym(H):
14.        raise Exception, "error: log filter is not symmetrical"
15.     G = fft2(f) * H
16.     g = ifft2(G).real
17.     return g

Description

Filters the image f by the Laplacian of Gaussian (LoG) filter with parameter sigma. This filter is also known as the Marr-Hildreth filter. Obs: to better efficiency, this implementation computes the filter in the frequency domain.

Examples

Example 1

1. from ia636 import ialogfilter, ianormalize
2. 
3. f = adreadgray('cameraman.pgm')
4. adshow(f,title='original')
5. g07 = ialogfilter(f, 0.7)
6. adshow(ianormalize(g07),title='LoG filter')
7. adshow(g07 > 0, title='positive values')

original

LoG filter

positive values

Example 2

1. g5 = ialogfilter(f, 5)
2. adshow(ianormalize(g5),title='sigma=5')
3. adshow(g5 > 0, title='positive, sigma=5')
4. g10 = ialogfilter(f, 10)
5. adshow(ianormalize(g10),title='sigma=10')
6. adshow(g10 > 0, title='positive, sigma=10')

sigma=5

positive, sigma=5

sigma=10

positive, sigma=10

See Also

  • ialog - Laplacian of Gaussian image.