Laplacian Gaussian smoothing filter

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
rudyb
Posts: 3
Joined: 2014-01-27T11:37:34-07:00
Authentication code: 6789

Laplacian Gaussian smoothing filter

Post by rudyb »

I read few articles that Laplacian (second derivative in x + second derivative in y) is used to actually sharpen the images. Because when you apply a Laplacian kernel on an image, it essentially marks its intensities, and (after some rescinding), if you add the result of the filter to the original image it is as if that you are intensifying the pixels that have high intensities already, and it is very clear that why this technique actually used to sharpen the intensities.
(for example: http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm)

But one thing that I don't understand is that why this operation (Laplacian operation) in some other articles and some other parts of the literature is referred to as an smoothing filter. I don't see how Laplacian filter just by itself can be used as an smoothing tool ?!!
Isn't it used to sharpen the image even more rather than smoothing it? Isn't it that the effect of this filter is to highlight edges in an image? What is it when they talk about Laplacian smoothing filter?

Thanks,
--Rudy
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Laplacian Gaussian smoothing filter

Post by fmw42 »

I do not know why the Laplacian should be called a smoothing operator or tool? It is basically a high pass filter (edge detector), but if added back to the image, it produces a sharpening effect. See
http://www.imagemagick.org/Usage/convolve/#laplacian

On the other hand, the Gaussian is a low pass filter and as such causes smoothing or blurring of the image.

For a mathematical discussion of Laplacian and Gaussian filters (actually high and low pass convolution filters) using IM commands, see
http://www.fmwconcepts.com/imagemagick/ ... tering.pdf

Perhaps you have the two confused or are considering them equivalent.

A combination of the Laplacian and Gaussian is used to make a pyramid processing operation for multi-resolution techniques such as low pass, band pass and high pass combinations. See
https://en.wikipedia.org/wiki/Pyramid_( ... rocessing)
http://www.cs.toronto.edu/~kyros/course ... 13s.09.pdf
http://cs.haifa.ac.il/hagit/courses/ip/ ... eRepx4.pdf

There is also a Laplacian of a Gaussian filter (and also a Difference of Gaussians) that is a more generalized form of a mixed lowpass and highpass filter, such that the right combinations go from one to the other and inbetween as bandpass filters. See
http://www.imagemagick.org/Usage/convolve/#log
http://www.imagemagick.org/Usage/convolve/#dog


Do you have a reference where it says it is a "smoothing" operator? If so, please provide so we can see the contect in which it is called that.
rudyb
Posts: 3
Joined: 2014-01-27T11:37:34-07:00
Authentication code: 6789

Re: Laplacian Gaussian smoothing filter

Post by rudyb »

Thanks for all the examples and explanations. I believe after reading your post and looking through the examples, it makes sense why they refer to laplacian to sometimes as "sharpening" and other times as "smoothing". Cause they are technically the same operation, but one uses the negative of Laplacian. So, if we ADD the high-pass information to the image, that actually has sharpening effect. On the contrary, if we SUBTRACT the high frequency data from the image, and is left with only low-passed (smooth/blur) portion of the image.

As an example, page 20 of the following article, touches on this topuc: http://www.fmwconcepts.com/imagemagick/ ... tering.pdf
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Laplacian Gaussian smoothing filter

Post by fmw42 »

On the contrary, if we SUBTRACT the high frequency data from the image, and is left with only low-passed (smooth/blur) portion of the image.
In principle that is mathematically true. Image - LowPassImage = HighPassImage. Therefore, mathematically, Image - HighPassImage = LowPassIimage. However, in practice, one has to do that very carefully. The former part works well, since the Gaussian Low Pass has no negative values. But the latter part does not work so well, especially when, as in non-hdri IM, one has only one sided edges (they are clipped at zero, so one never sees the negative values).

In the Fourier Transform Domain, the low pass filter is indeed the negative of the high pass filter and vice versa. See http://www.fmwconcepts.com/imagemagick/ ... l#blurring
http://www.fmwconcepts.com/imagemagick/ ... _detection

