Any way to retain the largest element in a 3D array - similar to bwareafilt?

9 ビュー (過去 30 日間)
PhD Problems
PhD Problems 2019 年 7 月 31 日
コメント済み: PhD Problems 2019 年 8 月 1 日
Hi,
I have this volume in 3D which is displayed using ``volshow``:
As can be seen there are some outlier voxels that are undesireable. Is there any way that I can only retain the largets element in the volume and ignore the rest? Similar to ``bwareafilt(img, 1)`` ?
I tried to use the new ``bwmorph3(vol, 'majority')`` and it did clean it up a bit, but still leave some voxels behind. (The above volshow is after the bwmorph3 majority operation).
Any way to accomplish this?
I'm currently using Matlab 2018b, but am happy to upgrade if any helpful 3D function was introduced later.
update:
I think regionprops3 is what will work for me, I tried regionprops3(vol, 'Volume') on the above image and got this returned
378
246
124
1
6
160
220
131
532
124
152
2038747
2
182
785
16101
216
13
76
8
78
150
126
48
I think the volume 2038747 relates to the largest object (at index 12).
How do I use this to retain only this volume?
Thanks
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 1 日
Can you share the code/representataion code of the volshow image, so that we can try on it?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 1 日
CC = bwconncomp(vol);
numPixels = cellfun(@numel,CC.PixelIdxList);
[~,idx] = max(numPixels);
filtered_vol = false(size(vol));
filtered_vol(CC.PixelIDXList{idx}) = true;
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 1 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 1 日
Great sir!
PhD Problems
PhD Problems 2019 年 8 月 1 日
Thank you, thats very helpful :)

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by