Laplacian of Gaussian

The LoG-filter creates an image with zero-crossings at edge locations.  The edges can be detected using either dilation or erosion.  Alternatively one could match a set of small 3x3 patterns.  The notable property of edge detection using the LoG-filter is that it generates closed edge contours.

See also

#!/usr/bin/env ruby
require 'hornetseye'
include Hornetseye
raise "Syntax: l_o_g.rb <input file> <output file>" if ARGV.size != 2
img = MultiArray.load_ubyte( ARGV[0] )
# Compute Laplacian of Gaussian.
log = MultiArray.laplacian_of_gaussian 1.4, 9
binary = img.correlate( log ) >= 0
( binary.not.or( binary.erode ).to_ubyte * 0xFF ).save_ubyte ARGV[1]
Close