Opened 17 years ago

Closed 9 years ago

#1867 closed enhancement (invalid)

HFARasterBand::GetColorInterpretation can't report RGB colorspace

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

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 (1)

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

Download all attachments as: .zip

Change History (6)

by mrosen, 17 years ago

Attachment: AuxFileTest.aux added

rgb aux file

comment:1 by mrosen, 17 years ago

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

comment:2 by Even Rouault, 13 years ago

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

comment:3 by mrosen, 13 years ago

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 ;-).

comment:4 by Kyle Shannon, 9 years ago

Cc: Kyle Shannon added

comment:5 by Jukka Rahkonen, 9 years ago

Resolution: invalid
Status: newclosed

AFAIK the ERDAS Imagine HFA format is not made to support such interpretation. Layers are labeled individually to thematic/athematic layers. Format does not assign certain source bands to fixed R G B channel for visualization. For example the example in ERDAS Field guide on page 135 shows athematic layers 3-2-1 as R-G-B http://www.ltrs.uri.edu/teaching/FieldGuide.pdf.

Closing as invalid. Reopen if you do not agree and add some clarification why.

Note: See TracTickets for help on using tickets.