Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get all pixel coordinates of selection
#6
(09-28-2021, 10:28 PM)Ofnuts Wrote:
(09-28-2021, 12:17 PM)joho21 Wrote:
(09-28-2021, 04:02 AM)PixLab Wrote: I don't see where you want to go with "particular selection". You have multiple selection?
Or you want every coordinate of every single pixel?
What do you want to achieve by doing so?
Please give us a bigger "picture" about what you would really like to do.

Speaking about XY https://xyproblem.info/ Wink
(thanks to Ofnuts for that link)

Sure, I can give the bigger picture. I've got a map that will be used for a conflict-type game, hosted by a Discord bot. What I'd like to accomplish is for the different provinces of the said map to be automatically colored based on who owns them. Ie, if one person conquers province 8, province 8 will now be their color. I was looking at using PILLOW, which lets you color images, but only one pixel at a time. I'd have to get a list of all the pixels within the bounds of each province in order to change their color automatically. The difficult part is just getting a list of XY coordinates for the pixels within each province boundary. Doing it by hand is not preferable. I looked at the "color select" and just the plain old magic wand tool on GIMP to see, but it only gives me like the XY coordinates of the upper-left point of the selection.

To do this you create a mask of each province before the game starts. To change the color of a province, you use the mask to make a selection, and then bucket fill the selection. 

Another method is to have each province in a separate alpha-locked layer, and then you just bucket-fill the layer with the new color. This technique is also quite easy to implement outside of Gimp with ImageMagick compose for instance. You can even have images of the the provinces in al the colors, and build the map by selecting the province images  with the appropriate colors.
Okay... I've not used image manipulation code before, so I have no idea what any of that means. I'll certainly do some research into how to work with those things and see what I can come up with. It's a bit of a brand-new concept to me and I've heard it can be complicated to do image manipulation through just raw code. Thanks for the suggestions!
Reply


Messages In This Thread
RE: Get all pixel coordinates of selection - by joho21 - 09-29-2021, 02:24 AM

Forum Jump: