How would you create a mask on an image?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Feynman
am 5 Okt. 2013
Kommentiert: Image Analyst
am 5 Okt. 2013
I am doing a project and one of the tasks is to create a matrix with number of pixels x number of pixels x 3 as its size. In the previous task I created a matrix using the green container of the RGB image and I am suppose to duplicate this along the 3 dimensions. My question is what functions would I use in order to do this. I am not allowed to use any implicit functions only explicit.
6 Kommentare
Image Analyst
am 5 Okt. 2013
mark and redChannel have to be the same type of integer like it said. So you'd need to do
maskedRed = redChannel .* uint8(mask);
if redChannel is a uint8.
Akzeptierte Antwort
Image Analyst
am 5 Okt. 2013
Here's one method:
% Multiply the mask by each color channel individually.
maskedRed = redChannel .* mask;
maskedGreen = greenChannel .* mask;
maskedBlue = blueChannel .* mask;
% Recombine separate masked color channels into a single, true color RGB image.
maskedRgbImage = cat(3, maskedRed, maskedGreen, maskedBlue);
Here's another method, suggested by Sean D.
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!