フィルターのクリア

Calculate the mean of nonzero pixels and setting a threshold

3 ビュー (過去 30 日間)
Demy
Demy 2022 年 8 月 5 日
回答済み: Matt J 2022 年 8 月 5 日
I have a 3D binary mask and a 4D array with some values. I calculate the mean of my array which corresponds to the regions of my mask.
my_mean = accumarray(double(mask(:))+1, my_array(:),[], @nanmean, 0)
I would like to set a threshold. i.e., if the value in the array is more than 100 then ignore it from the calculation. I tried the following without success. Any help is highly appreciated.
my_mean = accumarray(double(mask(:))+1, my_array(:),[], @nanmean, 0, my_array(:)<99)

回答 (1 件)

Matt J
Matt J 2022 年 8 月 5 日
fun=@(z) nanmean(z(z<99));
my_mean = accumarray(double(mask(:))+1, my_array(:),[], fun)

Community Treasure Hunt

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

Start Hunting!

Translated by