applying mask on an image
Ältere Kommentare anzeigen
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?

Antworten (1)
Image Analyst
am 25 Sep. 2019
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;
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!