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