gpt4 book ai didi

graphics - 如何制作Photoshop描边效果?

转载 作者:行者123 更新时间:2023-12-02 19:28:47 25 4
gpt4 key购买 nike

我正在寻找一种以编程方式重新创建以下效果的方法:

给出输入图像:
input http://www.shiny.co.il/shooshx/ConeCarv/q_input.png

我想迭代应用“描边”效果。
第一步如下所示:
step 1 http://www.shiny.co.il/shooshx/ConeCarv/q_step1.png

第二步是这样的:
alt text http://www.shiny.co.il/shooshx/ConeCarv/q_step2.png

等等。

我认为这将涉及某种边缘检测,然后以某种方式跟踪边缘。
是否有已知的算法可以有效且稳健地执行此操作?

最佳答案

基本上,自定义算法是,根据 this thread :

Take the 3x3 neighborhood around a pixel, threshold the alpha channel, and then see if any of the 8 pixels around the pixel has a different alpha value from it. If so paint acircle of a given radius with center at the pixel. To do inside/outside, modulate by the thresholded alpha channel (negate to do the other side). You'll have to threshold a larger neighborhood if the circle radius is larger than a pixel (which it probably is).


This is implemented using gray-scale morphological operations. This is also the same technique used to expand/contract selections. Basically, to stroke the center of a selection (or an alpha channel), what one would do is to first make two separate copies of the selection. The first selection would be expanded by the radius of the stroke, whereas the second would be contracted. The opacity of the stroke would then be obtained by subtracting the second selection from the first.

In order to do inside and outside strokes you would contract/expand by twice the radius and subtract the parts that intersect with the original selection.

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

关于graphics - 如何制作Photoshop描边效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/252709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com