- Sep 10, 2001
- 11,711
- 8
- 81
Hi fellas,
I really need a 2d GFX guru to advise me on how to accomplish something which I don't know even how to approach yet.
I want to develop a cool map based tool that needs to read a map image and separate distinct regions out of it so that I may easily do hit testing and filling on them. And this would be the key map to identify regions while another real map of the same location is what would be displayed. This is totally for personal hobby - not for work, not for profit.
My map image input would look something like this (basic example):
It contains a number of solid, unique colored continuous regions. This means all pixels for one region are connected to eachother and they are all exactly the same RGB value. There would be no other region with the same RGB value.
I want to scan this image in C# and be able to create I guess a Region object to represent each separate region of the map.
So perhaps after processing I'd end up with:
Which just illustrates that the program has detected 8 separate regions, labeled A-H. And the black lines represent the borders it detected between those regions.
Then once I have separate objects representing each region I can display a real looking map image on a GUI represented by the same area as the key map above but instead of simple, solid colored regions it is now a detailed map of greens of trees and such with no discernible regions. But since I have the region objects from the input image I can draw the borders on top of this map and even overlay the regions on top of this map by filling their area with some color.
So lets say the key map was for the counties of a state. Each county represented by a unique color. I scan this with some algorithm to detect the borders and create Region objects for each one.
Then the GUI displays a real satellite looking map of my state, and using the region data by reading the key map it can draw the borders between the counties on top of this map. Obviously both maps have exactly the same dimensions and match exactly in scale and everything. Then maybe when the user mouses over a county on the real map I will know which county they are on since I'd know it's Region and it's boundaries from the key map - and display pertinent info. And maybe they click a button which highlights all counties with population over 100,000 for example. Since I'd have Region objects I can easily Fill them with some overlay color.
Anyway - my problem is I have absolutely no idea how to do an algorithm to scan that key map and create the separate regions.
I would like something that is a little bit "loose", as in it does not build a giant path of points going pixel by pixel for the borders around the region, but sort of smooths it out like how I drew those lines in the second image above. This way each region is represented by much fewer points to save memory. And also I may need to do this for several thousand unique regions, so this algorithm's gotta be pretty quick so the user doesnt sit there for 5 minutes while this processes.
*ANY* advise on doing this would mean a lot to me... a link to an algorithm, a book, a tutorial - anything you may be familiar with or can suggest or whatever info I would greatly appreciate.Maybe even suggest another forum specific to gfx programming that may have more experts willing to lend some advice.
Thanks and happy new year!
I really need a 2d GFX guru to advise me on how to accomplish something which I don't know even how to approach yet.
I want to develop a cool map based tool that needs to read a map image and separate distinct regions out of it so that I may easily do hit testing and filling on them. And this would be the key map to identify regions while another real map of the same location is what would be displayed. This is totally for personal hobby - not for work, not for profit.
My map image input would look something like this (basic example):
It contains a number of solid, unique colored continuous regions. This means all pixels for one region are connected to eachother and they are all exactly the same RGB value. There would be no other region with the same RGB value.
I want to scan this image in C# and be able to create I guess a Region object to represent each separate region of the map.
So perhaps after processing I'd end up with:
Which just illustrates that the program has detected 8 separate regions, labeled A-H. And the black lines represent the borders it detected between those regions.
Then once I have separate objects representing each region I can display a real looking map image on a GUI represented by the same area as the key map above but instead of simple, solid colored regions it is now a detailed map of greens of trees and such with no discernible regions. But since I have the region objects from the input image I can draw the borders on top of this map and even overlay the regions on top of this map by filling their area with some color.
So lets say the key map was for the counties of a state. Each county represented by a unique color. I scan this with some algorithm to detect the borders and create Region objects for each one.
Then the GUI displays a real satellite looking map of my state, and using the region data by reading the key map it can draw the borders between the counties on top of this map. Obviously both maps have exactly the same dimensions and match exactly in scale and everything. Then maybe when the user mouses over a county on the real map I will know which county they are on since I'd know it's Region and it's boundaries from the key map - and display pertinent info. And maybe they click a button which highlights all counties with population over 100,000 for example. Since I'd have Region objects I can easily Fill them with some overlay color.
Anyway - my problem is I have absolutely no idea how to do an algorithm to scan that key map and create the separate regions.
I would like something that is a little bit "loose", as in it does not build a giant path of points going pixel by pixel for the borders around the region, but sort of smooths it out like how I drew those lines in the second image above. This way each region is represented by much fewer points to save memory. And also I may need to do this for several thousand unique regions, so this algorithm's gotta be pretty quick so the user doesnt sit there for 5 minutes while this processes.
*ANY* advise on doing this would mean a lot to me... a link to an algorithm, a book, a tutorial - anything you may be familiar with or can suggest or whatever info I would greatly appreciate.Maybe even suggest another forum specific to gfx programming that may have more experts willing to lend some advice.
Thanks and happy new year!
Last edited: