我编写了自己的perlin库,还使用了一个标准python库来生成噪声。下面是我的代码:
import sys
from noise import pnoise2, snoise2
perlin = np.empty((sizeOfImage,sizeOfImage),dtype=np.float32)
freq = 1024
for y in range(256):
for x in range(256):
perlin[y][x] = int(pnoise2(x / freq, y / freq, 4) * 32.0 + 128.0)
max = np.amax(perlin)
min = np.amin(perlin)
max += abs(min)
perlin += abs(min)
perlin /= max
perlin *= 255
img = Image.fromarray(perlin, 'L')
img.save('my.png')
dp(filename='my.png')
不管频率或倍频程如何,它总是看起来很粗糙。我的结论是我用错了,但我不知道为什么我的解决方案是错误的。我使用分数单位通过频率和迭代通过我的二维数组。我试过转换指标,但还是没有连续性。怎样才能得到平滑的柏林噪声?在
我认为有一些潜在的问题
int
max
和{abs(min)
例如:
相关问题 更多 >
编程相关推荐