1

(I have posted the same question in theoretical computer science forum but I doubt that it will get much attention because it is more practical rather than theoretical)

I am looking for an algorithm that would allow me to generate a line as if it was drawn by hand, given a sample line.

In other words, I have a line (a drawing) that I need to recreate several times, like a human would do if they traced the original drawing on tracing paper.

Naturally, a human would trace the drawing pretty closely to the original, but with minor errors. So I am wondering if algorithm exists that would distort the drawing so that the result looks like a traced original made by a person.

This is for a program that animates a drawing.

akonsu
  • 28,824
  • 33
  • 119
  • 194

2 Answers2

2

Hmm. That's an interesting problem. I don't know how realistic Perlin noise looks like,

but here the test case where I've included the brownian motion type of noise (e.g. when the perturbation from the straight line for a given point = sum of previous perturbations + gaussian random number with a zero center and a certain sigma :

different degree of wobbliness

The image shows from left to right the drawing as a function of sigma (decreasing from left to right)

Here is the code:

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')
sega_sai
  • 8,328
  • 1
  • 29
  • 38
  • Can you provide more details about the resolution you used, what the sigmas were, what the distance between the plot points was? – Adi Shavit Sep 17 '12 at 19:19
  • @sega_sai, thanks. I barely understand the terms here. as well as the previous comment. please point me to the resources where I can learn what this is about. – akonsu Sep 17 '12 at 19:25
1

One approach is to use Perlin Noise. You can find helpful links in the answer here: Perlin Noise for 1D?

Community
  • 1
  • 1
beaker
  • 16,331
  • 3
  • 32
  • 49