I have a 8-bit greyscale 16x16 image where I want to extract coherent shapes with a more or less consistent pixel arrangement if possible (like: a rectangle, staircase, line). Currently, I'm doing this in two simple steps:
- Find all pixels which have a value above a fixed threshold.
- Group all pixels which share at least one edge with another pixel (find coherent areas by checking if pixels are neighbours).
Here, you can see an example image with the shape segmentation I would like to have and the one I get with the thresholding algorithm:
The main problem is that there are sometimes small overlaps of different shapes, where my current algorithm will extract it as one shape (see third image). It could even be that there is an additional pixel which adjoins the red, the blue and the green shape, which would lead to having only one big shape extracted in this example image.
One solution I was thinking about was generating a convex hull around a found shape and try to split the shape if it contains a too high percentage of black (below-threshold) pixels, but I would need to find a way of where to split it. If possible, I would also like to get rid of thresholding and maybe use deformable image contours (snakes) or another gradient-based method. On the other hand, I want to keep the algorithm as simple/fast as possible as it is only a sub-step of a obstacle detection pipeline which runs at 90 Hz (the image represents a u-disparity which is a histogram of a disparity image).
Does anyone have a suggestion what I could try?