Combining 5 different bands to generate one sinlge image.

4 ビュー (過去 30 日間)
Amit Bhasin
Amit Bhasin 2019 年 1 月 20 日
コメント済み: Amit Bhasin 2019 年 2 月 20 日
How can I cobmine 5 different multispectral bands (R,G,B, NIR, RedEdge). They all are in .tiff version?
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 20 日
I notice your reference to NIR and RedEdge, both of which are associated with satellite images. I wonder if it would be appropriate to be building a GeoTIFF instead of a plain TIFF ?
Amit Bhasin
Amit Bhasin 2019 年 1 月 20 日
Actually, I took the images using a multispectral camera on a UAV drone!

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 20 日
Sample code:
filename = 'test5.tif';
if exist('R', 'var')
numrows = size(R,1);
numcols = size(R,2);
else
%this entire section is just creating data to write out, and the details
%do not matter. There is no significance to the 87 and 207 and so on,
%I just put them in to have distinguishable layers.
numrows = 64;
numcols = 80;
rng(12345);
R = sort(randi([0 255], numrows, numcols, 'uint8'));
G = sort(randi([0 255], numrows, numcols, 'uint8'), 2, 'descend');
B = sort(randi([0 255], numrows, numcols, 'uint8'), 1, 'descend');
NIR = max(min(G, 87), 207) - randi([0 50], numrows, numcols, 'uint8');
RedEdge = randi([50 223], numrows, numcols, 'uint8');
end
%serious code starts here
data = cat(3,R, G, B, NIR, RedEdge);
t = Tiff(filename, 'w');
setTag(t,'Photometric', Tiff.Photometric.MinIsBlack);
setTag(t,'Compression', Tiff.Compression.None);
setTag(t,'BitsPerSample', 8);
setTag(t,'SamplesPerPixel', size(data,3));
setTag(t,'SampleFormat', Tiff.SampleFormat.UInt);
setTag(t,'ExtraSamples', Tiff.ExtraSamples.Unspecified);
setTag(t,'ImageLength', numrows);
setTag(t,'ImageWidth', numcols);
setTag(t,'TileLength', 32);
setTag(t,'TileWidth', 32);
setTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
write(t, data);
close(t);
  1 件のコメント
Amit Bhasin
Amit Bhasin 2019 年 2 月 20 日
Thanks Walter Roberson! It worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by