Nikos Alexandris wrote:
I can’t get any decent looking colors, with any of the methods. I
wonder if my images are not properly “aligned” or the like.
Moritz Lennert wrote:
Getting back to this just for clarification. What do you call "decent
looking colors" ?
apply to my sentence “s/decent looking colors/usable images”
Have you looked at the example images in the man page [1]?
[1] http://grass.osgeo.org/grass70/manuals/i.pansharpen.html
Sure.
They show quite different colors depending on the technique used.
This is not the problem that I have. Nor is it the one Haziq described in the
Q&A at http://gis.stackexchange.com/q/39174/5256.
Are you trying to get them all to look like the top left ("natural
color") image ?
No. I simply try to get usable output from 11-bit bands fed in i.pansharpen.
The only usable output, no matter the method actually, is when rescaling the
input bands to 8-bit. Tested with my working data (IKONOS, QuickBird) as well as with some publicly available IKONOS data.
I am delivering 18 examples in which none of them appears ok to me. I guess I don’t know how to use the module. Will post images in trac, if possible, else in my wiki user-page.
I don’t provide any 8-bit examples. All of my attempts, so far, with 8-bit images work fine – they look from acceptable to really good depending on some re-balancing, be it manually playing with color-tables or using i.landsat.rgb
Nevertheless, I 'd like to see only one example using a >8-bit set of bands in which i.pansharpen works as expected. Then I know for sure that, once again I have messed-up a normal runnig process :-). I am a Great specialist doing this… 
So, here it goes.
1) We have publicly available IKONOS images:
ftp://ftp.glcf.umd.edu/glcf/China_earthquake_May_2008/IKONOS/.
Get for example the first one:
ftp://ftp.glcf.umd.edu/glcf/China_earthquake_May_2008/IKONOS/po_58204_0000000.20001116.China-Sichuan/
2) Import in GRASS’ db, convert from DN to Radiance to Reflectance. Details
in the Wiki:
http://grasswiki.osgeo.org/wiki/IKONOS#Deriving_Physical_Quantities
3) Let’s have a look at the “input” ranges:
11-bit DNs, ranging in…
min=0
max=1400
title= (po_58204_blu_0000000)
min=0
max=1654
title= (po_58204_grn_0000000)
min=0
max=1321
title= (po_58204_nir_0000000)
min=0
max=1319
title= (po_58204_pan_0000000)
min=0
max=1489
title= (po_58204_red_0000000)
Radiances
min=0
max=269.716258496062
title= (Blue_Radiance)
min=0
max=259.280160521696
title= (Green_Radiance)
min=0
max=164.2581277309
title= (NIR_Radiance)
min=0
max=203
title= (Pan_Radiance)
min=0
max=238.452890740853
title= (Red_Radiance)
Reflectances – note to self: fix r.support below!
min=0
max=0.705829413346531
title=echo Blue band (Top of Atmosphere Reflectance) (Blue_ToAR)
min=0
max=0.706357576839509
title=echo Green band (Top of Atmosphere Reflectance) (Green_ToAR)
min=0
max=0.717436479668371
title=echo NIR band (Top of Atmosphere Reflectance) (NIR_ToAR)
min=0
max=0.745578096984679
title=echo Pan band (Top of Atmosphere Reflectance) (Pan_ToAR)
min=0
max=0.774115699104528
title=echo Red band (Top of Atmosphere Reflectance) (Red_ToAR)
4) i.pansharpen – all of them, three methods – from my history
Brovey
18 31.Jul.13 [ 15:54:36 ] i.pansharpen sharpen=brovey pan=Pan_Radiance
ms1=Blue_Radiance ms2=Green_Radiance ms3=Red_Radiance
output=sharp_brovey_Radiance
19 31.Jul.13 [ 15:54:46 ] i.pansharpen sharpen=brovey pan=Pan_ToAR
ms1=Blue_ToAR
ms2=Green_ToAR ms3=Red_ToAR output=sharp_brovey_ToAR
24 31.Jul.13 [ 15:59:16 ] i.pansharpen sharpen=brovey pan=Pan_DNs
ms1=Blue_DNs
ms2=Green_DNs ms3=Red_DNs output=sharp_brovey_DNs
PCA
59 31.Jul.13 [ 16:09:53 ] i.pansharpen sharpen=pca pan=Pan_DNs
ms1=Blue_DNs
ms2=Green_DNs ms3=Red_DNs output=sharp_pca_DNs
60 31.Jul.13 [ 16:22:03 ] i.pansharpen sharpen=pca pan=Pan_Radiance
ms1=Blue_Radiance
ms2=Green_Radiance ms3=Red_Radiance output=sharp_pca_Radiance
61 31.Jul.13 [ 16:27:28 ] i.pansharpen sharpen=pca pan=Pan_ToAR
ms1=Blue_ToAR
ms2=Green_ToAR ms3=Red_ToAR output=sharp_pca_ToAR
IHS
62 31.Jul.13 [ 16:35:12 ] i.pansharpen sharpen=ihs pan=Pan_ToAR
ms1=Blue_ToAR
ms2=Green_ToAR ms3=Red_ToAR output=sharp_ihs_ToAR
63 31.Jul.13 [ 16:37:21 ] i.pansharpen sharpen=ihs pan=Pan_Radiance
ms1=Blue_Radiance
ms2=Green_Radiance ms3=Red_Radiance output=sharp_ihs_Radiance
64 31.Jul.13 [ 16:39:32 ] i.pansharpen sharpen=ihs pan=Pan_DNs
ms1=Blue_DNs
ms2=Green_DNs ms3=Red_DNs output=sharp_ihs_DNs
5) Let’s look at the numbers
for SHARP in g.mlist rast pat=sharp*
; do r.info -mr ${SHARP}; done
min=36.2130177514793
max=153
title= (sharp_brovey_DNs_blue)
min=0
max=112.211538461538
title= (sharp_brovey_DNs_green)
min=0
max=107.968559837728
title= (sharp_brovey_DNs_red)
min=7.93864844473524
max=102.4232751775
title= (sharp_brovey_Radiance_blue)
min=0
max=87.5889521289036
title= (sharp_brovey_Radiance_green)
min=0
max=74.435557812593
title= (sharp_brovey_Radiance_red)
min=0
max=0.398724812575096
title= (sharp_brovey_ToAR_blue)
min=0
max=0.335289700449259
title= (sharp_brovey_ToAR_green)
min=0
max=0.476377949923749
title= (sharp_brovey_ToAR_red)
min=0
max=255
title=Image blue (sharp_ihs_DNs_blue)
min=0
max=255
title=Image green (sharp_ihs_DNs_green)
min=0
max=255
title=Image red (sharp_ihs_DNs_red)
min=0
max=255
title=Image blue (sharp_ihs_Radiance_blue)
min=0
max=254
title=Image green (sharp_ihs_Radiance_green)
min=0
max=254
title=Image red (sharp_ihs_Radiance_red)
min=0
max=2
title=Image blue (sharp_ihs_ToAR_blue)
min=0
max=2
title=Image green (sharp_ihs_ToAR_green)
min=0
max=2
title=Image red (sharp_ihs_ToAR_red)
min=177.072681268903
max=490.188522572706
title= (sharp_pca_DNs_blue)
min=174.855236596567
max=415.384343723085
title= (sharp_pca_DNs_green)
min=-71.4712772318356
max=390.53877906274
title= (sharp_pca_DNs_red)
min=38.0505369148222
max=189.658927814102
title= (sharp_pca_Radiance_blue)
min=24.8653625573439
max=215.672403116314
title= (sharp_pca_Radiance_green)
min=-13.7969488642255
max=113.557246501694
title= (sharp_pca_Radiance_red)
min=0.0506311311052859
max=0.660054986167671
title= (sharp_pca_ToAR_blue)
min=0.0146679903931977
max=0.832078269086436
title= (sharp_pca_ToAR_green)
min=-0.0646181045289202
max=0.451095521435642
title= (sharp_pca_ToAR_red)
At least for some of the above results, it is obvious that something isn’t right.
6) I use the script copy-pasted in the end of this message in G64 (…I wish I could use frames in G7 :-p) to get some overviews, without and with
“i.landsat.rgb -p”
Will upload screenshots uploaded in trac – if possible.
Summary
In almost all – actually, in all of them! – there are NULL cells introduced there where they did not exist before. I don’t use a MASK. I have set up the region before running i.pansharpen to match the extent of the Red band, for example (resolution is taken care by the module).
Nikos
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
#!/bash/sh
script to draw screenshots, 3 x 3 various methods x inputs
loop over Methods and Input Types, compose RGBs
for Method_Input in “ihs DNs” “ihs Radiance” “ihs ToAR” \
“brovey DNs” “brovey Radiance” “brovey ToAR” \
“pca DNs” “pca Radiance” “pca ToAR”
do
parse “${Method_STR}” and set positional parameters
set – $Method_Input ; echo $1 $2
compose
r.composite --o \
r=sharp_“${1}”_“${2}”_red \
g=sharp_“${1}”_“${2}”_green \
b=sharp_“${1}”_“${2}”_blue \
out=rgb_sharpened_“${1}”_“${2}”
done
set wide aspect ratio (16:9, e.g. 1366 width x 768 height)
d.monsize setm=x0 setw=1366 seth=768
split in 9 frames
d.split.frame frames=9
preferred font?
d.font DroidSans
loop over composites
for FRAME in “uno ihs DNs” “dos ihs Radiance” “tres ihs ToAR” \
“cuatro brovey DNs” “cinco brovey Radiance” “seis brovey ToAR” \
“siete pca DNs” “ocho pca Radiance” “nueve pca ToAR”
do
parse “${FRAMES_STR}” and set positional parameters
set – $FRAME ; echo $1 $2 $3
select FRAME
d.frame -s “${1}”
draw the map
d.rast rgb_sharpened_“${2}”_“${3}”
draw label on the left and vertically
d.text text=“${2}, ${3}” size=8 color=50:50:50 at=10,25 rotation=90
draw legend ?
d.legend rgb_sharpened_“${2}”_“${3}” -s at=10,90,76,82
done
re-balance colors
for Method_Input in “ihs DNs” “ihs Radiance” “ihs ToAR” \
“brovey DNs” “brovey Radiance” “brovey ToAR” \
“pca DNs” “pca Radiance” “pca ToAR”
do
parse “${Method_STR}” and set positional parameters
set – $Method_Input ; echo $1 $2
re-balance, re-compose
i.landsat.rgb -p \
r=sharp_“${1}”_“${2}”_red \
g=sharp_“${1}”_“${2}”_green \
b=sharp_“${1}”_“${2}”_blue
re-compose
r.composite --o \
r=sharp_“${1}”_“${2}”_red \
g=sharp_“${1}”_“${2}”_green \
b=sharp_“${1}”_“${2}”_blue \
out=rgb_sharpened_“${1}”_“${2}”_rebalanced
done
set wide aspect ratio (16:9, e.g. 1366 width x 768 height)
d.monsize setm=x1 setw=1366 seth=768
split in 9 frames
d.split.frame frames=9
preferred font?
d.font DroidSans
loop over Re-Balanced composites
for FRAME in “uno ihs DNs” “dos ihs Radiance” “tres ihs ToAR” \
“cuatro brovey DNs” “cinco brovey Radiance” “seis brovey ToAR” \
“siete pca DNs” “ocho pca Radiance” “nueve pca ToAR”
do
parse “${FRAMES_STR}” and set positional parameters
set – $FRAME ; echo $1 $2 $3
select FRAME
d.frame -s “${1}”
draw the map
d.rast rgb_sharpened_“${2}”_“${3}”_rebalanced
draw label on the left and vertically
d.text text=“${2}, ${3}” size=8 color=50:50:50 at=10,25 rotation=90
d.text text=“Rebalanced i.landsat.rgb -p” size=6 color=50:50:50 at=14,10 rotation=90
draw legend ?
d.legend rgb_sharpened_“${2}”_“${3}”_rebalanced -s at=10,90,76,82
done
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###