Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4905 closed defect (fixed)

pct2rgb fails when palette/RAT has >256 entries

Reported by: Robert Coup Owned by: Robert Coup
Priority: normal Milestone: 1.10.0
Component: Utilities Version: svn-trunk
Severity: normal Keywords: pct2rgb


When running pct2rgb against an image having a colour table with >256 entries, it dies. The lookup array built from the colour table is built as max(256, len(colourTable)) rather than min(256, len(colourTable)), so lookups for entries after 256 fail:

$ pct2rgb -rgba rat.img test_pct2rgb_4.tif
  File "", line 167, in <module>
    dst_data = Numeric.take(band_lookup,src_data)
  File "/usr/lib/python2.7/dist-packages/numpy/core/", line 103, in take
    return take(indices, axis, out, mode)
IndexError: index out of range for array

I've attached a patch, test case, and am sourcing licensing release for the image used in the test case.

Attachments (1)

4905.diff (6.0 KB ) - added by Robert Coup 11 years ago.
Patch & test case

Download all attachments as: .zip

Change History (3)

by Robert Coup, 11 years ago

Attachment: 4905.diff added

Patch & test case

comment:1 by Even Rouault, 11 years ago

Milestone: 1.10.0
Resolution: fixed
Status: newclosed

I've applied the patch to in r25674 (but not the new test case since the source image is missing)

comment:2 by Robert Coup, 11 years ago

Added the test case in r25688.

The test data (trunk/autotest/gcore/data/rat.img) is from Land Environments New Zealand (LENZ) Level 2 - CC-BY Licensed by Ministry for the Environment. ERDAS Imagine conversion & processing by Landcare Research. Release for GDAL's test suite explicitly cleared.

Note: See TracTickets for help on using tickets.