Prev: Position, TightInset and OuterPosition in a subplot
Next: Simulink + embedded matlab function + matrix indexing
From: Mitja on 24 Nov 2009 13:20 Hello! I have a problem with my project. Title is hair segmentation / detection. I don't know how to start doing it, seperate hair from picture (portreit ) with filters, so that at the end I can chance hair color. I would really appreciate your suggestions, support, sample or code.
From: ImageAnalyst on 24 Nov 2009 14:02 On Nov 24, 1:20 pm, "Mitja " <kastelic.mi...(a)gmail.com> wrote: > Hello! > > I have a problem with my project. Title is hair segmentation / detection. I don't know how to start doing it, seperate hair from picture (portreit ) with filters, so that at the end I can chance hair color. I would really appreciate your suggestions, support, > sample or code. ------------------------------------------------------------ It's not easy. It might seem so at first but once you get it working for one head, then another one comes along with a different haristyle that messes up your algorithm. But anyway, you'll have to use a variety of classification methods and need to combine them to see if some pixel is really hair or not. You might even have to look for what is not hair (e.g. flesh tones and background colors, if known) and use spatial information (e.g. background is expected to be connected to the edge of the photo while flesh tones are not connected to the border, and hair may or may not be connected to the border). You could look at color classification - but that could pick up pixels in the face or clothing or even background. You could look at texture. You could try region growing. And, like I said, look at position/location. You might look at other things too and list all the measurements in a "feature vector." Then train it by outlining known hair regions by hand and seeing what the feature vector looks like for the known hair regions. Then see how well your test regions match that (to within some tolerance).
From: Mitja on 24 Nov 2009 14:34 > It's not easy. It might seem so at first but once you get it working > for one head, then another one comes along with a different haristyle > that messes up your algorithm. But anyway, you'll have to use a > variety of classification methods and need to combine them to see if > some pixel is really hair or not. You might even have to look for > what is not hair (e.g. flesh tones and background colors, if known) > and use spatial information (e.g. background is expected to be > connected to the edge of the photo while flesh tones are not connected > to the border, and hair may or may not be connected to the border). > You could look at color classification - but that could pick up pixels > in the face or clothing or even background. You could look at > texture. You could try region growing. And, like I said, look at > position/location. You might look at other things too and list all > the measurements in a "feature vector." Then train it by outlining > known hair regions by hand and seeing what the feature vector looks > like for the known hair regions. Then see how well your test regions > match that (to within some tolerance). ----------------------------------------------------------------------------------------------------------------- Well I had an idea how to simplify a little bit. for the first time I would use homogeneously backgroung (blue or white color), so i could then "cut" it off, and even do the same whit skin tone! and than I "made" edges and from there I would like to separate hair. but i think i will have the biggest problems at the and with separation.
From: ImageAnalyst on 24 Nov 2009 16:37 On Nov 24, 2:34 pm, "Mitja " <kastelic.mi...(a)gmail.com> wrote: > Well I had an idea how to simplify a little bit. for the first time I would use homogeneously backgroung (blue or white color), so i could then "cut" it off, and even do the same whit skin tone! and than I "made" edges and from there I would like to separate hair. but i think i will have the biggest problems at the and with separation. - Hide quoted text - > ----------------------------------------------------------- Perhaps you'd like to see my image segmentation demo. If you're going to just use simple thresholding in this phase of your project, then the demo may help you. http://www.mathworks.com/matlabcentral/fileexchange/25157 You can just threshold each of the color planes and then combine them, something like redPlane = rgbImage(:,:,1); greenPlane = rgbImage(:,:,2); bluePlane = rgbImage(:,:,3); redBinary = redPlane > lowThresholdR & redPlane < highThresholdR; greenBinary = greenPlane > lowThresholdG & greenPlane < highThresholdG; blueBinary = bluePlane > lowThresholdB & bluePlane < highThresholdB; overallBinary = redBinary & greenBinary & blueBinary; Then just call bwlabel (or bwconncomp in R2009b), regionprops, and so on. Maybe you'd like to post an image somewhere (on a free image hosting web site), although I won't be answering any questions from tomorrow morning through Saturday night (but there are many other talented people here who could help you if you post an image and some code.) Regards, ImageAnalyst
From: Mitja on 3 Dec 2009 05:06
Hello! Well, I looked at the demo http://www.mathworks.com/matlabcentral/fileexchange/25157 and I find par of code that is interesting to me (!!!foregroud and backgroud!!!): % Threshold the image to get a binary image (only 0's and 1's) of class "logical." % Method #1: using im2bw() % normalizedThresholdValue = 0.4; % In range 0 to 1. % thresholdValue = normalizedThresholdValue * max(max(originalImage)); % Gray Levels. % binaryImage = im2bw(originalImage, normalizedThresholdValue); % One way to threshold to binary % Method #2: using a logical operation. thresholdValue = 100; binaryImage = originalImage > thresholdValue; % Bright objects will be the chosen if you use >. % binaryImage = originalImage < thresholdValue; % Dark objects will be the chosen if you use <. % Do a "hole fill" to get rid of any background pixels inside the blobs. binaryImage = imfill(binaryImage, 'holes'); I dont know yet how to implement this code to may project. I thought i could use a portret of some person on blue or white background. This would be initial picture. The plan would be next: 1. I would made face recognition 2. frequential mask 3. Color mask 4. fusion and markers placement (white for foregroung and black for background) 5. alpha matte estimated 6. hair segmentation. It was taken from that article: http://www-video.eecs.berkeley.edu/Proceedings/ICIP2008/pdfs/0002276.pdf if its posible I would do it in less steps if it's posible. |