0

I am developing an application which aids users to paint effectively. I have a C# code which runs a matlab script and gets the edge detected black and white image of a reference image. Now, I have developed the code which can allow the user to paint over the image. My task is to guide the user to paint over this image. Essentially, when the user is painting, my task is to see that the painting over the black and white edge detected image does not cross the edges. I should be able to detect that when the paint stroke has crossed over an edge, it should be cut off at that edge.

I wish to find out how to store the edges' information and check if the user has hit an edge. If someone could provide some guidelines regarding the same, it would be really helpful.

Thanks

EDITED: I have uploaded one reference image and its edge detected image. The painting is done on the edge detected image.

enter image description here

Community
  • 1
  • 1
Bharath
  • 175
  • 2
  • 4
  • 14
  • It is hard to be certain what you mean by edges. Are edges "lines" defined in the image, or are they the edge of the image (like the image boarder). Also, an image might be helpful as well as a sample of the edge data you are receiving. – Trisped Jul 03 '12 at 22:20
  • Hi, edges are the lines defined in the image, Like the edges that are determined by operators like Sobel, Prewitt etc. I will update the question and add an image – Bharath Jul 03 '12 at 22:24

1 Answers1

3

Looks like something is wrong with your edge detector because it's generating a pair of lines for each edge.

Your goal check if the user has hit an edge implies that you need an absolute decision - EDGE or NO EDGE. But edge detection operators like Sobel give you an "edginess" value for each pixel in the range of [0, 255]. So you need more processing to make this absolute decision.

Simply thresholding the Sobel output is prone to noise. For example, if there was a small out-of-focus object in front of a sharp edge, it could make the edge very weak at that point.

Look into the Canny Edge Detector. Its hysteresis step helps connect edges that have weak spots. The output is a binary image - edge or no edge.

Once you have an edge image, you can flood-fill the background, separating the image into a set of disconnected foreground elements. Then use a Region labeling algorithm to give each foreground element a unique label. When the user begins painting, record which region they are inside, and then restrict painting to that region.

This process is highly dependent on the quality of the edge detected image. If the Canny detector fails to fully enclose a region with edges, it will fail spectacularly.

japreiss
  • 11,111
  • 2
  • 40
  • 77
  • Thanks for your reply. I am trying to find a method which can convert discontinued edge images to continuous ones. If you have any tutorial or a sample code, do let me know. Thanx – Bharath Jul 06 '12 at 22:10