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. Visual Basic
  4. A series of points(coordinates)which form a shape [modified]

A series of points(coordinates)which form a shape [modified]

Scheduled Pinned Locked Moved Visual Basic
questioncsharphelp
8 Posts 2 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.
  • S Offline
    S Offline
    szevy_suez
    wrote on last edited by
    #1

    Hi, How do I get the coordinates of a series of points which form a shape in an image? Is there a way to do this? What image format will be easier for this task? By the way, I need to do this in vb.net. Hope someone can help. -- modified at 8:55 Monday 7th August, 2006

    D 1 Reply Last reply
    0
    • S szevy_suez

      Hi, How do I get the coordinates of a series of points which form a shape in an image? Is there a way to do this? What image format will be easier for this task? By the way, I need to do this in vb.net. Hope someone can help. -- modified at 8:55 Monday 7th August, 2006

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Are you saying that you're trying to recognize a shape in an image?? The image format really wouldn't make that much of a difference. Machine "vision" is still very much a research topic in Uni.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Are you saying that you're trying to recognize a shape in an image?? The image format really wouldn't make that much of a difference. Machine "vision" is still very much a research topic in Uni.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        S Offline
        S Offline
        szevy_suez
        wrote on last edited by
        #3

        Yup...that's what I want to do. I need the series of x and y coordinates to drive something like an x-y plotter. What I'm doing now is to get the color of image's pixel(1,1) and use the maketransparent method for this color so that the background will be transparent. I assumed that this will result in the onli pixels which are not transparent are the outline of the shape since I had applied canny edge detection to the image. Then, I will check each pixel, if pixel(x,y) is NOT transparent(which is supposed to be the shape) then the x and y values will be stored. But somehow, even pixel(1,1) is not transparent when I test the code. Did I made mistake somewhere? This is my code : Dim x As Integer Dim y As Integer Dim pic as Bitmap=Image.FromFile("C:\Program Files\Inkscape\staredge.bmp") Dim xmax As Integer=pic.Width-1 Dim ymax As Integer=pic.Height-1 try pic.MakeTransparent(pic.GetPixel(1, 1)) Catch MsgBox("failed") end try Do While x <= xmax y = 0 Do While y <= ymax Dim c As System.Drawing.Color = pic.GetPixel(x, y) If c = System.Drawing.Color.Transparent Then wait2send("Untitled - Notepad", "none{ENTER}", 0) Else wait2send("Untitled - Notepad", "yes{ENTER}",0) End If y += 1 Loop x += 1 Loop I used the try and catch method to test whether the maketransparent method worked. The MsgBox("failed") did not appear, so it should worked. But I couldn't figure out what is the problem. Can you please advise?

        D 1 Reply Last reply
        0
        • S szevy_suez

          Yup...that's what I want to do. I need the series of x and y coordinates to drive something like an x-y plotter. What I'm doing now is to get the color of image's pixel(1,1) and use the maketransparent method for this color so that the background will be transparent. I assumed that this will result in the onli pixels which are not transparent are the outline of the shape since I had applied canny edge detection to the image. Then, I will check each pixel, if pixel(x,y) is NOT transparent(which is supposed to be the shape) then the x and y values will be stored. But somehow, even pixel(1,1) is not transparent when I test the code. Did I made mistake somewhere? This is my code : Dim x As Integer Dim y As Integer Dim pic as Bitmap=Image.FromFile("C:\Program Files\Inkscape\staredge.bmp") Dim xmax As Integer=pic.Width-1 Dim ymax As Integer=pic.Height-1 try pic.MakeTransparent(pic.GetPixel(1, 1)) Catch MsgBox("failed") end try Do While x <= xmax y = 0 Do While y <= ymax Dim c As System.Drawing.Color = pic.GetPixel(x, y) If c = System.Drawing.Color.Transparent Then wait2send("Untitled - Notepad", "none{ENTER}", 0) Else wait2send("Untitled - Notepad", "yes{ENTER}",0) End If y += 1 Loop x += 1 Loop I used the try and catch method to test whether the maketransparent method worked. The MsgBox("failed") did not appear, so it should worked. But I couldn't figure out what is the problem. Can you please advise?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Color.Transparent isn't what you think it is when GetPixel is used. AFAIK, GetPixel NEVER returns transparent pixels! You'd be better off finding the pixels that are closer to the color that you're looking for.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Color.Transparent isn't what you think it is when GetPixel is used. AFAIK, GetPixel NEVER returns transparent pixels! You'd be better off finding the pixels that are closer to the color that you're looking for.

            Dave Kreskowiak Microsoft MVP - Visual Basic

            S Offline
            S Offline
            szevy_suez
            wrote on last edited by
            #5

            Can I ask u a question? If the image was converted to grayscale and then canny edge detection was applied to it, does that mean the final image contains only two types of colors?

            D 1 Reply Last reply
            0
            • S szevy_suez

              Can I ask u a question? If the image was converted to grayscale and then canny edge detection was applied to it, does that mean the final image contains only two types of colors?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              szevy_suez wrote:

              does that mean the final image contains only two types of colors?

              Uhhh, Light Gray and Dark Gray?? What are you talking about?

              Dave Kreskowiak Microsoft MVP - Visual Basic

              S 1 Reply Last reply
              0
              • D Dave Kreskowiak

                szevy_suez wrote:

                does that mean the final image contains only two types of colors?

                Uhhh, Light Gray and Dark Gray?? What are you talking about?

                Dave Kreskowiak Microsoft MVP - Visual Basic

                S Offline
                S Offline
                szevy_suez
                wrote on last edited by
                #7

                Since I want to recognise a shape in an image, I need to know what color the shape's pixels contain, so I can check each pixel's color to identify whether the pixel belongs to the shape. However, I am not sure about the exact color. Do you know how to change an image to a 2bit black and white image? That shud make that easier rite? Currently, I was only able to change the image to grayscale image and then apply edge detection to it, to get the outline of the shape, since what I want is only the x and y coordinates of the outline. Then, since you said GetPixel don't really return transparent color, what I thought was to get the color of GetPixel(1,1) which usually belongs to the background of the image and get all the x and y coordinates of pixels which do not have the same color as Pixel(1,1). But of course this could not be done if the image consist of more than two colors. Will an image after grayscale conversion and edge detection application contain more than TWO colors? However, if I can convert the image to a 2 bit black n white image, it would be better. Please advise.

                D 1 Reply Last reply
                0
                • S szevy_suez

                  Since I want to recognise a shape in an image, I need to know what color the shape's pixels contain, so I can check each pixel's color to identify whether the pixel belongs to the shape. However, I am not sure about the exact color. Do you know how to change an image to a 2bit black and white image? That shud make that easier rite? Currently, I was only able to change the image to grayscale image and then apply edge detection to it, to get the outline of the shape, since what I want is only the x and y coordinates of the outline. Then, since you said GetPixel don't really return transparent color, what I thought was to get the color of GetPixel(1,1) which usually belongs to the background of the image and get all the x and y coordinates of pixels which do not have the same color as Pixel(1,1). But of course this could not be done if the image consist of more than two colors. Will an image after grayscale conversion and edge detection application contain more than TWO colors? However, if I can convert the image to a 2 bit black n white image, it would be better. Please advise.

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  szevy_suez wrote:

                  Will an image after grayscale conversion and edge detection application contain more than TWO colors?

                  Yes. It'll be made up of various shades of gray. In a photograph, upwards of 65,000 shades... Image processing is not my field. Search the articles for "Image processing" and you'll find a great series of articles by Christian Graus on image manipulation.

                  Dave Kreskowiak Microsoft MVP - Visual Basic

                  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