Finding maximum axial slice location from 3D binary label

2 ビュー (過去 30 日間)
banikr
banikr 2020 年 4 月 17 日
コメント済み: darova 2020 年 4 月 17 日
Hello,
I want to find the maximum axial slice location/number/position of a 3D binary mask.
which means the slice location where the binary mask ends.
  2 件のコメント
darova
darova 2020 年 4 月 17 日
What about min and max?
banikr
banikr 2020 年 4 月 17 日
編集済み: banikr 2020 年 4 月 17 日
could you describe or specify how to use min max in this case?
The data size is 172, 220, 156.
I can write a for loop and including sum() option. But I wonder if there are simple matlab code for that.

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

回答 (1 件)

darova
darova 2020 年 4 月 17 日
  • Use find to find all values
  • Use ind2sub to convert indices to i,j,k (x,y,z)
ix = find(V(:)); % find nonzero values
[i1,i2,i3] = ind2sub(size(V),ix); % convert to i,j,k
[~,imax1] = max(i1); % max i
[~,imax2] = max(i2); % max j
[~,imax3] = max(i3); % max k
plot3(i1(imax1),i2(imax1),i3(imax1),'.r')
  2 件のコメント
banikr
banikr 2020 年 4 月 17 日
Hey @darova,
I think I have got what I was looking for.
[~,imax3] = min(i3);
This actually gives the final slices as matlab starts counting from bottom.
I was available to crop the bottom slice location.
Thanks!!
darova
darova 2020 年 4 月 17 日

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

Community Treasure Hunt

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

Start Hunting!

Translated by