applying mask on an image
조회 수: 52 (최근 30일)
이전 댓글 표시
Hello,
any help of how to write this code or how to start it?
Consider the “ctskull-256” image, apply a mask on it to only extract the
intensity above half of the peak intensity (that is, to set them to 1 and set
the pixel intensity below this level to 0). Compare the result with
FIGURE2.21(h) in your textbook, what do you find?

댓글 수: 0
답변 (1개)
Image Analyst
2019년 9월 25일
To create a mask like you said:
maxGL = max(grayImage(:))
mask = grayImage > maxGL/2;
To apply the mask to an RGB image, use this code:
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
If it's grayscale, you can do it simpler like this:
grayImage(~mask) = 0;
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!