Ticket #1867 (new enhancement)

Opened 6 years ago

Last modified 22 months ago

HFARasterBand::GetColorInterpretation can't report RGB colorspace

Reported by: mrosen Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

HFARasterBand::GetColorInterpretation? can't report RGB colorspace.

I'm attaching two files to illustrate the issue

  • an AUX file for an RGB image.
  • an IMG file for a grayscale image.

In both cases gdalinfo reports ColorInterp?=Undefined for all bands. Using the fix below, the bands are reported correctly. ==========================

/************************************************************************/
/*                       GetColorInterpretation()                       */
/************************************************************************/

GDALColorInterp HFARasterBand::GetColorInterpretation()

{
    HFADataset *poHDS = (HFADataset *) poDS;
    if (poHDS->nBands == 3)
    {
        switch (nBand)
        {
          case 1: return GCI_BlueBand;
          case 2: return GCI_GreenBand;
          case 3: return GCI_RedBand;
        }
    }
    else if (poCT != NULL)
    {
        return GCI_PaletteIndex;
    }
    else if (poHDS->nBands == 1) return GCI_GrayIndex;
    return GCI_Undefined;
    /*
    if( poCT != NULL )
        return GCI_PaletteIndex;
    else
        return GCI_Undefined;
    */
}

Attachments

AuxFileTest.aux Download (5.7 KB) - added by mrosen 6 years ago.
rgb aux file

Change History

Changed 6 years ago by mrosen

rgb aux file

Changed 6 years ago by mrosen

the IMG file was too big to attach. see me if you need it. the patch is pretty straightforward though.

Changed 22 months ago by rouault

Is there a reason considering that a 3 band should be always interpreted as RGB ?

Changed 22 months ago by mrosen

In general, it seems like it's more right than wrong. I imagine there are cases where is this wrong (BGR and NIR-G-B come to mind -- though I don't know if there are such HFA files in practice).

It would be great if the driver could read metadata to ensure that colorinterp is reported correctly... but I could not see how that would work. Absent that, I think that assuming a 3 band image is RGB is a better choice than saying it's undefined ... at least it was for cases we were dealing with ;-).

Note: See TracTickets for help on using tickets.