Hi CV/Pattern Recognition Community,
I've got a serious problem regarding the segmentation of an image. The scenario is an atmosphere within a furnace which makes my head go insane. And I need to detect object contours of different materials (glass, ceramics, Al, Ir,..) in a short period of time (<10 seconds) and not just for one special case. I also need the contour in a sequential row of pixels for the code. Therefore a chain code or so called border/contour following is also needed, so open holes aren't good. In the background are non linear noises, approximately of dust, particles or somewhat else, that are appearing from time to time.
Matlab or OpenCV suggestions are welcome.
To make it more clear, I've posted another image of my goal and a half-transparent object, which needs also to be detected. Also further examples which need to be aware of.
As you can see in the Image #1, there are particles in the right part of the image and nearby the outer contour of the star, which is the object. Also the overall contrast is not very good. The object itself stands on an underground, which is not relevant for the contour detection. The image #2 shows a halftransparent object, which is also possible.
I want to find contour/perimeter of that object, like on the next screen (red line). The two rectangles (yellow) are marking the starting (left) and the ending point (right). The blue line is ignorable.
At first I thought that I could solve the problem of that filthy atmosphere with just filters. But after a honourable ammount of investing time, I just realized, that I have to elimate or reduce the noises significantly in order to increase contrast of foreground and background. I'd tried a lot of methods, like histogram equalization, Otsu-adaptive equalization, linear filters (e.g. gauss), nonlinear filters (median, diffusion), Active Contours, k-Means, Fuzzy-c-means and also Canny for pure Edge Detection in combination with morphological operators.
- Canny: The particles and the atmosphere are causing holes, but I need a complete contour of the object. Still with closing, dilatating of morphological operators it is not well enough. Canny has still the best results of all methods I've studied because of hysteresis.
- Active Contours: They work on edges/gradients as well, they act completely crazy after initializing inside the object, which maybe is caused by the edge map resulting the 'open' object. As far as I know the contour has to be closed. Tried it with different derivates (GVF/VFC/Classic Snake).
- k-Means: Results include the furnace atmosphere, because of foggy background. Same for fuzzy-c-means. I chose two clusters, because of separating the object from the background. More clusters lead to weaker results.
- Histogram/Otsu: Because of the very close gray intensities (imho!), it's merging the object with the background. Tried it with local and global methods.
- Filters: Especially GLPF or other LPF are smearing the edges, which is not so good and doesn't even reduce the foggy atmosphere.
- Non-Linear Filters are preserving the edges. Most of them take too long for calculating the large images. Took a fast bilateral filter for now. Results see below.
Therefore not a single method is good enough for post-processing steps, because the gained results of the object segment are poor competed to an existing algorithm. That existing algorithm is very local and therefore it works for this very special scenario.
So I am asking you, if I have missed something completely... I have no further idea how to process and how I should get good contour results, without having gaps or holes.. Is it possible without making a lot of changes on the CCD and the physical environment? Thanks in advance!
Last Approach so far (after a long night of experiments with MOs):
- Bilateral Filter (edge preserving, but smoothing homogenous areas)
- Canny (Sigma = 2, Threshold = [0.04 0.08])
- Morphological Operations (MO):
bwareopen
,closing
,remove
&bridge
bwlabel
for selecting only the perimeter of the contour, which removes unwanted noises. no updated screenshots yet, but it works for the star. the glass gots an inner-contour which is connected to the outter contour, which can also be seen on the screenshot below.
So I'm afraid that I need a special algorithm for the traversal of the outter contour. It will be some clockwise/counterclockwise lookup of neighbourhood. That clockwise/counterclockwise step can switch, if there is a corner point. if there is a gap, increase the radius and look again. if there are two or more possible following points, take the one who got the same direction as the previous. Do you think, that contour following algorithm makes sense?