Algorithm for determining if a pixel is within the border

We are currently creating a simple image processing application in Silverlight, and we hit a little. We want users to be able to select an area of ​​the image (either by drawing a free line around the selected area, or by creating a polygon around it), and then be able to apply effects to the pixels within this selection.

Creating a set of images is simple enough, but we need a very fast algorithm to determine which pixels to manipulate (i.e. something to determine which pixels are within the user's selection ).

We have been thinking about three possibilities so far, but we are sure that there must be a really effective and quick way to do this better than these.

1. Pixel by pixel. We simply look at each pixel in the image and check it within the user's choice. Obviously, this is too slow!

2. Using the line crossing algorithm. The type of thing is visible here .

3. Flood fill. Select the pixels along the selection path, and then fill the fill within that selection. This may work fine.

This should be a problem that is usually resolved, so we assume that there are many more solutions that we did not even think about.

What would you recommend?

+3
2

.

:

:

+4

. - Silverlight .

( , ), , (, ).

, . , - :)

+3

Source: https://habr.com/ru/post/1767158/


All Articles