[GRASS-user] Do filters available in GRASS takes care of cell padding?

Glynn Clements glynn at gclements.plus.com
Fri Dec 4 13:44:06 PST 2015


Uttam Kumar wrote:

> 4.) Which one of the above GRASS commands would be best suited to perform
> window operation (high pass filtering) along with cell padding?

One caveat to my previous reply:

Ignoring nulls often doesn't work so well for kernels with a zero sum
(e.g your high-pass filter). You can't use r.neighbors method=average
with weights which sum to zero (as that results in division by zero),
and method=sum introduces a bias if some weights are ignored (at the
edges, you'll have a single cell with a weight of 24 and fewer than 24
cells with a weight of -1, meaning that a constant map would produce a
positive value near the edges).

I would suggest using two passes, e.g.

	r.neighbors size=5 method=average input=band5 output=band5_average
	r.mapcalc 'band5_highpassfilter = band5 - band5_average'
	g.remove raster=band5_average

This returns the value of the centre cell minus the average of the
surrounding non-null cells. The average value is still meaningful if
the filter window overlaps null cells or the edges.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list