How I create a image mask?
31 views (last 30 days)
Show older comments
I want to cut a complete face image in fixed face, without ears. Like we doing in photoshop. I have to create a mask from that i'll cut existing face images.
2 Comments
Jan
on 29 Nov 2015
You forgot to explain any details. Do you want to determine the shape automatically or does the user define it with the mouse? Do you need a hard edge or some smoothing? Do you have the image processing toolbox?
In addition "provide me matlab code" is a command, not a polite question. This reduces the motivation to post an answer or provide a solution. So take the chance to edit the question, provide enough details to give us a chance to post a matching answer, and be polite.
Answers (2)
Image Analyst
on 29 Nov 2015
See my attached demo of imfreehand.
3 Comments
W.Khan
on 20 Oct 2017
Hello Image Analyst, I have two questions: for the selecting tool we can select only one object. What if I want to select more than one area. How to amend it?
Another question is: When I select the masked region, the mask is white (Masked white inside region). What if I want to fill this white area with some color, say blue, yellow etc? Please comment.
Thanks
Image Analyst
on 20 Oct 2017
Put imfreehand in a loop.
Do the mask replacement on each color channel individually.
Image Analyst
on 2 Dec 2015
For the face image, in your comment....
This image is already masked, so you must already have a mask, so I'm not sure what additional you need. If you don't have the mask, just take the max of the image and find zeros.
maxImage = max(rgbIMage, [], 3);
mask = maxImage ~= 0; % Inside of face, OR
mask = maxImage == 0; % Outside face - whichever you want.
2 Comments
Image Analyst
on 2 Dec 2015
Edited: Image Analyst
on 2 Dec 2015
How can I know how to do that when you have not given the original, pre-mask image and only supplied the post-mask image? What is outside the part you masked that made you decide not to include that in the mask?
Anyway, if you have only 24 images to mask, you might get it done faster in Photoshop than if you have to write and debug a MATLAB program.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!