How to create a mask on an image and have the background white?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Martha
el 6 de Sept. de 2014
Comentada: Image Analyst
el 14 de Ag. de 2017
Hi, I create a mask into an image and I did this:
i=roipoly(f1,p1,p2);
mask=repmat(i,[1,1,3]);
f1(~mask)=1;
imshow(f1)
and it work very well but my problem is that I want to have the background white instead of black. How can I create a mask into an image, leaving a region of interest as it is (image) and all the rest as color white?
I appreciate some suggestions. Martha
0 comentarios
Respuesta aceptada
Image Analyst
el 6 de Sept. de 2014
If f1 is a uint8 RGB image, you can set
f1(~mask) = 255;
See attached masking demo, attached below this image it creates:
5 comentarios
Image Analyst
el 14 de Ag. de 2017
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!