[GRASS-user] Is mosaicing 24 bit images possible in Grass 6.2?

Dear all,

I intend to mosaic two 24 bit images in LAT LON location.
I imported a 24 bit coloured PNG image in Grass using r.in.gdal in an x-y location.
GRASS treated it as a combination of three 8 bit images, one for red, one for green,
and one for blue and imported them as three separate maps.

After going through the archives, I tried to use r.patch to combine all the three components.
The output of which wasn’t a 24bit image but was only one of the components. (Not coloured)

d.rgb module does display a coloured 24 bit image after inputing the three components to it.

I geocoded them to get non-coloured 8 bit geocoded images in the target location.

I did the same for the second 24 bit image.
Mosaicing works fine(i.image.mosaic), but i need to use 8 bit images(24 bit images converted to 8 bit images prior to importing, using xv; resolution weak)
or any one of the 8 bit components of a 24 bit image.

Is there a way to mosaic 24 bit images and to output it as a single 24 bit image?

Regards
Nagesh


www.nio.org
www.indian-ocean.org
www.reefindia.org
www.coastalhazards.info
www.coastalhazards.in
www.mangroveindia.org

On 03/07/08 14:35, Nagesh Bhatkar wrote:

Dear all,

I intend to mosaic two 24 bit images in LAT LON location.
I imported a 24 bit coloured PNG image in Grass using r.in.gdal in an x-y location.
GRASS treated it as a combination of three 8 bit images, one for red, one for green,
and one for blue and imported them as three separate maps.

After going through the archives, I tried to use r.patch to combine all the three components.
The output of which wasn't a 24bit image but was only one of the components. (Not coloured)

d.rgb module does display a coloured 24 bit image after inputing the three components to it.

I geocoded them to get non-coloured 8 bit geocoded images in the target location.

I did the same for the second 24 bit image.
Mosaicing works fine(i.image.mosaic), but i need to use 8 bit images(24 bit images converted to 8 bit images prior to importing, using xv; resolution weak)
or any one of the 8 bit components of a 24 bit image.

Is there a way to mosaic 24 bit images and to output it as a single 24 bit image?

r.composite (Raster->Manage map colors->Create RGB)

Moritz

Nagesh wrote:

I intend to mosaic two 24 bit images in LAT LON location.
I imported a 24 bit coloured PNG image in Grass using
r.in.gdal in an x-y location.
GRASS treated it as a combination of three 8 bit images,
one for red, one for green, and one for blue and imported
them as three separate maps.

After going through the archives, I tried to use r.patch to
combine all the three components.

I think you mean to use r.composite there, not r.patch.

The output of which wasn't a 24bit image but was only
one of the components. (Not coloured)

the first map was "patched" over top of the other two.

d.rgb module does display a coloured 24 bit image after
inputing the three components to it.

Correct.

I geocoded them to get non-coloured 8 bit geocoded images
in the target location.

I did the same for the second 24 bit image.
Mosaicing works fine(i.image.mosaic), but i need to use 8
bit images(24 bit images converted to 8 bit images prior to
importing, using xv; resolution weak)
or any one of the 8 bit components of a 24 bit image.

Is there a way to mosaic 24 bit images and to output it as
a single 24 bit image?

# expand region to cover both image regions
g.region rast=map1.red,map2.red

# merge bands together
for COLOR in red green blue ; do
  r.patch in=map1.${COLOR},map2.${COLOR} out=map.${COLOR}
end

# display mosaicked image
d.rgb r=map.red g=map.green b=map.blue

You will lose information if you use r.composite, best to keep bands separate unless you absolutely must combine them. (e.g. for NVIZ color drape)

Hamish

On Thu, Jul 3, 2008 at 3:39 PM, Hamish <hamish_b@yahoo.com> wrote:

You will lose information if you use r.composite,
best to keep bands separate unless you absolutely must combine
them. (e.g. for NVIZ color drape)

maybe also try:

i.image.mosaic
Description:
Mosaics up to 4 images and extends colormap; creates map *.mosaic

Markus

Hamish pisze:

Nagesh wrote:

Is there a way to mosaic 24 bit images and to output it as
a single 24 bit image?

To export a 24 bit image make a group of the 3 bands (i.group) and export the *group* using r.out.gdal (gdal_translate can do that also from outside GRASS, if you choose it's input as a path to your group file). This way you don't loose data as it would be the case for r.composite.

Note that you can nicely visualise GRASS raster groups in QGIS, if at adding the GRASS raster layer you choose a group.

Maciek

--
Maciej Sieczka
www.sieczka.org

On Thursday 03 July 2008, Maciej Sieczka wrote:

Hamish pisze:
> Nagesh wrote:
>> Is there a way to mosaic 24 bit images and to output it as
>> a single 24 bit image?

To export a 24 bit image make a group of the 3 bands (i.group) and
export the *group* using r.out.gdal (gdal_translate can do that also
from outside GRASS, if you choose it's input as a path to your group
file). This way you don't loose data as it would be the case for
r.composite.

Note that you can nicely visualise GRASS raster groups in QGIS, if at
adding the GRASS raster layer you choose a group.

Maciek

This is an excellent tip. Is this documented anywhere?

Cheers,

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

On 03/07/08 15:39, Hamish wrote:

You will lose information if you use r.composite,

Just for my understanding: if you set levels to 256, you won't lose information, or ?

It will just make displaying the result very slow.

Moritz

Moritz Lennert wrote:

> You will lose information if you use r.composite,

Just for my understanding: if you set levels to 256, you won't lose
information, or ?

It will just make displaying the result very slow.

Correct.

That assumes that the bands are limited to 256 levels. If you have
more than that, it is impossible to generate a composite image without
losing precision, as r.composite doesn't allow more than 256 levels.
There isn't really much point; the only reason for generating a
composite image is for display. For analysis, you are better off using
separate bands.

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

Dylan Beaudette pisze:

On Thursday 03 July 2008, Maciej Sieczka wrote:

This is an excellent tip. Is this documented anywhere?

In r.out.gdal manual. There are couple of references to imagery group vs
GDAL in r.in.gdal man as well.

Maciek

--
Maciej Sieczka
www.sieczka.org