Opened 8 years ago

Closed 8 years ago

#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 8 years ago.
gdalgeopackagerasterband.cpp (76.8 KB ) - added by ccjklppp 8 years ago.
gdalmediancut.cpp (38.9 KB ) - added by ccjklppp 8 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by Even Rouault, 8 years ago

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 by ccjklppp, 8 years ago

contact@???

in reply to:  2 ; comment:3 by Even Rouault, 8 years ago

Replying to ccjklppp:

contact@???

See http://spatialys.com

in reply to:  3 comment:4 by ccjklppp, 8 years ago

Replying to rouault:

Replying to ccjklppp:

contact@???

See http://spatialys.com

I sent you an email. thanks.

by ccjklppp, 8 years ago

Attachment: gdal_alg_priv.h added

by ccjklppp, 8 years ago

by ccjklppp, 8 years ago

Attachment: gdalmediancut.cpp added

comment:5 by ccjklppp, 8 years ago

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 by Even Rouault, 8 years ago

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 by ccjklppp, 8 years ago

I'll check it out

in reply to:  6 comment:8 by ccjklppp, 8 years ago

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

comment:9 by Even Rouault, 8 years ago

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