You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于二维点坐标列表快速生成图像的Python实现方案问询

基于大量二维坐标点生成密度图的高效实现方案

我有一组由二维坐标(x, y)定义的点集,示例生成代码如下:

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(123)
x = 10*np.random.randn(2000)+32
y = 10*np.random.randn(2000)+32

我目前通过以下代码将这些点填充到二维数组生成图像:

im = np.zeros((64, 64))
dx = np.arange(64)
dy = np.arange(64)
for i in range(len(x)):
    xt, yt = x[i], y[i]
    ind_x = np.argmin((abs(dx-xt)))
    ind_y = np.argmin((abs(dy-yt)))
    im[ind_x, ind_y] += 1
    
plt.imshow(im)

现在需要针对以下两种场景,找到最快的Python实现方案:

  • 点数量极多的场景
  • 图像像素数量极多的场景

密度图示例

内容的提问来源于stack exchange,提问作者Pierre Vermot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 01:57:03