Apply a mask to 4D medical images in a vectorized way
4 ビュー (過去 30 日間)
古いコメントを表示
Dear All,
I have a 4D array V, with the size [144 144 12 25]. In fact, it is a 4D medical image with 12 stacked slices in 25 different time. I want to apply a mask, named M, to each image in the array in a vectorized way. M is a 144x144 array containing logical values. Could someone help me how to do it?
Thanks,
Ahmad
1 件のコメント
José-Luis
2013 年 2 月 11 日
I notice that you don't seem accept many answers after asking questions. Some of the answers seemed valid to me. Please remember to accept answers if they help you, since it is the only "payment" the volunteers in this forum receive.
採用された回答
José-Luis
2013 年 2 月 11 日
編集済み: José-Luis
2013 年 2 月 12 日
data = rand(144,144,12,25);
your_mask = rand(144,144) > 0.5;
Assuming you want to multiply by the mask:
your_result = bsxfun(@times,data,mask);
Note that you can do operations other than multiplication. Please have a look at
doc bsxfun
4 件のコメント
その他の回答 (1 件)
Conrad
2013 年 2 月 11 日
Something like this:
fV = V.*M(:,:,ones(1,size(V,3)),ones(1,size(V,4)));
Conrad
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!