Clear Filters
Clear Filters

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

13 views (last 30 days)
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 Comments
Richard
Richard on 19 Dec 2019
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

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 21 Dec 2019
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 Comments
Richard
Richard on 21 Dec 2019
So many functions, so much to learn! Thanks - I see that im2unit8 is a shortcut for the conversion. ... Richard

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!