Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Detect and Fill part of an image

Detect and Fill part of an image

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestionvisual-studiogame-devdata-structures
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beko
    wrote on last edited by
    #1

    Hello, I want to implement something similar to map colouring (Not the famous problem but actually filling). Let us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info. At first, i thought i could get points (borders of a country), and use triangulation or polygon filling and define bounding rectangles or polygons (simple way, not using any tree implementation), but this approach needs lots of data generated by me. (using OpenGL) my question is, is it feasible to implement this with a picture, detecting boundaries (i saw threads about edge detection) automatically for each country name and store them for hit testing and use filling algorithms (flood vs.)? (I am a real beginner on Image Processing, Bitmap Handling, GDI etc.:)) How would you solve this? Thank you, Bekir Turkmen.

    C A N 3 Replies Last reply
    0
    • B beko

      Hello, I want to implement something similar to map colouring (Not the famous problem but actually filling). Let us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info. At first, i thought i could get points (borders of a country), and use triangulation or polygon filling and define bounding rectangles or polygons (simple way, not using any tree implementation), but this approach needs lots of data generated by me. (using OpenGL) my question is, is it feasible to implement this with a picture, detecting boundaries (i saw threads about edge detection) automatically for each country name and store them for hit testing and use filling algorithms (flood vs.)? (I am a real beginner on Image Processing, Bitmap Handling, GDI etc.:)) How would you solve this? Thank you, Bekir Turkmen.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      beko wrote:

      us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info.

      do you already know the boundaries of the countries ? if so, how are the boundaries stored ? Cleek | Image Toolkits | Thumbnail maker

      B 1 Reply Last reply
      0
      • C Chris Losinger

        beko wrote:

        us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info.

        do you already know the boundaries of the countries ? if so, how are the boundaries stored ? Cleek | Image Toolkits | Thumbnail maker

        B Offline
        B Offline
        beko
        wrote on last edited by
        #3

        i dont know the boundaries initially. However, i can find them manually and store them as point vectors for using input to Delaunay Triangulation (i have implemented one or two parts this way, without using any info from any picture) and display it with OpenGL. I do not need any information about boundaries actually other than hit testing, so i thought i could retrieve those boundaries(using edge detection algorithms) from the picture directly and display the picture as the view.(In data preparation stage, for example, when i click Canada, i will generate the boundary data and define it as Canada and write to a file (perhaps with some processing to reduce number of points) to read it later for hit testing.) Note that in the picture, boundaries are clearly given. Thanks. Bekir.

        1 Reply Last reply
        0
        • B beko

          Hello, I want to implement something similar to map colouring (Not the famous problem but actually filling). Let us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info. At first, i thought i could get points (borders of a country), and use triangulation or polygon filling and define bounding rectangles or polygons (simple way, not using any tree implementation), but this approach needs lots of data generated by me. (using OpenGL) my question is, is it feasible to implement this with a picture, detecting boundaries (i saw threads about edge detection) automatically for each country name and store them for hit testing and use filling algorithms (flood vs.)? (I am a real beginner on Image Processing, Bitmap Handling, GDI etc.:)) How would you solve this? Thank you, Bekir Turkmen.

          A Offline
          A Offline
          A A 0
          wrote on last edited by
          #4

          Way too little information to make a decent recommendation. If the area under the different regions have similiar features, look into doing some kind of connected component analysis.

          Quran Lectures (updated 1/3/06) "They are MUSLIM. It does not matter how you split it up: all msulims (so they say) see every other muslim as a brother, regardless of origin or nationality." -legalAlien. Alhamdullah for the blessing of Islam

          1 Reply Last reply
          0
          • B beko

            Hello, I want to implement something similar to map colouring (Not the famous problem but actually filling). Let us say, i have a picture of a continent, and i want to select a country and fill it with a colour and also in a list view, i want to highlight that country with some additional info. At first, i thought i could get points (borders of a country), and use triangulation or polygon filling and define bounding rectangles or polygons (simple way, not using any tree implementation), but this approach needs lots of data generated by me. (using OpenGL) my question is, is it feasible to implement this with a picture, detecting boundaries (i saw threads about edge detection) automatically for each country name and store them for hit testing and use filling algorithms (flood vs.)? (I am a real beginner on Image Processing, Bitmap Handling, GDI etc.:)) How would you solve this? Thank you, Bekir Turkmen.

            N Offline
            N Offline
            normanS
            wrote on last edited by
            #5

            I suggest brute-force and pig-ignorance. It's not pretty, but it always works for me! Assuming the map is static (because the countries / areas don't change) you could colour a bitmap image of the map offline, using some graphics package, so that all countries use different colours. If you use 24-bit colours, the difference could be in a single LSbit, which would un-noticeable. Then display the map as a bitmap image. When you click on a point, get the colour under the cursor, and match that to the country, in order to get country-specific information. To change the colour you could (using brute force) loop through all the pixels in a copy of your original bitmap, replacing all pixels of the matching colour with a new colour, then display the updated bitmap.

            B 1 Reply Last reply
            0
            • N normanS

              I suggest brute-force and pig-ignorance. It's not pretty, but it always works for me! Assuming the map is static (because the countries / areas don't change) you could colour a bitmap image of the map offline, using some graphics package, so that all countries use different colours. If you use 24-bit colours, the difference could be in a single LSbit, which would un-noticeable. Then display the map as a bitmap image. When you click on a point, get the colour under the cursor, and match that to the country, in order to get country-specific information. To change the colour you could (using brute force) loop through all the pixels in a copy of your original bitmap, replacing all pixels of the matching colour with a new colour, then display the updated bitmap.

              B Offline
              B Offline
              beko
              wrote on last edited by
              #6

              Thanks for the suggestion, I think that is quite practical, i will try to implement the way you suggested. Thanks to all replies. Bekir.

              N 1 Reply Last reply
              0
              • B beko

                Thanks for the suggestion, I think that is quite practical, i will try to implement the way you suggested. Thanks to all replies. Bekir.

                N Offline
                N Offline
                normanS
                wrote on last edited by
                #7

                Great! It's a lot easier to use the brute force approach and get the computer to work hard, rather than to have to learn how to implement complicated edge-detection algorithms. Of course, if the map changes frequently, my suggestion would not be useful.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups