MATLAB: How to segment this metal bead correctly as shown in the attached images

Image Processing Toolboximage segmentationmetalweld

I tried to segment the bead on the joint of the metal in the image below, but the results seem to be not meaningful. I am interested in trying some other algorithms like random walker, level sets, and snake algorithms to do the segmentation. I have attached the combined real image and the expected results.

Best Answer

Try converting to grayscale and calling stdfilt(). Then threshold. Mask off the known locations of the white background to dark plate boundaries. Call imfill() on what's left, then call bwareafilt() and bwboundaries(). Let me know if you can't figure it out, and attach the test image alone as a PNG file.