[GRASS-user] output values of r.composite

When I use r.composite to create, i.e., a false_color composite from three Landsat bands, the RGB values in the composite are slightly different than the values in the original bands. Why is that?

Here's an example:

# Import three bands
GRASS 7.0.0svn (UTM33N):~/Downloads > for b in 2 3 4; do r.in.gdal --o input=LE71830542003069SGS00_B${b}.TIF output=b${b}; done
r.in.gdal complete.

# Create composite
GRASS 7.0.0svn (UTM33N):~/Downloads > r.composite r=b4 g=b3 b=b2 out=false_color --o
Creating color table for output raster map...
  100%
Writing raster map <false_color>...
  100%
r.composite complete. Raster map <false_color> created.

GRASS 7.0.0svn (UTM33N):~/Downloads > r.info -g false_color
north=1065915
south=856485
east=731415
west=497985

# Choose a point for testing
GRASS 7.0.0svn (UTM33N):~/Downloads > x=600000; y=900000

# and query with r.what
GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n map=b4,b3,b2 coord=${x},${y}
easting|northing|site_name|b4|b3|b2
600000|900000||67|108|96 <<=============

GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n -r map=false_color coord=${x},${y}
easting|northing|site_name|false_color|false_color_color
600000|900000||12712|065:106:098 <<============
GRASS 7.0.0svn (UTM33N):~/Downloads >

Thanks,
Micha

On Wed, Jan 28, 2015 at 10:34 PM, Micha Silver <micha@arava.co.il> wrote:

When I use r.composite to create, i.e., a false_color composite from three
Landsat bands, the RGB values in the composite are slightly different than
the values in the original bands. Why is that?

Because the number of levels to be used for each component is by
default 32, not 256 [0].

Markus M

[0] http://grass.osgeo.org/grass70/manuals/r.composite.html

Here's an example:

# Import three bands
GRASS 7.0.0svn (UTM33N):~/Downloads > for b in 2 3 4; do r.in.gdal --o
input=LE71830542003069SGS00_B${b}.TIF output=b${b}; done
r.in.gdal complete.

# Create composite
GRASS 7.0.0svn (UTM33N):~/Downloads > r.composite r=b4 g=b3 b=b2
out=false_color --o
Creating color table for output raster map...
100%
Writing raster map <false_color>...
100%
r.composite complete. Raster map <false_color> created.

GRASS 7.0.0svn (UTM33N):~/Downloads > r.info -g false_color
north=1065915
south=856485
east=731415
west=497985

# Choose a point for testing
GRASS 7.0.0svn (UTM33N):~/Downloads > x=600000; y=900000

# and query with r.what
GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n map=b4,b3,b2 coord=${x},${y}
easting|northing|site_name|b4|b3|b2
600000|900000||67|108|96 <<=============

GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n -r map=false_color
coord=${x},${y}
easting|northing|site_name|false_color|false_color_color
600000|900000||12712|065:106:098 <<============
GRASS 7.0.0svn (UTM33N):~/Downloads >

Thanks,
Micha

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Markus:
Thanks for the quick reply. That indeed was my problem: misunderstanding the implications of the levels param.
Best,
Micha

···

On 29-Jan-15 12:28 PM, Markus Metz wrote:

On Wed, Jan 28, 2015 at 10:34 PM, Micha Silver [<micha@arava.co.il>](mailto:micha@arava.co.il) wrote:

When I use r.composite to create, i.e., a false_color composite from three
Landsat bands, the RGB values in the composite are slightly different than
the values in the original bands. Why is that?

Because the number of levels to be used for each component is by
default 32, not 256 [0].

Markus M

[0] [http://grass.osgeo.org/grass70/manuals/r.composite.html](http://grass.osgeo.org/grass70/manuals/r.composite.html)

Here's an example:

# Import three bands
GRASS 7.0.0svn (UTM33N):~/Downloads > for b in 2 3 4; do r.in.gdal --o
input=LE71830542003069SGS00_B${b}.TIF output=b${b}; done
r.in.gdal complete.

# Create composite
GRASS 7.0.0svn (UTM33N):~/Downloads > r.composite r=b4 g=b3 b=b2
out=false_color --o
Creating color table for output raster map...
 100%
Writing raster map <false_color>...
 100%
r.composite complete. Raster map <false_color> created.

GRASS 7.0.0svn (UTM33N):~/Downloads > r.info -g false_color
north=1065915
south=856485
east=731415
west=497985

# Choose a point for testing
GRASS 7.0.0svn (UTM33N):~/Downloads > x=600000; y=900000

# and query with r.what
GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n map=b4,b3,b2 coord=${x},${y}
easting|northing|site_name|b4|b3|b2
600000|900000||67|108|96            <<=============

GRASS 7.0.0svn (UTM33N):~/Downloads > r.what -n -r map=false_color
coord=${x},${y}
easting|northing|site_name|false_color|false_color_color
600000|900000||12712|065:106:098        <<============
GRASS 7.0.0svn (UTM33N):~/Downloads >

Thanks,
Micha

_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)

This mail was received via Mail-SeCure System.

-- 
Moshav Idan
D.N. Arava, 86840
cell: 0523-665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)

Markus Metz wrote:

On Wed, Jan 28, 2015 at 10:34 PM, Micha Silver <micha@arava.co.il> wrote:
> When I use r.composite to create, i.e., a false_color composite from three
> Landsat bands, the RGB values in the composite are slightly different than
> the values in the original bands. Why is that?

Because the number of levels to be used for each component is by
default 32, not 256 [0].

You can use levels=256 if you want 256 levels. But the resulting map
will have a very large colour table (65536 rules), which will
negatively affect the performance of anything which reads the colour
table. Which is why the default is 32 levels rather than 256.

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

Thanks for clarifying.
We always have to answer claims such as: “…but Arc* does like this…”.

We noticed the problem when compositing Landsat tiles in an area with very uniform landscape. The slight shift in RGB values with the default level=32 led to many adjacent pixels getting the same color value, and the result looked very “blocky”.

···

On 30-Jan-15 2:33 PM, Glynn Clements wrote:

Markus Metz wrote:

On Wed, Jan 28, 2015 at 10:34 PM, Micha Silver [<micha@arava.co.il>](mailto:micha@arava.co.il) wrote:

When I use r.composite to create, i.e., a false_color composite from three
Landsat bands, the RGB values in the composite are slightly different than
the values in the original bands. Why is that?

Because the number of levels to be used for each component is by
default 32, not 256 [0].

You can use levels=256 if you want 256 levels. But the resulting map
will have a very large colour table (65536 rules), which will
negatively affect the performance of anything which reads the colour
table. Which is why the default is 32 levels rather than 256.

-- 
Moshav Idan
D.N. Arava, 86840
cell: 0523-665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)