How to extract max from a cell?
10 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm dealing with image/video processing and I would like to extract the area of the biggest connected component for each frame. I have created a cell structure with the areas of each connected component in each frame. The problem is to create a proper "for loop" to store the values of max areas(from each frame) in an array. Then, I would like to do the same thing with mean(s) of pixels' intensity (for the biggest connected component). Any help will be extremely valuable. Thank you, Luisa
0 件のコメント
回答 (2 件)
Sandro Lecci
2018 年 5 月 17 日
Dear Luisa,
maybe the function cellfun does what you are looking for.
A = cell(3,1);
%Store with 3 matrices of different sizes
A{1} = magic(10);
A{2} = rand(20);
A{3} = ones(30);
%Extract the max of all cells
maxA = cellfun(@(X) max(max(X)), A)
Best, Sandro
0 件のコメント
KSSV
2018 年 5 月 17 日
% make some random cell for demo
A = cell(10,1) ;
for i = 1:10
A{i} = rand(randperm(10,1),1) ;
end
% get max using loop
iwant = zeros(length(A),1) ;
for i = 1:length(A)
iwant(i) = max(A{i}) ;
end
% use cellfun
m = cellfun(@max,A) ;
[iwant m]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!