Opened 15 years ago
Closed 10 years ago
#2914 closed defect (fixed)
Building RRD overviews using AVERAGE_BIT2GRAYSCALE results in wrong value
Reported by: | gaopeng | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | GDAL_Raster | Version: | 1.6.0 |
Severity: | normal | Keywords: | overviews |
Cc: |
Attachments (2)
Change History (13)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I can't reproduce this anymore. I closed it as non-reproducible.
comment:3 by , 15 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
I reopen this ticket with a new test case. The attached is an 1-bit tiff image with an external tiff overview (.ovr) with AVERAGE_BIT2GRAYSCALE (created by making tiff read-only). The overview pixel values are 1 instead of 255.
by , 15 years ago
comment:4 by , 15 years ago
Keywords: | overviews added |
---|---|
Milestone: | 1.6.1 → 1.6.3 |
I have confirmed that if I copy the .tif file to wrk.tif and run the following the generated overviews are still just 0/1 valued - and in fact the overviews are 1bit.
gdaladdo -r average_bit2grayscale wrk.tif 2 warmerda@gdal64[146]% tiffinfo wrk.tif.ovr TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480) encountered. TIFF Directory at offset 0x8 (8) Subfile Type: reduced-resolution image (1 = 0x1) Image Width: 5388 Image Length: 6564 Tile Width: 128 Tile Length: 128 Bits/Sample: 1 Sample Format: unsigned integer Compression Scheme: None Photometric Interpretation: min-is-black Samples/Pixel: 1 Planar Configuration: single image plane Tag 42112: <GDALMetadata><Item name="RESAMPLING" sample="0">AVERAGE_BIT2GRAYSCALE</Item></GDALMetadata>
It would appear there are smarts in the TIFF driver for creation of the overviews of NBITS=1 files with one bit depth that need to be disabled for this kind of overview sampling.
comment:5 by , 15 years ago
Milestone: | 1.6.3 → 1.7.0 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
comment:6 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
by , 13 years ago
Attachment: | rrd1bit.zip added |
---|
comment:7 by , 13 years ago
It appears that HFACreateOverview() always creates overviews for a 1bit layer as 1bit overviews. The resampling algorithm is not consulted. So even though things are promoted to 8bit and computed in greyscale the result is demoted to 1bit on write.
I tested with the command:
gdaladdo -r average_bit2grayscale sw_pyr2.img --config USE_RRD YES --config HFA_USE_RRD YES 2
I will dig into ensuring HFACreateOverview() can be forced to create 8bit overviews for 1bit layers if bit2grayscale is in effect.
comment:8 by , 13 years ago
I have fixed the code so the overview is generated as 8bit instead of 1bit for this particular overview algorithm. I also found I had to fix things so that HFARasterBand has an nHFADataType of EPT_u8 instead of EPT_u1 for the overview in this case or it was written corrupted.
Incidentally fixed GetFileList() to include .rrd.
The fixes are currently in trunk (r21352) with some regression testing (r21351).
Should this be back ported to 1.6-esri or some other branch?
comment:10 by , 10 years ago
Feels like undone back porting to 1.6-esri is the thing that has kept this otherwise resolved issue open. That back porting will never happen so close the issue as fixed.
comment:11 by , 10 years ago
Milestone: | 1.8.1 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
I have tried the following command:
on a 1 bit TIFF file, and produced .rrd overviews that seem to be correctly greyscale averaged in a byte overview type.
I did find I had to make some changes to avoid the new color table lookup logic when doing bit2grayscale overviews in trunk (r16884) and 1.6 branch (r16885) but I don't think this relates to the problem report directly.
Could you provide more detail on how I might reproduce this problem?