필터 지우기
필터 지우기

find mean of 2d slice in 3d segmented volume

조회 수: 2 (최근 30일)
Raheema Al Karim Damani
Raheema Al Karim Damani 2020년 2월 9일
댓글: Raheema Al Karim Damani 2020년 2월 9일
I have a 3d variable with slices containing segmented rois (128x128x10) . I am trying to find the mean value for each slice in such a way that it does not average the zero pixels around the roi. i want a 1 x 10 array containing the mean value for each slice.
  댓글 수: 2
Turlough Hughes
Turlough Hughes 2020년 2월 9일
How did you get your roi?
Raheema Al Karim Damani
Raheema Al Karim Damani 2020년 2월 9일
I used roi poly. and then I masked the original image onto the binary segment

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

채택된 답변

Image Analyst
Image Analyst 2020년 2월 9일
Try this:
[rows, columns, slices] = size(image3d);
% image3d is your masked gray level image with some zeros in it.
sliceMeans = zeros(1, slices);
for slice = 1 : slices
% Get this slice
thisSlice = image3d(:, :, slice);
% Find out what pixels are nonzero
nonZeroIndexes = thisSlice ~= 0;
% Compute the means of only non-zero pixels.
sliceMeans(slice) = mean(thisSlice(nonZeroIndexes))
end

추가 답변 (1개)

Turlough Hughes
Turlough Hughes 2020년 2월 9일
편집: Turlough Hughes 2020년 2월 9일
Ok I think I know what you want. Looking at the documentation for roipoly, I assume you got a binary image representing the region of interest, lets call that BW. Let's also say your images are in the variable, V, which is 128 by 128 by 10. To determine the mean value of each slice for the ROI only, you could do the following:
[indRows,indCols] = find(BW); % where BW is the binary image representing your roi.
result = mean(V(indRows,indCols,:),[1 2]);
So the idea here is to find row and column indices for your ROI (I'm also assuming it is the same roi for each slice). Once you know your indices you its simply a case of plugging the values into the mean function.
  댓글 수: 2
Turlough Hughes
Turlough Hughes 2020년 2월 9일
You may also want to reshape the result;
result = reshape(result,1,10)
Raheema Al Karim Damani
Raheema Al Karim Damani 2020년 2월 9일
Thank you for your response! It is actually diff rois for each slice, hence diff dimensions.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by