Home > Krita, Open Source > Faster "Gaussian" Blur and Pyramidal Sharpening

Faster "Gaussian" Blur and Pyramidal Sharpening

I have still trouble to feel at ease with KDE4 development, and fill the need to develop against a stable environment, so from time to time I do go back to Krita 1.6 and play with it and fill again my energy bar which I can then spend on Krita2. So last week I did wrote two filters (and I am still working on two others).

Faster Gaussian Blur

Bluring has always been one of the slowest operation in Krita (especially compared to what competitors do), mostly because of my laziness and, also, because for some reason the convolution code in Krita refused to work with non-square kernel (for absolutely no good reason). So, when I wrote the filter, I wrote it as a one pass filter, with one huge kernel, which means that for a bluring of 10 pixels radius, Krita was making 441 memory access and mathematical operations, while with a two pass blur filter, only 42 memory access and mathematical operations are needed, thus reducing the cost by a factor of ten, and the needed computation time as well.

But still we can do better, in fact, I have noticed that the second pass is twice as slow as the first one, which is probably due to fact that the convolution code is optimized for working with scanning line horizontally, while the second pass scan lines vertically.

Pyramidal Sharpening

The pictures made by most of camera isn’t always of the best quality, and they especially often lack of sharpness. It can happen for various reasons, ranging from bad lens, to bad sensors or to bad focus. So, one of the basic feature in picture editing is to increase the sharpness of an image. There are quiet a few techniques for doing this, until recently Krita only included what I call the “classical sharp” (it’s the simplest way of sharpening, it’s a convolution mask, very similar to bluring) and “unsharp mask” (the wikipedia entry describes it better than I will ever be able to). I have started playing with an article which proposed to use a pyramid representation of an image to increase its sharpness.

While the “classical sharp” is clearly the worse of all, it’s quiet unclear to determine which of the other two algorithms give the best results, and it also might depends of the parameters used for each one.

Advertisements
  1. Ants Aasma
    23 May, 2007 at 08:00

    Regarding sharpening, have you seen the SIGGRAPH 2006 paper about < HREF="http://people.csail.mit.edu/fergus/research/deblur.html" REL="nofollow">removing camera shake<>?

  2. Pooh22
    23 May, 2007 at 10:03

    Is something wrong with the second (pyramidal sharpening png) image?I clicked on it in akregator and gwenview showed the picture for about 1/5th while downloading and then blanked out… (using kde 3.5.7 on feisty)

  3. Cyrille Berger
    23 May, 2007 at 19:25

    @pooh22 : I have no idea, I am still using kde 3.5.6 and have no problem.@ants aasma : the problem of this paper is that is panted and they limit it to non-commercial use (which makes it impossible to ship in most distributions, so until Krita gets an easy way to install new plugins, it’s unlikely I will invest much time on it), and as they admit it on their website it’s not yet fully functionnal

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: