【问题标题】:generating line distortion in images在图像中产生线条失真
【发布时间】:2023-03-08 08:40:01
【问题描述】:

(我已经在理论计算机科学论坛上发布了同样的问题,但我怀疑它会得到很多关注,因为它更实用而不是理论)

我正在寻找一种算法,它允许我生成一条线,就好像它是手工绘制的一样,给定一条示例线。

换句话说,我有一条线(一张图)需要重新创建几次,就像人类在描图纸上描摹原始图时所做的那样。

自然地,人类会非常接近原图,但会出现一些小错误。所以我想知道是否存在会扭曲绘图的算法,使结果看起来像一个人制作的追踪原件。

这是用于动画绘图的程序。

【问题讨论】:

    标签: algorithm image-processing graphics


    【解决方案1】:

    嗯。这是一个有趣的问题。我不知道 Perlin 噪声看起来有多逼真,

    但这里是我包含brownian motion 噪声类型的测试用例(例如 当给定点的直线扰动 = 先前扰动的总和 + 具有零中心和特定 sigma 的高斯随机数时:

    图像从左到右显示绘图作为 sigma 的函数(从左到右递减)

    代码如下:

    import numpy as np, numpy.random
    import matplotlib.pyplot as plt
    np.random.seed(1)
    N = 1000
    xs = np.arange(N)
    thi =  6
    sig =  0.00045
    def getrand():
            return np.cumsum(np.random.normal(0, sig, size=len(xs)))
            # returns the cumulative sum of the set of random 
            # normally distributed numbers
    plt.figure(1)
    plt.plot(xs, getrand() * N, linewidth=thi, color='black')
    plt.plot(xs, N + getrand() * N, linewidth=thi, color='black')
    plt.plot(N + getrand() * N, xs, linewidth=thi, color='black')
    plt.plot(getrand() * N, xs, linewidth=thi, color='black')
    

    【讨论】:

    • 您能否提供更多关于您使用的分辨率、sigma 是多少、绘图点之间的距离是多少的详细信息?
    • @sega_sai,谢谢。我几乎不明白这里的术语。以及之前的评论。请指出我可以了解这是什么的资源。
    【解决方案2】:

    一种方法是使用 Perlin Noise。您可以在此处的答案中找到有用的链接:Perlin Noise for 1D?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-24
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多