1
$\begingroup$

I am working on a task of segmenting small artifacts from a set of images like below:Few samples

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:

  1. Any algorithm you know which will solve the problem?
  2. 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.
$\endgroup$
  • $\begingroup$ See morphological operations. It should be good for this task selecting a good element structuring element. $\endgroup$ – Darleison Rodrigues Apr 23 '16 at 22:18
2
$\begingroup$

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<std::vector<Point> > contours;
    std::vector<Vec4i> 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 < 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 < 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: enter image description here

$\endgroup$
0
$\begingroup$

Assumptions

All your images are binary, i.e. the background is of a certain value (0) and the data is of a certain value (1). There is no noise in your images.

The artifact that you would like to get rid of is those small lines that are attached to some crossing points.

When you say ...the percentage of in these artifacts will be very less compared to the whole image... you mean that the artifact lines are much shorter than the image lines. Much shorter is quantifiable by you, e.g. by a statement like "The artifact lines are 5% of the length of the other lines in the image".

Proposed ansatz for an solution

  1. Detect the corners in your images, e.g. by an corner detection algorithm, or by a morphological image processing algorithm (if you have a fixed and known set of possible angles).

  2. Save the corner information in a second array (or however you like), and erase the corner pixels from your original image. This leaves all the lines disjunct.

  3. Label all the lines with an integer number.

  4. Calculate a histogram of these numbers, which is essentially the line length of each labeled line.

  5. Apply your artifact percentage criterion on the histogram values and discard the lines that fall below it by setting the corresponding lines to the background value.

  6. Get the saved corner pixels back in your image and remove the labeling information.

I hope that helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.