How I create a image mask?

31 views (last 30 days)
Samyak Raj Mehta
Samyak Raj Mehta on 29 Nov 2015
Commented: Image Analyst on 20 Oct 2017
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
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.
Samyak Raj Mehta
Samyak Raj Mehta on 2 Dec 2015
Edited: Samyak Raj Mehta on 2 Dec 2015
Thank's for your suggestion. I want to make mask, from this mask i'll cut different kind of face which are from faceGen Modeller. I need Edge of image are smooth.
I attached a sample face cut image.
Thank's...

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 29 Nov 2015
See my attached demo of imfreehand.
  3 Comments
W.Khan
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
Image Analyst on 20 Oct 2017
Put imfreehand in a loop.
Do the mask replacement on each color channel individually.

Sign in to comment.


Image Analyst
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
Samyak Raj Mehta
Samyak Raj Mehta on 2 Dec 2015
I have used photoshop to cut this face and 24 images are still there to shape up. So can you please provide me solution from that my work will reduce. Or other wise any way to make outline of this face., from that I use outline of that face as a mask and cut rest of images.
Image Analyst
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.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!