Creating a blur effect with rinzelight.

After releasing rinzelight 0.0.3, I wondered how hard addinga blur effect would be. So I started implementing it.

We are going to do two 1D blur. In first place, open a repl and start emacs (or vim). Use rinzelight.image for reading northern-lights.jpg

First, let’s start creating a blur-kernel function with two parameters, width and sigma. Rinzelight lacks of a kernel-rank constant, so let’s add it. Open src/rinzelight/constants and add the following line to the end:

We get a horizontal kernel, which we will apply twice, one horizontally and one vertically. For getting a vertical kernel, we write one final function called transpose-horizontal-kernel:

And now, we are ready to write the blur effect:

And this is the result of a (blur (read-image "samples/northern-lights.jpg") 5 1.5 repeat-op rendering-quality):

(blur img 5 1.5 repeat-op rendering-quality)
(blur img 5 1.5 repeat-op rendering-quality)

And that's it!

Introducing rinzelight 0.0.2

I started writing rinzelight long time ago. Exactly, I started on February. Sadly, since I wasn’t getting a few points about Clojure, I stopped working on it twenty days after for half a year.

But do not let me digress. Rinzelight is finally released! Actually, rinzelight 0.0.2 is released! But let me introduce you to rinzelight.

Opening an image.

Just use rinzelight.image namespace. Then, just provide read-image of a filepath or an InputStream. Just like this:

A hash?

Yes. Four fields: image, format, width and height.

It’s an image. Let me see it!

Command your repl to display-image.

What about saving it?

The correct spell is write-image. Just give it an image and an uri.

I want to change an image’s nature.

If you want to, you can. Just look for namespaces under rinzelight.effects. Lookup tables and affine transforms are already available. There are even map-image and map-pixel-location functions. If you want to use map-pixel-location, take a look at rinzelight.effects.helper-functions for a helping hand.

What about a few examples?

I hide them under examples. They are a bit obfuscated using criterium for benchmarking, but they are not hard to understand. For running them, use lein run. They’ll take a bit, since I use them as benchmarks.