[GRASS-user] Quantization of a true color GeoTIFF

Hi,

I have a 16244x12706 GeoTIFF file (600dpi scan) which is made up of 7
colors but came as a 3-band 24bit True Color image.

I can import with r.in.gdal as red,green,blue bands, but it's huge and
slow.

I can't use pnmquant as it overflows the RAM. (I have 2GB physical + 2GB
swap)

I tried Indexing it to a small number of colors with the Gimp, but after
the process the colors were all changed. I can index as 256 colors with
little color change in the Gimp, but that is still 249 more than I need.

I want a CELL map with cat=[1,2,3,4,5,6,7] values with RGB set for each
category by r.colors.

I guess I can use the Gimp to index to 7 (wrong) colors, import that into
GRASS, then use r.colors + the Gimp's eye-dropper tool on the original to
fix them.

Staying with the original 3-band import, how to find the 7 peaks in the
r.composite histogram, filter out anything that isn't a peak by changing
its value to be that of the nearest peak, and reclass to 1-7? As
r.reclass can take ranges for input, I guess I can be a bit sloppy in
finding the peaks and use the result of r.stats as input to r.reclass,
then extract a "hardcopy" from the reclass map with r.mapcalc a=b.

?
any one have a bright idea how to do this with minimal data loss
?

thanks,
Hamish

Hamish schrieb:

Hi,

I have a 16244x12706 GeoTIFF file (600dpi scan) which is made up of 7
colors but came as a 3-band 24bit True Color image.

I can import with r.in.gdal as red,green,blue bands, but it's huge and
slow.

I can't use pnmquant as it overflows the RAM. (I have 2GB physical + 2GB
swap)

I tried Indexing it to a small number of colors with the Gimp, but after
the process the colors were all changed. I can index as 256 colors with
little color change in the Gimp, but that is still 249 more than I need.

I want a CELL map with cat=[1,2,3,4,5,6,7] values with RGB set for each
category by r.colors.

I guess I can use the Gimp to index to 7 (wrong) colors, import that into
GRASS, then use r.colors + the Gimp's eye-dropper tool on the original to
fix them.

Staying with the original 3-band import, how to find the 7 peaks in the
r.composite histogram, filter out anything that isn't a peak by changing
its value to be that of the nearest peak, and reclass to 1-7? As
r.reclass can take ranges for input, I guess I can be a bit sloppy in
finding the peaks and use the result of r.stats as input to r.reclass,
then extract a "hardcopy" from the reclass map with r.mapcalc a=b.

?
any one have a bright idea how to do this with minimal data loss
?

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

you could try the script rgb2pct which is included in the gdal utilities. with "-n number" you can set the number of colors.

regards
wolfgang

WolfgangZ schrieb:

Hamish schrieb:

Hi,

I have a 16244x12706 GeoTIFF file (600dpi scan) which is made up of 7
colors but came as a 3-band 24bit True Color image.

I can import with r.in.gdal as red,green,blue bands, but it's huge and
slow.

I can't use pnmquant as it overflows the RAM. (I have 2GB physical + 2GB
swap)

I tried Indexing it to a small number of colors with the Gimp, but after
the process the colors were all changed. I can index as 256 colors with
little color change in the Gimp, but that is still 249 more than I need.

I want a CELL map with cat=[1,2,3,4,5,6,7] values with RGB set for each
category by r.colors.

I guess I can use the Gimp to index to 7 (wrong) colors, import that into
GRASS, then use r.colors + the Gimp's eye-dropper tool on the original to
fix them.

Staying with the original 3-band import, how to find the 7 peaks in the
r.composite histogram, filter out anything that isn't a peak by changing
its value to be that of the nearest peak, and reclass to 1-7? As
r.reclass can take ranges for input, I guess I can be a bit sloppy in
finding the peaks and use the result of r.stats as input to r.reclass,
then extract a "hardcopy" from the reclass map with r.mapcalc a=b.

?
any one have a bright idea how to do this with minimal data loss
?

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

you could try the script rgb2pct which is included in the gdal utilities. with "-n number" you can set the number of colors.

regards
wolfgang

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

at least rgb2pct is included in the wftools http://fwtools.maptools.org/ not sure if it officially belongs to gdal utilities.

On Feb 11, 2008 9:43 AM, WolfgangZ <wollez@gmx.net> wrote:

WolfgangZ schrieb:

...

at least rgb2pct is included in the wftools http://fwtools.maptools.org/
  not sure if it officially belongs to gdal utilities.

It does:

locate rgb2pct
/home/neteler/software/gdal/swig/python/scripts/rgb2pct.py

You need to compile GDAL with python support of course.

Markus

> Hamish schrieb:
>> I have a 16244x12706 GeoTIFF file (600dpi scan) which is made up
>> of 7 colors but came as a 3-band 24bit True Color image.

...

>> I want a CELL map with cat=[1,2,3,4,5,6,7] values with RGB set for
>> each category by r.colors.

WolfgangZ wrote:

> you could try the script rgb2pct which is included in the gdal
> utilities. with "-n number" you can set the number of colors.

Thanks. I had a look at that but it dithers, which I wish to avoid.

Adam Dershowitz provided a tip which solved this for me.
Gimp was thresholding it against some standard palette spread causing
bad results. I could deal with modifying the palette, but two of the 7
colors were shades of blue, they were always lumped together. From the
description of rgb2pct that may be a bit smarter in that regard.

The trick was to create a custom palette in the Gimp using the
eye-dropper tool on the original image to grab the colors. Then run the
Gimp's indexing tool with that palette as the guide, and it gave me the
desired 7 color map to pass to GRASS. From there it all worked nicely.

cheers,
Hamish

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