Why am I getting an error warning about extrasamples with geotiffwrite ?

When I call geotiffwrite I receive an error warning, and I do not understand why. My call is as follows ...
geotiffwrite(FilenameOutput,RGBdata,R,CoordRefSysCode,EPSG:4283');
RGBdata is 9601 x 13441 x 3 (double)
R is a GeographicCellsReference with properties that include RasterSize: [9601 13441] that is consistent with RGBdata
I cannot see where there are any ExtraSamples (e.g., Alpha informtion) in my call. I am trying to supply just 3 Photometric color channels per pixel.
I have placed a Service Request (case 03924628), but surprisingly and with disappointment, I am not getting useful assistance. I am hoping that someone else may be able to help.
The warning is ...
=====
Warning: Sum of Photometric color channels and ExtraSamples does not match the value specified in SamplesPerPixel.
Writing with this configuration will error in a future release. To correct the configuration, define the non-color channels as ExtraSamples.
In Tiff/writeAllTiles (line 2254)
In Tiff/write (line 1480)
In geotiffwrite>writeImage (line 1510)
In geotiffwrite>writeGeoTiffFile (line 1492)
In geotiffwrite (line 271)
In HSI_image (line 582)
In HSI_2019_FAA_B1_20191216 (line 259)
=====

2 comentarios

Please attach RGBdata and R for testing.
Hello Walter.
I have attached R.mat so that you can recover "R".
RGBdata is huge, so for testing it would be better to generate it yourself using rand ...
%%%%%
load('R.mat');
RGBdata = rand(9601,13441,3);
geotiffwrite([FilenameOutput '_test'],RGBdata,R,'CoordRefSysCode',['EPSG:4283']);
%%%%%
This generates the same error warning as the original "RGBdata"
Thank-you for looking into this ... Richard

Iniciar sesión para comentar.

 Respuesta aceptada

geotiffwrite function assignTiffTags assumes that RGB images are only uint8 or uint16 . You are passing in double, so it thinks you are doing a grayscale image with Extra Samples, except that it does not construct an Extra Samples tag to account for the possibility.
The workaround is
geotiffwrite([FilenameOutput '_test'],RGBdata,R,'CoordRefSysCode',['EPSG:4283'], 'tifftags', struct('Photometric', Tiff.Photometric.RGB));

4 comentarios

Hello again Walter.
Thank-you for pointing this out. If I had known that the data had to be unit8 or unit16, it would have been straight forward to comply with this. The documentation said that the input image could be double, but did not indicate that this was only under certain conditions.
I modified my code to convert to my input RGB image to a 24-bit RGB image prior to calling geotiffwrite. The geotiff file is now written withour an error warning.
RGBdata8bit = uint8(round(RGBdata.*255));
geotiffwrite([FilenameOutput '_test'],RGBdata8bit,R,...
'CoordRefSysCode',['EPSG:',num2str(EPSGCode)]);
Once again, thank-you. I have been stumped for ages by this. ... Richard
By the way, use im2uint8()
I just filed a bug report on this.
So many functions, so much to learn! Thanks - I see that im2unit8 is a shortcut for the conversion. ... Richard

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 19 de Dic. de 2019

Comentada:

el 21 de Dic. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by