Skip to main content

3 posts tagged with "Image Processing"

View all tags

Installing ImageMagick (Ubuntu)

· One min read
wget https://download.imagemagick.org/ImageMagick/download/ImageMagick-7.0.11-14.tar.xz

Extract

tar xf ImageMagick-7.0.11-14.tar.xz

Make

sudo apt update
cd ImageMagick-7.0.11-14.tar.xz
./configure
make -j
sudo make install
sudo ldconfig /usr/local/lib

Denoising with a Gaussian Filter (Python / Scipy)

· One min read

As an example, let's use a 1[Hz] sine wave as the signal. Add noise generated from random numbers following a normal distribution with a mean of 0 and a standard deviation of 0.5 to the signal.

import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import gaussian_filter1d

t = np.arange(1000) / 100
s = np.sin(2*np.pi*t)
noise = np.random.normal(0, 0.5, size=len(t))
x = s + noise

plt.plot(t, x, label="+noise")
plt.plot(t, s, label="signal")
plt.legend(loc=1)
plt.show()

pyplot

Apply a Gaussian filter with a standard deviation of 5. The larger the standard deviation, the smoother the result, but the more it deviates from the original signal.

y = gaussian_filter1d(x, 5)
plt.plot(t, y, label="filtered")
plt.plot(t, s, label="signal")
plt.legend(loc=1)
plt.show()

pyplot