程序纹理算法的清晰度?

Clarity in Procedural Texture Algorithms?

在本页的大图部分 here 给出了 table 用于比较 3 个不同函数的不同组合。设左边的函数为 y = f(x) 那么函数 Average、Difference、Weighted Sum、4% Threshold 呢?我需要 y

的数学方程式

该页面上解释了所有内容:

Here are some simple, boring functions which, when repeatedly combined with smaller and smaller versions of themselves, create very interesting patterns. The table below shows you the basic source pattern (left), and combinations of that pattern with smaller versions of itself using various combination methods.

Average (1/n) - This is simply the average of all of the scales being used, 'n' is the total number of scales. So if there are 6 scales, each scale contributes about 16% (1/6th) of the final value.

Difference - This uses the difference between the color values of each scale as the final texture color.

Weighted Sum (1/2^n) - The weighted sum is very similar to the average, except the larger scales have more weight. As 'n' increases, the contribution of that scale is lessened. The smallest scales (highest value of n) have the least effect. This method is the most common and typically the most visually pleasing.

4% Threshold - This is a version of the Weighted Sum where anything below 48% gray is turned black, and anything above 52% gray is turned white.

让我们使用 Averagechecker 函数。您正在对许多重复的不同图像进行平均,在他们的示例中为 6 个,但在以下示例中为 3 个:

因此输出图像的每个像素都是其他图像像素值的平均值。您可以根据需要拥有任意数量的这些图像,并且它们始终以相同的方式构建:级别 n 的图像由 4 个图块组成,这些图块是级别 n-1 的图像缩放到四分之一它的大小。然后从所有这些图片中应用上述功能之一只得到一个。

现在清楚了吗?然而,通常很难给出定义每个图像的函数 f。然而,即使在伪代码和数学中有 n 个输入(xs)用于 1 个输出(y = f(x1, x2, ....xn)),“复合”函数也被定义:

  • 平均 (1/n) - 对于 n 级别,final_pixel[x][y] = sum for i from 1 to n of image_i[x][y]/n

  • 差异 - 对于 n 级别,final_pixel[x][y] = sum for i from 2 to n of to n of image_i[x][y] - image_i-1[x][y] -- 对此不完全确定。

  • 加权总和 (1/2^n) - 对于 n 级别,final_pixel[x][y] = sum for i from 1 to n of image_i[x][y]/(2**n)

  • 4% 阈值 - 对于 n 级别,

value = sum for i from 1 to n of image_i[x][y]/(2**n)
if value/max_value > .52 then final_pixel[x][y]=white 
else if value/max_value < .48 then final_pixel[x][y]=black;
else final_pixel[x][y]=value

其中 2**n 是 2 的 n 次方。