Multiple ROI within one slice median calculation

조회 수: 1 (최근 30일)
Fiona Gong
Fiona Gong 2019년 8월 23일
편집: Matt J 2019년 8월 23일
Hi all,
I have a mask file 192x192x10, within each slice there are multiple ROIs with mask = 1 and background = 0. I then use bsxfun to apply this mask to an image 192x192x17 with values between [0,1]. What I'm trying to calculate is the median value of each individual ROIs within each slice. Is there an easy way to calculate the median value of each individual ROIs?
Many thanks!
Fiona
  댓글 수: 2
xi
xi 2019년 8월 23일
편집: xi 2019년 8월 23일
There are multiple ROIs within each slice. So, you need to define the number of ROIs as well as the sub-masks for individual ROIs, in order to calculate whatever value of each ROI.
Otherwise, you will need to use some algorithms (such as clustering) to automatically detect connected regions as individual ROIs, for each given mask slice.
Fiona Gong
Fiona Gong 2019년 8월 23일
Hi thanks for swift reply, much appreciate! Could you give some more clues about how to define the submask and number of ROIs? They can be random so number could be different at each slice.

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

채택된 답변

Matt J
Matt J 2019년 8월 23일
편집: Matt J 2019년 8월 23일
I think this is what you want:
I=reshape(Image,[],17);
clear Medians
for i=1:10 %loop over masks
S=regionprops(mask(:,:,i),'PixelIdxList');
J=numel(S);
for j=J:-1:1 %loop over ROIs
Medians{i}(:,j)=median(I(S(j).PixelIdxList,:),1);
end
end

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by