Opened 21 years ago

Closed 19 years ago

#270 closed enhancement (fixed)

24-bit image processing crash

Reported by: warmerdam Owned by: sdlime
Priority: high Milestone:
Component: GDAL Support Version: 4.1
Severity: minor Keywords:
Cc: bfraser@…

Description

Frank,
 
  I've got a build of Mapserver on Win2k (nightly snapshot from 2003/01/14,
GD-2.0.10,with GDAL-1.1.8).  It crashes when I have a CLASS defined for a raster
layer of a 24-bit tif:
 
LAYER
  NAME 'TopoMaps'
  GROUP "Raster Backdrops" 
  TYPE raster
  STATUS on
  PROJECTION
    "proj=utm"
    "ellps=WGS84"
    "zone=12"
     "north"
  END
  DATA 'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83_24.tif'
#  DATA 'C:\Inetpub\wwwroot\modis\site\basemap\072l12nc_83.tif'
    CLASS
     NAME "1:50k Topomaps"
    END
END  # LAYER
 
But doesn't crash when the tif is 8-bit /paletted (then it renders all the
pixels as blue, but that's a different problem).
 
In the debugger it shows it's caused by msDrawRasterLayerGDAL (mapdrawgdal.c
around line 414) :
======================================================================
  /*
   * Setup the mapping between source eightbit pixel values, and the
   * output images color table.  There are two general cases, where the
   * class colors are provided by the MAP file, or where we use the native
   * color table.
   */
  if(layer->numclasses > 0 && gdImg ) {
    int c;
 
    cmap_set = TRUE;
 
    for(i=0; i<GDALGetColorEntryCount(hColorMap); i++) {
        GDALColorEntry sEntry;
        colorObj pixel;
 
        GDALGetColorEntryAsRGB( hColorMap, i, &sEntry );
=======================================================================
It appears to crash since hColorMap is NULL and the called function attempts to
access it's data members.
 
I'm not clear why msDrawRasterLayerGDAL is trying to do ColorMap processing on a
24-bit image.
 
Any thoughts?
 
Brent Fraser
GeoAnalytic Inc.
Tel:(403) 213-2700
bfraser@geoanalytic.com
www.geoanalytic.com

Change History (7)

comment:1 by fwarmerdam, 21 years ago

Brent,

OK, there are a few issues going on. 

I fixed the crash problem, the changes are in CVS. 

However, you still can't meaningfully use classification expressions on 
24bit images.  The classification mechanism is implemented by classying just
the 256 possible image pixel values for 8 bit images, then using the resulting
lookup table to classify the actual pixels encountered during processing the
image.  However, for 24bit images this isn't practical.  Classification would
have to be done for each pixel which would be quite expensive. 

For now what happens is that if you use classification, only the first of 
the indicated bands will be utilized, and a greyscale colortable will be 
applied to it.  

I am leaving this bug report open as a focus for considering per-pixel 
classification which would enable classifying 24bit images, as well as doing
real non-eight bit input classification though at a considerable runtime
cost. 

Finally, I have incorporated a new test in msautotest/gdal/classtest2.map for
classification on a 24 bit input raster.

comment:2 by bfraser@…, 21 years ago

Cc: bfraser@… added

comment:3 by bfraser@…, 21 years ago

Frank,

  Just to clarify, I was using CLASS in the LAYER def to produce a legend entry 
using HTML Legends(no CLASS = no legend entry), not to classify the raster. 

  Perhaps if there is no EXPRESSION entry in the CLASS, GDAL should skip the 
classification process?

Brent

comment:4 by fwarmerdam, 21 years ago

Owner: changed from fwarmerdam to sdlime
Steve,

Brent mentions that he was using a CLASS with an RGB layer with
the intention of producing a legend entry, but not really wanting to
affect the way the layer looks.  Currently if there are classes the
raster code treats a layer quite differently. 

Do you have any thoughts on how Brent could generate a legend entry in another
way, or if there is some mechanism by which I should avoid treating the layer
as classified?

comment:5 by dmorissette, 21 years ago

Version: 4.04.1
Let's revisit this in 4.1 as an enhancement.

comment:6 by fwarmerdam, 20 years ago

Severity: normalenhancement
I have reclassified this as an enhancement request.  I do *not* believe
we should try and address it for 4.4.

comment:7 by fwarmerdam, 19 years ago

Resolution: fixed
Status: newclosed
For 4.6.0 beta2 I have changed mapdrawgdal.c so that it does not use
classification rendering if there are no expressions attached to any of 
the CLASSes.  In this case the classes can be used for setting legend
entries, but have no effect on rendering itself.

Also addressed in bug 985 and bug 1015.

Note: See TracTickets for help on using tickets.