How to get the intensity values (data stored) that is stored in the voxels (3D image) at the certain distances from the origin of the sphere?
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello, I have a 3D medical image with data values stored in its each voxel. I would like to pull out the data values of image at certain radial distances. The origin of my image is (0, 0, 0) and radius of the sphere is 20 mm. I would like to generate 19 concentric shells of equal thickness 1 mm (so total is 20 mm) in between center of sphere and its surface. At each concentric shell, I am interested to extract the value of the data stored in 3D image. How to write simple Matlab code for this situation? Has anyone done this before? Please provide me some ideas and suggestions, may be a little piece of code as well.
댓글 수: 3
Walter Roberson
2018년 9월 1일
It looks like the ElementSpacing has the relevant information about pixel sizes.
채택된 답변
Walter Roberson
2018년 9월 1일
filename = ...;
info = mha_readheader(filename);
V = mha_read_volume(info);
spx = info.ElementSpacing(1);
spy = info.ElementSpacing(2);
spz = info.ElementSpacing(3);
%careful, first dimension is y not x.
sx = size(V,2);
sy = size(V,1);
sz = size(V,3);
cx = sx/2; cy = sy/2; cz = sz/2;
xv = ((1:sx) - cx) * spx;
yv = ((1:sy) - cy) * spy;
zv = ((1:sz) - cz) * spz;
[X, Y, Z] = ndgrid(xv, yv, zv);
D = sqrt(X.^2 + Y.^2 + Z.^2);
rvals = 0 : 19;
rthick = 1;
Nr = length(rvals);
shells = cell(Nr, 2);
for ridx = 1 : Nr
r = rvals(ridx);
mask = (D >= r & D < r+thick);
shells{ridx, 2} = mask;
shells{ridx, 1} = V(mask);
end
Now the first column of the cell array shells contain the extracted data values, and the second column contains the mask of locations that were extracted (in case you need it later.)
댓글 수: 6
Walter Roberson
2018년 9월 2일
No, avgpixelvals is the mean for each concentric shell. shells is a cell array in which the first column contains only values that lie within the particular concentric sphere for that one radius.
추가 답변 (1개)
blues
2018년 9월 3일
댓글 수: 1
Walter Roberson
2018년 9월 3일
Your graph appears to show a y value peaking about 8.4*10^-8
Anyhow, you used the wrong numeric syntax
axis([0 120 5E-11 8E-8])
or
axis([0 120 5*10.^(-11) 8*10.^(-8)]);
With 5E-11 being only about 1/1600 of 8E-8, you should expect that MATLAB will probably round the lower bound to 0. After all, you would need your y resolution to be at least 1600 for it to make a 1 pixel difference.
참고 항목
카테고리
Help Center 및 File Exchange에서 Biomedical Imaging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!