[gdal-dev] GeoTiff and the 4th band
Even Rouault
even.rouault at mines-paris.org
Mon Apr 18 05:47:59 EDT 2011
Selon Nicolas Mayer <nmayer31000 at gmail.com>:
> Even, thank you very much for answering me so quicly
>
> With the PHOTOMETRIC creation option to MINISBLACK, I get now :
> Band 1 Block=100x20 Type=Byte, ColorInterp=Gray
> Band 2 Block=100x20 Type=Byte, ColorInterp=Undefined
> Band 3 Block=100x20 Type=Byte, ColorInterp=Undefined
> Band 4 Block=100x20 Type=Byte, ColorInterp=Undefined
>
> Does this option change anything in the metadatas or in the headers of the
> written file ?
Yes of course, otherwise how would you explain you get a difference ;-) ? This
change the value of the PHOTOMETRIC tiff tag in TIFF file.
>
> But I try to make the same thing as an exemple file I have, which has this
> interpretation whith gdalinfo (GDAL 1.7.3) :
>
> Metadata:
> TIFFTAG_IMAGEDESCRIPTION=B3 B2 B1 B4
> TIFFTAG_DATETIME=20050824 18:08:22
> AREA_OR_POINT=Point
> Image Structure Metadata:
> INTERLEAVE=BAND
> Corner Coordinates:
> Upper Left ( 0.0, 0.0)
> Lower Left ( 0.0, 3000.0)
> Upper Right ( 3000.0, 0.0)
> Lower Right ( 3000.0, 3000.0)
> Center ( 1500.0, 1500.0)
> Band 1 Block=3000x500 Type=Byte, ColorInterp=Red
> Band 2 Block=3000x500 Type=Byte, ColorInterp=Green
> Band 3 Block=3000x500 Type=Byte, ColorInterp=Blue
> Band 4 Block=3000x500 Type=Byte, ColorInterp=Undefined
>
> My goal is to have an "RGB-Undefined" color interpretation.
> Have you any idea of the creation option (or driver option ?) to set to have
> the same color interpretations ?
Actually after looking more precisely at the code and a bit of testing, I see
you can obtain the behaviour you wish by specifying both PHOTOMETRIC=RGB and
ALPHA=NO. (ALPHA=NO only will not be sufficient)
>
> Thank you in advance
>
> Nicky
>
>
>
> 2011/4/18 Even Rouault <even.rouault at mines-paris.org>
>
> > Selon Nicolas Mayer <nmayer31000 at gmail.com>:
> >
> > Retry by setting the PHOTOMETRIC creation option to MINISBLACK. Otherwise,
> > by
> > default, without specifying it, GDAL assumes that the PHOTOMETRIC is RGB
> > and
> > that the 4th band is an alpha band.
> >
> > You should get :
> > Band 1 Block=100x20 Type=Byte, ColorInterp=Gray
> > Band 2 Block=100x20 Type=Byte, ColorInterp=Undefined
> > Band 3 Block=100x20 Type=Byte, ColorInterp=Undefined
> > Band 4 Block=100x20 Type=Byte, ColorInterp=Undefined
> >
> > There's no way in the TIFF format to really specify the color
> > interpretation of
> > each band. The way GDAL builds the color interpretation when reading a TIFF
> > file
> > is a combination of the value of the PHOTOMETRIC and EXTRASAMPLES tag.
> >
> > > Hello
> > >
> > > I have a problem with the geotiff (GTiff) driver.
> > >
> > > I create a 4-bands raster image in a c++ program. The fourth band was
> > > considered as an alpha band in the geotiff image (actually, it is near
> > > infrared : NIR)
> > >
> > > $ gdalinfo new_geotiff.tif
> > > Driver: GTiff/GeoTIFF
> > > Files: new__geotiff.tif
> > > Size is 100, 100
> > > (...)
> > > Band 1 Block=100x20 Type=Byte, ColorInterp=Red
> > > Mask Flags: PER_DATASET ALPHA
> > > Band 2 Block=100x20 Type=Byte, ColorInterp=Green
> > > Mask Flags: PER_DATASET ALPHA
> > > Band 3 Block=100x20 Type=Byte, ColorInterp=Blue
> > > Mask Flags: PER_DATASET ALPHA
> > > Band 4 Block=100x20 Type=Byte, ColorInterp=Alpha
> > >
> > > How to remove the Color interpretation 'alpha' and the mask flags ?
> > >
> > > I want to have :
> > >
> > > Band 1 Block=100x20 Type=Byte, ColorInterp=Red
> > > Band 2 Block=100x20 Type=Byte, ColorInterp=Green
> > > Band 3 Block=100x20 Type=Byte, ColorInterp=Blue
> > > Band 4 Block=100x20 Type=Byte, ColorInterp=Undefined
> > >
> > > I already tryed :
> > > pDS->GetRasterBand(4)->SetColorInterpretation(GCI_Undefined );
> > >
> > > I tryed too to set the creation option : "ALPHA" to "NO".
> > >
> > >
> > > Thanks in advance for any help.
> > >
> > > Nicky
> > >
> >
> >
> >
>
More information about the gdal-dev
mailing list