Segmentation of small artifacts - Image Processing I am working on a task of segmenting small artifacts from a set of images like below:

I am looking for a generic approach, but unsure of what to search?

I tried looking at density flow analysis, but don't know if that fit in.

I am unable to come up with a single pattern in all the images. For example I look out for "loops", but few images have loop plus more lines, like in (d) above.

One property I am certain about, the percentage of in these artifacts will be very less compared to the whole image.

Can you help me with:


Any algorithm you know which will solve the problem?
Any research paper, where a similar problem is solved. It is okay if that is not the topic of research paper, as this kind of work is usually present in per-processing stages.
If this is really what your input looks like then you should be able to handle this with the standard morphological image processing operations.

Assuming foreground as white and background as black, it basically comes down to a morphological open with a big enough structure element to elide the tails. The only trouble is that doing so will not work given that the input has holes so large the lines in the body of the shape itself would also get nuked by the open operation. One way to handle this is to perform the open on the figure without holes and then put the holes back in.

For example, in C++ using OpenCV:

void Test()
{

    Mat src_bw;
    cv::threshold(
        imread("some_file.png", CV_LOAD_IMAGE_GRAYSCALE), 
        src_bw, 0, 255, 
        CV_THRESH_BINARY | CV_THRESH_OTSU
    );

    imshow("src_bw", src_bw);

    // perform contour extraction using RETR_CCOMP i.e. we are assuming input doesn't have nested islands/holes just simple holes.
    std::vector&lt;std::vector&lt;Point&gt; &gt; contours;
    std::vector&lt;Vec4i&gt; hierarchy;
    findContours(src_bw.clone(), contours, hierarchy, RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));

    // iterate over the contours, draw the top-level contours into "blobs"
    Mat blobs = Mat::zeros(src_bw.size(), CV_8U);
    for (int i = 0; i &lt; contours.size(); i++)
        if (hierarchy[i][3] == -1) 
            drawContours(blobs, contours, i, 255, CV_FILLED, 8, hierarchy, 0, Point());

    imshow("blobs", blobs);

    // do an 'open' on blobs which will remove the artifacts.
    auto shape = MORPH_ELLIPSE;
    Mat strel = getStructuringElement(MORPH_ELLIPSE, Size(5,5));
    Mat blobs_opened;
    morphologyEx(blobs, blobs_opened, MORPH_OPEN, strel);
    imshow("blobs_opened", blobs_opened);

    // draw the holes back into the output
    Mat output = blobs_opened.clone();
    for (int i = 0; i &lt; contours.size(); i++)
        if (hierarchy[i][3] != -1) {
            drawContours(output, contours, i, 0, CV_FILLED, 8, hierarchy, 0, Point());
        }

    imshow("output", output);
}


yielding the following: