Getting mean row vector from a cell array of row vectors of the same size

1 回表示 (過去 30 日間)
Matthew Peoples
Matthew Peoples 2021 年 5 月 26 日
回答済み: Allen 2021 年 5 月 26 日
Hi there,
I have a cell array of 1x60, each containing a double/row vector of 1x256 - each of these a histogram of an image of values from 0 to 255.
I need to find the mean row vector/histogram across all 60 of these images i.e. the average of cells 1-256 across all 60. I understand the logic but don't know how to code it.
Any help would be very much appreciated. Thank you.

採用された回答

Jonas
Jonas 2021 年 5 月 26 日
編集済み: Jonas 2021 年 5 月 26 日
so if i understood you correctly each cell contains histogram values with 256 bins each and you want to know mean count for each bin: in this case use cell2mat which converts your 1x60 cell to a 256x60 matrix. the use mean() which operates columnwise. then you get medium count for each bin

その他の回答 (1 件)

Allen
Allen 2021 年 5 月 26 日
It is not entire clear to me what you are trying to average. However, if I am understanding correctly, the following example attempts to duplicate your 1x60 cell-array with 1x256 numerical arrays, where each numerical array contains a randomly assigned value from 0 to 255 for each element. I then determine the average of all values in each 1x256 numerical array and since there are 60 elements in the cell-array, the end result is a 1x60 numerical array. If this not what you are looking for please provide more details and include your an example of your initial data and a few snippets of code that you have already attempted.
% Attempts to duplicate your datasets as elements in a cell-array (each cell-array element is a 1x256 numerical array)
C = arrayfun(@(x) randi([0,255],[1,256]),1:60,'un',0);
% Calculates the overall average for each element in the cell-array
avg = cellfun(@mean,C);

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by