Python Forum
How to extract (x,y) coordinates of the boundary of a .tif image?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to extract (x,y) coordinates of the boundary of a .tif image?
#14
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:
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.
Reply


Messages In This Thread
RE: How to extract (x,y) coordinates of the boundary of a .tif image? - by merlem - Feb-09-2017, 05:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get the image's coordinates not the canvas' when navigate on an image hobbyist 9 1,946 Jul-21-2022, 03:29 PM
Last Post: deanhystad
  Crop Image to Bounding Box Coordinates sallyjc81 2 5,185 Jul-23-2020, 08:46 AM
Last Post: sallyjc81
  periodic boundary contions grknkilicaslan 1 1,969 Jul-18-2020, 10:16 PM
Last Post: Gribouillis
  How to extract temperature value of pixels of a thermal image recorded by IR camera hamacvan 1 14,583 Jan-13-2019, 06:06 PM
Last Post: Larz60+
  How to extract digits in table of image using python SuSeegio 3 3,163 Dec-05-2018, 10:47 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020