필터 지우기
필터 지우기

Masked image displaying wrong intensity

조회 수: 4 (최근 30일)
Fotaras Sitof
Fotaras Sitof 2017년 9월 21일
댓글: Fotaras Sitof 2017년 9월 21일
Hey guys,
I have a 3D image: [256x256x160] and a mask: [256x256x160]. The mask is a binary image of 0 and 255. After applying the mask on the image:
if true
% masked_image = image.*mask;
end
I get a masked_image that has totally wrong intensity values. In fact, its values are nowhere to be found on the original image. They are just too big. All I want to achieve is extract the original image's intensities at the location of the mask and calculate the mean value of that ROI. I can see from 'imshow' that the mask is aligned properly on the image. However, applying the mask is unsuccessful and I don't understand why.
Many thanks for your help.

채택된 답변

OCDER
OCDER 2017년 9월 21일
편집: OCDER 2017년 9월 21일
Try this instead, which will select only the pixels in image dictated by the mask:
%to get the masked image without changing the dimension of the image
masked_image = image.*(mask > 0);
%or if you want just the pixels
masked_image_pixels = image(mask > 0);
Note that mask should really be a logical array, not a uint8 array, which is what (mask > 0) is taking care of for you.
In your original code, the issue is that you are using a uint8 mask matrix to multiply element-by-element with the image matrix. This means doing the following:
image .* mask
(value from the image matrix) x (255 or 0 from the "binary" uint8 mask matrix)
which would explain the large numbers.
  댓글 수: 1
Fotaras Sitof
Fotaras Sitof 2017년 9월 21일
Thanks for the clarification. It makes sense now. After the mask was converted to 0 and 1 rather than 0 and 255 the extracted ROIs have proper values.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by