Maybe this can help you?
http://scikit-image.org/docs/dev/api/ski...d_contours
Edit: some 'quick and dirty' solution based on what they describe in scikit:
http://scikit-image.org/docs/dev/api/ski...d_contours
Edit: some 'quick and dirty' solution based on what they describe in scikit:
import PIL import PIL.Image ima = PIL.Image.open("Bild90.tif") imsize = ima.size boundary = [] for imapp in range(imsize[0] -1): for imapix in range(imsize[1] -1): pix1 = ima.getpixel((imapp, imapix)) pix2 = ima.getpixel((imapp, imapix +1)) pix3 = ima.getpixel((imapp + 1, imapix)) pix4 = ima.getpixel((imapp + 1, imapix +1)) if not (pix1 == pix2 == pix3 == pix4): boundary.append((imapp, imapix)) imac = ima.copy() imacopy = imac.convert("L") for pixel in boundary: imacopy.putpixel(pixel, 255) imacopy.show()If the boundary needs to be only one pixel wide, one has to refine it a bit further.