Find nearest seed index given geodesic distance of a binary image

2 views (last 30 days)
Given a binary image, BW, and a vector of seed locations, ind
D = bwdistgeodesic(BW,ind) computes the geodesic distance of each pixel in BW to the nearest seed.
How can one find a matrix I, same size as BW, which gives the index of the nearest seed for each pixel? For example, if there are 5 seeds, each pixel in I should have a value (1,2,3,4 or 5) depending on the nearest seed location based on the distance already found in D.
Cheers.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!