[GRASS-dev] Implementation of the High Pass Filter Additive Fusion technique (i.fusion.hpf)

Nikos Alexandris nik at nikosalexandris.net
Wed Nov 20 23:38:12 PST 2013


Nick Ves wrote:

> > The HPF algorithm about the histrogram matching states "Stretch the
> > new multispectral image to match the mean and standard deviation of
> > the original (input) multispectral image"
> > In that context why it is wrong to do:

> > Ouput <- output/sddev(output)*sddev(input)
> > Output <- Output - mean(output) + mean(input)

Moritz Lennert:

> To give the 'new' image the same mean and stddev of the 'input' image:
> (new - mean(new)) / stddev(new) * stddev(input) + mean(input)

Not entirely sure, I think it works. Taken a fragment from the publicly 
available QuickBird2 image over Sri Lanka (the extent shown at 
<http://grasswiki.osgeo.org/wiki/File:RGB_04APR05050541-M2AS-000000186011_01_P001.jpg>),


get mean and sd for r, g and b

# red
mean_red=321.375
sd_red=172.756

# hpf_red
mean_red_hpf=321.364
sd_red_hpf=238.391

# green
mean_green=434.033
sd_green=159.9

# hpf_green
mean_green_hpf=434.02
sd_green=258.249

# blue
mean_blue=285.168
sd_blue=75.0218

# hpf_blue
mean_blue_hpf=285.161
sd_blue_hpf=145.395


and then

r.mapcalc "hpf_red_histomatched = ( hpf_red - $mean_red_hpf ) / $sd_red_hpf * 
$sd_red + $mean_red" --o

r.mapcalc "hpf_blue_histomatched = ( hpf_blue - $mean_blue_hpf ) / 
$sd_blue_hpf * $sd_blue + $mean_blue" --o

r.mapcalc "hpf_green_histomatched = ( hpf_green - $mean_green_hpf ) / 
$sd_green_hpf * $sd_green + $mean_green" --o


check output stats

# r.univar hpf_red_histomatched
mean: 321.375
standard deviation: 172.756

# r.univar hpf_green_histomatched
mean: 434.033
standard deviation: 159.9

# r.univar hpf_blue_histomatched
mean: 285.168
standard deviation: 75.0217

# reset colors to match originals doesn't play exactly nice, so
r.colors hpf_red_histomatched color=grey -e
# repeat for green, blue

# draw
d.rgb ...


Looks nice! Is it that?

Nikos


More information about the grass-dev mailing list