ラベル付けされたtableをカウントする方法について
Afficher commentaires plus anciens
こんにちは。
ディープラーニングで学習するためのデータにラベル付けをおこないました。
そこで、各カテゴリごとのラベルの数を数えたいのですが方法が思いつきません。カテゴリは22種類あり、ラベル付けされているものは座標と幅、高さが記入されており、ラベル付けしてないものは空白のままです。tableの列方向のラベルの付いている数を知りたいです。
1万枚以上あるため、手動で数えるのは大変なのでなるべくプログラミングで実行したいです。
アイディア、アドバイス等ありましたら宜しくお願い致します。
5 commentaires
源樹 上林
le 21 Déc 2020
データはおおよそこんなイメージですか?
label = {'hoge';'hoge'; '';'hoge'};
zahyo = [ 1,2; 3,4;5,6; 7,8];
width = [ 1; 2; 3; 4];
height = [ 5; 6; 7; 8];
T = table(label, zahyo, width, height);
そして
T.label
のなかで、 '' と一致しない数の合計を数えたい。
という理解で合っていますか?
HY
le 23 Déc 2020
源樹 上林
le 23 Déc 2020
例の提示ありがとうございます。
forで回せば何でも解決でき…1万7千枚はあまり回したくはないですね。遅くなりそうな気がする。
nameImg = { '1.jpg', '2.jpg', '3.jpg' }';
label1 = {[2 2 22 33], [0], [5 6 90 87]}';
label2 = {[0], [9 8 30 28], [0]}';
T = table( label1, label2, 'RowNames', nameImg)
% ゼロ以外のインデックス
i = not( cellfun( @(x) isequal(x,0), T.label1 ) );
% ゼロ以外が取り出せていることを確認
T.label1(i)
% ゼロ以外の数
sum(i)
こういう感じですか?あとはこれを22回繰り返すとか。
ちょっとすっきりしない。
HY
le 23 Déc 2020
HY
le 24 Déc 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 製品のインストール dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!