Removing the boundary after segmentation ?
Hey all, I am working on image segmentation. After using watershed, I get the result shown in the first image below where the black lines indicate the boundary between regions. The result I would like to get however, should look like the second image without any black pixels (boundaries).
Currently, the way I assign boundary pixels to a region is as follows
1. loop through the entire image to look for black pixels. if it is a black pixel (boundary) then,
2. check the pixels to the right, bottom, and diagonal (right-bottom)
3. set the value of the black pixel to one of the 3 neighbors mentioned in step 2.
Would this be efficient enough ? I was hoping if could share a more efficient algorithm if the one I wrote above is not good.
Did you try looping throw the image in the way you described? I'm not an expert in this kind of things, but i have seen a code like below in tutorials before and would say its a common method.
I hope i don't understand something wrong - if so feel free to remove this comment.
Actually it is black because of visualisation but in fact its a negative value as described in the documentation: In the function output, each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the regions. Indeed looping the image and replacing those with the best neighbor element is the way to go.