Results 1 to 8 of 8

Thread: Creating a path from the center points of a selection?

  1. #1
    Guild Journeyer eepjr24's Avatar
    Join Date
    Nov 2020
    Location
    East Coast, USA
    Posts
    150

    Default Creating a path from the center points of a selection?

    If I have a selection, for simplicity sake we'll start with a 50 pixel wide line at a 45 degree angle from top left to bottom right (see below), how do I create a path that traverses the approximate center of the selection and is one pixel wide?

    45_degree_line.JPG

    I know how to create a selection, shrink a selection, create a path from a selection. But simply shrinking will either end you up with gaps in the path or with areas that are wider than a pixel in the path. I am fine if this is something I need to do programatically if someone can point me in the right direction or the terminology to look for to execute this type of operation. I am no great mathematician, but I can muddle through most geometry and basic trig. And I am fine with putting in time to experiment as necessary.

    - Ernie

  2. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Default

    Is this in any particular application or do you have the coordinates of the line or selection shape ? Is the starting point a set of numerical coordinates or an image which contains something like the line in it ? And if your selection was square then when you traverses, in which direction should it go ? Would it be across the smallest dimension for example.

    I would suggest at first glance by looking into OpenCV. You can use that with a number of different programming languages such as python.
    Last edited by Redrobes; 11-14-2020 at 08:22 AM.

  3. #3
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,610

    Default

    What you need is called a morphological skeletonize operation or medial axis transform. It's a common operation in image processing. There are many libraries that can perform this task, but some sort of context in which you perform the operation would be useful.

  4. #4
    Guild Journeyer eepjr24's Avatar
    Join Date
    Nov 2020
    Location
    East Coast, USA
    Posts
    150

    Default

    Quote Originally Posted by waldronate View Post
    What you need is called a morphological skeletonize operation or medial axis transform. It's a common operation in image processing. There are many libraries that can perform this task, but some sort of context in which you perform the operation would be useful.
    Trying to automate some tasks for map making. So say I have a set of roads laid out on a layer. Having a path that followed the center of the road would allow me to perform multiple strokes on the road to lay down color, texture, pot holes or whatever else I would like. So in the end I would like to be able to call this from scripts, but from what I have seen so far most anything you can do from the UI you can do from the pdb. I have been pointed to AutoTrace and a plug in to use it, I am probably going to try that next unless someone has nifty other ideas. =)

    Thanks for the responses.

    - E

  5. #5
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,610

    Default

    If you're looking to find the centerline of roads and then apply styles to that, you're most likely better off marking them manually because you are unlikely to need to do a huge number of roads (a couple of hundred, at most). That's especially true if you are trying to do this in the context of an existing tool like Photoshop or the GIMP. If you get a good workflow going, you can probably start from the centerlines next time.
    Skeletonizing existing images (or selections) is a very error-prone operation that tends to generate a large number of spurious side branches. Simplifying the skeleton is very likely to be more work that it's worth.
    Are you doing your own mapping program?

  6. #6
    Guild Journeyer eepjr24's Avatar
    Join Date
    Nov 2020
    Location
    East Coast, USA
    Posts
    150

    Default

    Quote Originally Posted by waldronate View Post
    If you're looking to find the centerline of roads and then apply styles to that, you're most likely better off marking them manually because you are unlikely to need to do a huge number of roads (a couple of hundred, at most). That's especially true if you are trying to do this in the context of an existing tool like Photoshop or the GIMP. If you get a good workflow going, you can probably start from the centerlines next time.
    Skeletonizing existing images (or selections) is a very error-prone operation that tends to generate a large number of spurious side branches. Simplifying the skeleton is very likely to be more work that it's worth.
    Are you doing your own mapping program?
    Marking them manually is pretty much what I am trying to avoid. I think I would rather just start out with paths for roads than go that route.

    No, I am just using the GIMP currently. Looking to make creating ad hoc content trivial for minor encounters, stop over points, etc. And ideally also create fast starting points for larger towns and such as well. If skeletonizing is too complex then I'll look at starting with paths, do you have any suggestions or know of tutorials or the like for generating quasi random paths, say in a mosaic or other warpable pattern set?

  7. #7
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,610

    Default

    Not in the context of the GIMP, no. A common and reasonably effective way to generate content is to start with a Voronoi tessellation of random set of points that's given a few rounds of Lloyd's algorithm to regularize things. Adjusting the original distribution can do interesting things. See Amit Patel's Red Blob Games or Oleg Dolya's Watabou thingies for examples.

  8. #8
    Professional Artist Tiana's Avatar
    Join Date
    Oct 2009
    Location
    Winnipeg, Manitoba, Canada!
    Posts
    1,825

    Default

    I have a program on my Mac, SuperVectorizer2, which will let you generate skeletonized vector lines from an artwork that would fit that description. It is a Mac only program though.

    Click my banner, behold my art! Fantasy maps for Dungeons and Dragons, RPGS, novels.
    No obligation, free quotes. I also make custom PC / NPC / monster tokens.
    Contact me: calthyechild@gmail.com or _ti_ (Discord) to discuss a map!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •