How to create a Photoshop stroke effect?

I am looking for a way to programmatically recreate the following effect:

Enter the input image:
input http://www.shiny.co.il/shooshx/ConeCarv/q_input.png

I want to iteratively apply the impact effect.
The first step is as follows:
step 1 http://www.shiny.co.il/shooshx/ConeCarv/q_step1.png

Second step: alt text http://www.shiny.co.il/shooshx/ConeCarv/q_step2.png

And so on.

I assume this will be related to some kind of definition of boundaries, and then somehow tracks the edge.
Is there a known algorithm for this in an efficient and reliable way?

+2
graphics 2d effects
source share
1 answer

Basically, a custom algorithm, according to this thread :

Take the 3x3 neighborhood around the pixel, the alpha threshold, and then see if any of the eight pixels around the pixel have a different alpha value. If so, a circle of a given radius centered on a pixel. To do inside / outside, modulate the threshold alpha channel (negate to do the other side). You will have to spawn a large neighborhood if the radius of the circle is larger than a pixel (which probably is).


This is implemented using morphological operations on a gray scale. This is also the same method that is used to expand / contract. Basically, to stroke the center of the selection (or alpha channel), what would you do, first make two separate copies of the selection. The first choice will expand with the radius of the stroke, while the second will shrink. Then impact opacity would be obtained by subtracting the second choice from the first.

To perform internal and external strokes, you cut / halve the radius and subtract the parts that intersect with the original selection.

It should be noted that the most general morphological algorithm requires operations O (m * n), where m is the number of pixels in the image, and n is the number of elements in the "structuring element". However, for some special cases, this can be optimized for O (m) operations (for example, if the structuring element is a rectangle or diamond).

+5
source share

All Articles