#6146 closed defect (fixed)

ComputeMedianCutPCT issues an empty color table

Reported by: ccjklppp Owned by: warmerdam
Priority: highest Milestone: 2.1.0
Component: Algorithms Version: 2.0.1
Severity: critical Keywords: ComputeMedianCutPCT
Cc:

Description

I'm using the ComputeMedianCutPCT method to calculate a color table for 60 tiffs (less than 17GB in total). First we created a VRT mosaic of all the tiffs, then we used it as the input for the ComputeMedianCutPCT method. The result was a color table that contains only 1 color. When the set was reduced to only 40 tiffs, the color tables was ok (contained 240 colors as requested). We tried with 2 different sets and the outcome was the same - when the size is bigger than ~15GB, the result color tables contains only 1 value =(124,124,124). It seems that the size of the input creates this problem. Please help!

Attachments (3)

gdal_alg_priv.h (8.7 KB) - added by ccjklppp 20 months ago.
gdalgeopackagerasterband.cpp (76.8 KB) - added by ccjklppp 20 months ago.
gdalmediancut.cpp (38.9 KB) - added by ccjklppp 20 months ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 20 months ago by Even Rouault

It seems that the current algorithm hasn't been designed to work if a color bucket is hit more than 2 billion times. 64 bit counts might be needed in that case. I can be contacted at contact@… .

comment:2 Changed 20 months ago by ccjklppp

contact@???

comment:3 in reply to:  2 ; Changed 20 months ago by Even Rouault

Replying to ccjklppp:

contact@???

See http://spatialys.com

comment:4 in reply to:  3 Changed 20 months ago by ccjklppp

Replying to rouault:

Replying to ccjklppp:

contact@???

See http://spatialys.com

I sent you an email. thanks.

Changed 20 months ago by ccjklppp

Attachment: gdal_alg_priv.h added

Changed 20 months ago by ccjklppp

Changed 20 months ago by ccjklppp

Attachment: gdalmediancut.cpp added

comment:5 Changed 20 months ago by ccjklppp

Hi,

I fixed the problem by changing all the counters from int to GIntBig type. The 3 files that was changes are attached. Can you please insert the changes to the source control?

thanks.

comment:6 Changed 20 months ago by Even Rouault

ccjklppp, I'd appreciate if you could test the below fix and confirm it works. It is a variant of your fix but that uses GUInt32 or GUIntBig depending on the raster dimensions, so as to limit the amount of memory to the strict necessary.

trunk r31065 "GDALComputeMedianCutPCT(): fix to make it work with rasters with more than 2 billion pixels (more precisely when a color bucket has more than > 2 billion pixel occurence, #6146)"

comment:7 Changed 19 months ago by ccjklppp

I'll check it out

comment:8 in reply to:  6 Changed 19 months ago by ccjklppp

I've checked it on small and large datesets and it seems to work...

comment:9 Changed 19 months ago by Even Rouault

Milestone: 2.0.22.1.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.