applying mask on an image
Mostrar comentarios más antiguos
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?

Respuestas (1)
Image Analyst
el 25 de Sept. de 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;
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!