Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
neighbors of superpixels obtained by watershed

Subject: neighbors of superpixels obtained by watershed

From: Xi

Date: 26 Oct, 2012 12:39:08

Message: 1 of 2

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?

Subject: neighbors of superpixels obtained by watershed

From: Steve Eddins

Date: 26 Oct, 2012 12:41:37

Message: 2 of 2

On 10/26/2012 8:39 AM, Xi wrote:
> 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?

Take a look at the indexing techniques described here:

http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/

--
Steve Eddins
http://blogs.mathworks.com/steve/

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us