Exemplo n.º 1
0
def dft(img):
  height, width = img.shape[0], img.shape[1]
  f = img
  F = np.zeros((height, width, 1), np.float)

  for u, v in product(range(0, height), range(0, width)):
    for x, y in product(range(0, height), range(0, width)):
      F[u, v] += f[x, y] * e ** (2 * pi * (u * x / height + v * y / width)) * (-1) ** (x + y)

  return F
Exemplo n.º 2
0
def high_frequency_emphasis(shape, D0, k1, k2):
  height, width = shape
  H = np.zeros((height, width), np.float)

  for u, v in product(range(0, height), range(0, width)):
    Duv = ((u - height / 2) ** 2 + (v - width / 2) ** 2) ** 0.5
    H[u, v] = k1 + k2 * (1 - e ** (-1 * Duv ** 2 / (2 * D0 ** 2)))

  return H
Exemplo n.º 3
0
def butterworth_filter(shape, D0, n):
  height, width = shape
  A = 2 ** 0.5 - 1
  H = np.zeros((height, width), np.float)

  for u, v in product(range(0, height), range(0, width)):
    Duv = ((u - height / 2) ** 2 + (v - width / 2) ** 2) ** 0.5
    H[u, v] = 1 / (1 + A * (Duv / D0) ** (2 * n))

  return H