MATLAB: How can i apply conditional dilation on the input image so that i can get the shown output image.

digital image processingdilationImage Processing Toolbox

Best Answer

I don't think the neckline/chest below the chin is important, especially because it will vary a lot depending on what kind of shirt the subject is wearing. Therefore I'd find just the head. To do that I'd scan only the bottom half of the image, where I assume the narrowest part of the neck will be, and find the line (row) in the image that has the greatest percentage of black in it, just looking at the black from 1 to the first white pixel and from the last white pixel to the end - use find() for that computation.
Then I'd draw a white line across at that line and fill just between the half way point and the line with imfill(). Let us know if you can't figure it out.