The negative of a Laplacian filter is still a high pass filter. It does not do smoothing. Contrary to what I put in my reference above. Negating the laplacian does not cause smoothing. I will have to fix that reference, since it is not stated well. The proper statement comes below.

Consider the following examples (for which I have intensified the Laplacian too much so that it is really visible. You can try a smaller value than 1000% for a less saturated sharpening):

Input: Lena
Image

Proper Laplacian filter

Code: Select all

lap1="3x3: -1 -1 -1 -1 8 -1 -1 -1 -1"
Negated (wrong sign) Laplacian filter

Code: Select all

lap1n="3x3: 1 1 1 1 -8 1 1 1 1"
Proper Laplacian applied to image as high pass filter -- shows one-sided edges (due to IM clipping at zero):

Code: Select all

convert lena.png -define convolve:scale='!1000%' -morphology convolve "$lap1" lena_lap1.png
Image

Wrong sign Laplacian applied to image as high pass filter -- shows opposite polarity edges:

Code: Select all

convert lena.png -define convolve:scale='!1000%' -morphology convolve "$lap1n" lena_lap1n.png
Image

So you see above that neither cause smoothing.


Proper Laplacian filter added to identify filter and applied to the image - causes sharpening:

Code: Select all

convert lena.png -define convolve:scale='!1000%,100%' -morphology convolve "$lap1" lena_lap1b.png
Image

Wrong sign Laplacian filter added to identify filter and applied to the image - causes strange looking sharpening:

Code: Select all

convert lena.png -define convolve:scale='!1000%,100%' -morphology convolve "$lap1n" lena_lap1nb.png
Image

The wrong sign laplacian sharpening above does not look natural! That is why one needs the correct sign.



Applying Proper Laplacian to image and adding the original back (produces "brighter" sharpening):

Code: Select all

convert lena.png \
\( -clone 0 -define convolve:scale='!1000%' -morphology convolve "$lap1" \) \
-compose plus -composite lena_lap1c.png
Image

Applying Proper Laplacian to image and negating, then adding the original back:

Code: Select all

convert lena.png \
\( -clone 0 -define convolve:scale='!1000%' -morphology convolve "$lap1" -negate \) \
-compose plus -composite lena_lap1cn.png
Image


Applying Proper Laplacian to image and subtracting from original (produces "darkening" sharpening):

Code: Select all

convert lena.png \
\( -clone 0 -define convolve:scale='!1000%' -morphology convolve "$lap1" \) \
+swap -compose minus -composite -write show: lena_lap1cs.png
Image

None of the above cause smoothing, since her shoulder is always sharp !


For reference, here is a gaussian blurred image.

Code: Select all

convert lena.png -gaussian-blur 0x1.5 -write show: lena_gblur.png
Image

And here is the blurred Gaussian result subtracted from the image to produce high pass filtered edges:

Code: Select all

convert lena.png \
\( -clone 0 -gaussian-blur 0x1.5 \) \
+swap -compose minus -composite -evaluate multiply 10 -write show: lena_image_gblur.png
Image

Note that the Laplacian is a second derivative operator. Any derivative, first (directional or gradient) or second (laplacian) will look for large transitions in grayscale in the image and set flat regions to zero. See the diagram at http://mipav.cit.nih.gov/pubwiki/index. ... _Laplacian

I still would like to see a reference to where you say someone else says the simple Laplacian (not Laplacian-Gausssian combinations or Laplacian of a Gaussian) is a smoothing filter.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Laplacian Gaussian smoothing filter

Post by fmw42 »

I did find a Laplacian Smoothing definition from Wikepedia at https://en.wikipedia.org/wiki/Laplacian_smoothing. But that is a mesh smoothing technique. The laplacian operator is used as part of a diffusion technique. I do not think that has anything to do with the classical image Laplacian filter that is a high pass filter and thus sharpens or edge detects. A Google search finds other similar articles that describe mesh smoothing.
Post Reply