|
Hi,
I am trying to use superpixel in image segmentation based on markov random field.
I apply watershed on a 2D image to obtain superpixels of the image. The resulting image has the same size with the input image where each pixel value in the resulting image shows the membership of the superpixel.
However it is not trivial to get the "neighbors" of the superpixel. I am thinking using the following method but found it is really inefficient
For each supervoxel A where value = a:
Initialize neighbors of A as N_A = [];
Find the edge index EI (the edge is zeros adjacent to supervoxel A
For each zero pixel j in EI
Obtain the neighbor N of EI
For each n in neighbor N_EI
include all pixel value that is != a or is not included before
end
end
end
There are three loops here which is really inefficient especially if the image is 3D.
Any suggestions on a better method?
|