tags:

views:

21

answers:

2

Is there any way using .net I can emulate the wand functionality found in your normal photo editor? I.e. user clicks on part of a photo and the application automatically selects the surrounding X pixels based on a given factor (usually tolerance threshold).

Any idea on how I could do this with .net? Thanks

+1  A: 

You'll have to do basic pixel manipulation to accomplish this. I would start by storing the color of the pixel they clicked, then instantiate a 2D array of ints that is the same dimensions as the image. Change the int that corresponds to the pixel they clicked on to a 1. At that point, you just have to use a pseudo-mapping algorithm to explode outwards, changing matching pixels to "1" in your array, and nonmatching pixels to "-1".

Eventually you'll have a minesweeper-esque 2D array with a heart of 1s, and edges of -1s, and then the uncheckable areas still at 0. The 1s then become the selected area

JustLoren
A: 

You want to do a flood fill using your tolerance threshold criteria to determine if a pixel should be included or not.

The details are a bit too much for a simple StackOverflow answer. As you can see from the Wikipedia article, there are many nuances just to the flood fill algorithm.

Mark Ransom