I have several outlines that consist of several black areas in my image. Directly adjacent to these black regions are some brighter areas that do not belong to my contours. I want to add these bright areas to my black region and therefore expand my outline in OpenCv.
Is there a convenient way to expand the contour? I thought about looking at the change in intensity from my gradient image created with cv::Sobel and stretching until the gradient changes again, which means that the pixel intensity returns to neither black nor bright areas Images.
Thanks!
Here are sample images. The first image shows the raw image, the second shows the extracted outline using Canny and findContours, the last shows the Sobel-Gradient intensity image of the same area. I want to include bright borders in the first image in the outline.



Update: now I used some morphological operations on Sobelgradients and added a contour around them (see image below). The next step may be to find an adjacent pair of purple and red outlines, but it looks like a waste of procession time to actually look for straight adjacent outlines. Any better ideas?

Update 2: My solution for now is to look for the morphed (red) gradient outlines in the bounding box around my (purple) outlines and choose the one that has the correct orientation and size. This works for gradient contours, where the morphological operation closes the gradient areas of βriseβ and βfallβ, as in Figure 3. But this is still a poor solution for cases where the illuminated area is wider than in the image above. Any idea is still very much appreciated, thanks!
source share