开发者

.net photo select 'wand' functionality

开发者 https://www.devze.com 2023-01-09 21:59 出处:网络
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 pix开

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 pix开发者_如何学Goels based on a given factor (usually tolerance threshold).

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号