# Identifying the boundary points of a shape based on the centroid

I have a set of binary 2D images with objects in white and their boundaries in black (attached example). I also have a list of centroids (x,y coordinate pairs) identifying all objects.

For each object, I am trying to identify all the x,y coordinates of that object's boundary (black pixels). Anyone have an idea on programming logic that can help achieve this?

I apologize in advance if this post belongs in another section. If anything is unclear I can clarify. Thanks.

• ...why not select all the black pixels in the image? – A_A Feb 25 at 7:56
• So I can identify all black pixels in the entire object. However, after doing that, I don't know how to figure out which black pixels out of all the black pixels in the image surround a particular white object -which can be identified by its centroid. – Vivek Feb 25 at 21:22
• Thanks. Is this homework by any chance? Nothing wrong with homework, just the "answer approach" will be slightly different. – A_A Feb 25 at 21:40
• It's for my research. The sample image I attached is an image taken from a microscope and the white objects are biological cells. I just didn't want to add confusion by giving the background info. – Vivek Feb 27 at 1:01
• Can I please ask if this was resolved? – A_A Jun 2 at 8:54

You can write this from first principles, or you can use skimage's label(). In fact, that function applies pixel connectivity slightly differently, by building regions up as it reads the image, creating a new one if it finds a disconnected pixel, so, you would not even need the centroids in that case.