<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">I tried to implement this as an alternate way of histogram matching in i.pansharpen (attached as i.pansharpen3). It works and gives different colors, but it no longer sharpens. I’m attaching the code for you to look at (new method matchhist_mean_sd).
 I’m tied up the rest of the afternoon. So maybe someone else can puzzle this out.<br>
<br>
Michael<br>
<br>
</div>
</span></font></div>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
____________________<br>
C. Michael Barton<br>
Director, Center for Social Dynamics & Complexity <br>
Professor of Anthropology, School of Human Evolution & Social Change<br>
Arizona State University<br>
<br>
voice:   480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)<br>
fax:          480-965-7671 (SHESC),  480-727-0709 (CSDC)<br>
www: <a href="http://www.public.asu.edu/~cmbarton">http://www.public.asu.edu/~cmbarton</a>,
<a href="http://csdc.asu.edu">http://csdc.asu.edu</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Nov 21, 2013, at 12:38 AM, Nikos Alexandris <nik@nikosalexandris.net> wrote:<br>
<br>
> Nick Ves wrote:<br>
> <br>
>>> The HPF algorithm about the histrogram matching states "Stretch the<br>
>>> new multispectral image to match the mean and standard deviation of<br>
>>> the original (input) multispectral image"<br>
>>> In that context why it is wrong to do:<br>
> <br>
>>> Ouput <- output/sddev(output)*sddev(input)<br>
>>> Output <- Output - mean(output) + mean(input)<br>
> <br>
> Moritz Lennert:<br>
> <br>
>> To give the 'new' image the same mean and stddev of the 'input' image:<br>
>> (new - mean(new)) / stddev(new) * stddev(input) + mean(input)<br>
> <br>
> Not entirely sure, I think it works. Taken a fragment from the publicly <br>
> available QuickBird2 image over Sri Lanka (the extent shown at <br>
> <<a href="http://grasswiki.osgeo.org/wiki/File:RGB_04APR05050541-M2AS-000000186011_01_P001.jpg">http://grasswiki.osgeo.org/wiki/File:RGB_04APR05050541-M2AS-000000186011_01_P001.jpg</a>>),<br>
> <br>
> <br>
> get mean and sd for r, g and b<br>
> <br>
> # red<br>
> mean_red=321.375<br>
> sd_red=172.756<br>
> <br>
> # hpf_red<br>
> mean_red_hpf=321.364<br>
> sd_red_hpf=238.391<br>
> <br>
> # green<br>
> mean_green=434.033<br>
> sd_green=159.9<br>
> <br>
> # hpf_green<br>
> mean_green_hpf=434.02<br>
> sd_green=258.249<br>
> <br>
> # blue<br>
> mean_blue=285.168<br>
> sd_blue=75.0218<br>
> <br>
> # hpf_blue<br>
> mean_blue_hpf=285.161<br>
> sd_blue_hpf=145.395<br>
> <br>
> <br>
> and then<br>
> <br>
> r.mapcalc "hpf_red_histomatched = ( hpf_red - $mean_red_hpf ) / $sd_red_hpf * <br>
> $sd_red + $mean_red" --o<br>
> <br>
> r.mapcalc "hpf_blue_histomatched = ( hpf_blue - $mean_blue_hpf ) / <br>
> $sd_blue_hpf * $sd_blue + $mean_blue" --o<br>
> <br>
> r.mapcalc "hpf_green_histomatched = ( hpf_green - $mean_green_hpf ) / <br>
> $sd_green_hpf * $sd_green + $mean_green" --o<br>
> <br>
> <br>
> check output stats<br>
> <br>
> # r.univar hpf_red_histomatched<br>
> mean: 321.375<br>
> standard deviation: 172.756<br>
> <br>
> # r.univar hpf_green_histomatched<br>
> mean: 434.033<br>
> standard deviation: 159.9<br>
> <br>
> # r.univar hpf_blue_histomatched<br>
> mean: 285.168<br>
> standard deviation: 75.0217<br>
> <br>
> # reset colors to match originals doesn't play exactly nice, so<br>
> r.colors hpf_red_histomatched color=grey -e<br>
> # repeat for green, blue<br>
> <br>
> # draw<br>
> d.rgb ...<br>
> <br>
> <br>
> Looks nice! Is it that?<br>
> <br>
> Nikos<br>
<br>
</div>
</span></font></div>
</body>
</html>