How to get XYZ coordinates of all non-zero voxels in a 3D volume?

조회 수: 5 (최근 30일)
I have an NxMxP matrix that forms a volume. Programs like ImageJ have a function to save the XY coordinates of any pixels above a certain threshold, is there a good way to implement this in 3D in matlab?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 18일
Try something like this
M = randi([0 5], 20, 30, 10); % example matrix
idx = find(M); % find nonzero values in M
[y,x,z] = ind2sub(size(M), idx);
y is the row number, x is column number, and z is the 3D slice number of non-zero entries.

추가 답변 (1개)

Rik
Rik 2020년 5월 18일
If you want to hide a bit of the implementation that Ameer showed you: I have extended the capabilities of find to more dimensions. You can find my findND function here on the FEX.
M = randi(255, 20, 30, 10); % example matrix
[y,x,z] = findND(M>100);

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by