33 views (last 30 days)

Matt J
on 25 Jul 2020 at 12:36

Edited: Matt J
on 25 Jul 2020 at 15:15

I know I need to use mat2cell and mean function.

I don't think you do. Let's call your 3D volume, V:

[ci,cj,ck]=deal(51,51,251); %center coordinate ?

[I,J,K]=ndgrid(abs((1:100)-ci),abs((1:100)-cj),abs((1:500)-ck));

L=max(max(I,J),K)+1; %label matrix

stats = regionprops3(L,V,'MeanIntensity','Volume');

cumVolumes = cumsum(stats.Volume);

cumIntensities = cumsum(stats.Volume.*stats.MeanIntensity);

result = cumIntensities ./cumVolumes

Matt J
on 2 Aug 2020 at 16:11

Something like this?

clear S

S(400)=struct('cumVolumes',[],'cumIntensities',[],'result',[]); %pre-allocate

for i = 1:400

[ci,cj,ck]=deal(51,51,50+i); %center coordinate

[I,J,K]= ndgrid(abs((1:100)-ci),abs((1:100)-cj),abs((i:100+i)-ck)); % Z remain 100 but changes with center

L = max(max(I,J),K)+1; %label matrix

stats = regionprops3(L,V(:,:[i:100+i]),'MeanIntensity','Volume');

S(i).cumVolumes = cumsum(stats.Volume);

S(i).cumIntensities = cumsum(stats.Volume.*stats.MeanIntensity);

S(i).result = cumIntensities ./cumVolumes

end

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.