Ask Your Question
0

How to isolate an arbitrary shape from noise?

asked 2017-07-01 10:45:41 -0600

I have a program that images a footprint as shown in the left most image. Though the print varies in size and aspect ratio, the general shape is as shown. However, due to noise, I sometimes get odd appendages as shown in the two images to the right.

Any ideas, just ideas not code, on how I might go about detecting the basic footprint and getting rid of the appendages?

thanksimage description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-02 04:58:38 -0600

KjMag gravatar image

updated 2017-07-02 05:00:17 -0600

Scan the object horizontally. Every time you spot continuous black pixels region (your contours are not one-pixel-wide), record coordinates of its pixels. After scanning each line check the number of regions you've found:

Possible cases

  1. If there is only 2 regions (marked blue in the image), you have no appendages.
  2. If you have 4 regions (marked red in the image), you've found and appendage. Remove the rightmost or leftmost pair based on distance between them - appendages you've shown are thinner than the actual footprint.
  3. If you have 3 regions, it means you have a case marked green, i.e. we are moving along the line that happens to be almost horizontal and connects the appendage with the footprint. In that case, remove the rightmost or leftmost region pixels based on the smallest distance between the regions.

After that, you should be left with images that look more or less that way:

image description

You can filter out the 'cutoffs' by segmenting image and comparing the number of pixels of two regions that you'll get. The rest (i.e. the protruding parts) you may handle with morphological opening using 'horizontal' kernel and then close the contour.

This solution should work assuming that the appendages you've shown are representative for what you may get. If the shapes are more diverse and/or may occur not only at the sides of the footprint, but also "under" or "over", the algorithm has to be modified.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-01 10:45:41 -0600

Seen: 508 times

Last updated: Jul 02 '17