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

4

1 に答える 1

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.

于 2012-07-03T23:11:18.333 に答える