如何在numpy/scipy中实现pixelmath

2024-06-01 14:12:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在读一本使用像素数学的书。在

问题是我该怎么做:

pmNewComputedImage("Ringing Paraboloid", 256,256,"(sqr(x)+sqr(y)) mod 256")

这将根据该等式返回256*256图像(sqr(x)+sqr(y)) mod 256。在

我不能做这个主意。我在纽比还是个新手。我只需要知道如何将行的平方加到列中,将其修改为256并返回一个新数组。在

编辑:

在像素数学中:

pixelmath

在numpy和matplotlib中:

numpy

谢谢。在


Tags: 图像numpymod编辑matplotlib数学像素数组
1条回答
网友
1楼 · 发布于 2024-06-01 14:12:10

试试这个:

x = np.arange(256).reshape(-1, 1)
y = np.arange(256)
rng_paraboloid = (x*x + y*y) % 256

import matplotlib.pyplot as plt
plt.imshow(rng_paraboloid, interpolation='nearest')

enter image description here

在numpy语言中,形状(256, 1)(256)broadcast的数组x和{}到一个共同的形状(256, 256)。在

相关问题 更多 >