Dsco

Today I want to share with you the results of a tiny image processor which convolves ppm data with predefined kernels, here are the results with this image.

Gaussian Blur filter

$$ \frac{1}{16} \begin{bmatrix} 1 & 2 & 1 \newline 2 & 4 & 2 \newline 1 & 2 & 1 \end{bmatrix} $$

Sharpen Filter

$$ \begin{bmatrix} 0 & -1 & 0 \newline -1 & 5 & -1 \newline 0 & -1 & 0 \end{bmatrix} $$

Edge Filter

$$ \begin{bmatrix} -1 & -1 & -1 \newline -1 & 8 & -1 \newline -1 & -1 & -1 \end{bmatrix} $$

Code

Check out the repo here

Notes

The program only works with P6 ppm files, to convert its output to other formats I used ffmpeg, here is one example.

$ dsco -f edge original_image.ppm | ffmpeg -i - edge_converted_img.png

You can also use magick to get the input and pipe it to allow dsco to read different formats:

$ magick original_image.png PPM:- | dsco -f sharpen | magick - sharped_converted_img.png

However with magick I a decrease of image quality.