Loop into cell array

1 回表示 (過去 30 日間)
Stu
Stu 2018 年 3 月 2 日
回答済み: Image Analyst 2018 年 3 月 2 日
I am trying to combine 4 separate bands into a multispectral image (960x1280x4).
I have 4 cell arrays of 1315x1 each and I am using 'cat' function to combine.
test=cell(1315,1)
for i=1:1315
test(i)=cat(3,G{i},R{i},RE{i},N{i});
end
I am getting error as "Conversion to cell from uint16 is not possible."
Please help
  2 件のコメント
Bob Thompson
Bob Thompson 2018 年 3 月 2 日
How does your code define G, R, RE, and N?
Stu
Stu 2018 年 3 月 2 日
編集済み: Stu 2018 年 3 月 2 日
Green band, red band, Red Edge band and NIR band. So each of them is a 1315x1 cell array

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

回答 (1 件)

Image Analyst
Image Analyst 2018 年 3 月 2 日
You need to use braces to put each created image into a new cell. See the FAQ to get a good, intuitive feel for what a cell array is http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Try this:
numImages = length(G);
allImages = cell(numImages , 1);
for k = 1 : numImages
allImages{k} = cat(3, G{k}, R{k}, RE{k}, N{k});
end

カテゴリ

Help Center および File ExchangeHyperspectral Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by