How would you create a mask on an image?
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 5 Oct 2013
Modifié(e) : Image Analyst
le 5 Oct 2013
Define implicit and explicit. Which are cat(), repmat(), bsxfun(), and class()? Walter and I used those in our Answers below. Are you allowed to use them?
Feynman
le 5 Oct 2013
Image Analyst
le 5 Oct 2013
That will get you a logical mask, m1, from which you can use it as the mask in my code below to mask out pixels brighter than the user specified value. You can set the values in any of the color channels to anything you want, e.g. 0 or 255, or anything else.
redChannel(m1) = 0; % Mask inside to %255 or whatever.
or
redChannel(~m1) = 0; % Mask outside.
Feynman
le 5 Oct 2013
Image Analyst
le 5 Oct 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.
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 5 Oct 2013
0 votes
repmat() or cat(3,X,X,X)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!