# Obtaining 3D matrix /image from voxel array with co-ordinates X,Y and Z with the intensity ?

조회 수: 1(최근 30일)
Jabir Mohamed Abdi 2021년 7월 27일
댓글: Jabir Mohamed Abdi 2021년 7월 28일
I have a voxel array of size 4089906 X 4 and I want to change it to 3D image/matrix and its size should be based on the co-ordinates X,Y and Z of the voxel array. In the diagram 1=X co-ordinate 2=Y co-ordinate 3=Z- co-ordinate and 4= Intensity. The ranges for the co-ordinates are X=[-550:1:300] Y= [-1350:1:-550] and Z= [2080:8:2120] 댓글을 달려면 로그인하십시오.

### 답변(1개)

Image Analyst 2021년 7월 28일
I know it's kind of obvious, but did you try a nested for loop?
x = squeeze(n(:, 1));
y = squeeze(n(:, 2));
z = squeeze(n(:, 3));
gl = squeeze(n(:, 4));
xMin = min(x);
xMax = max(x);
yMin = min(y);
yMax = max(y);
zMin = min(z);
zMax = max(z);
[rows, columns] = size(n)
outputRows = yMax - yMin;
outputCols = xMax - xMin;
outputSlices = zMax - zMin;
outputImage = zeros(outputRows, outputCols, outputSlices);
for k = 1 : rows
col = x(k) + xMin;
row = y(k) + yMin;
slice = z(k) + zMin;
outputImage(row, col, slice) = gl(k);
end
##### 댓글 수: 1표시숨기기 없음
Jabir Mohamed Abdi 2021년 7월 28일
I tried my version of nested loop but didnt work. Your way of the nested loop works and thank you for your assistance!.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!