Copyright © Fred Weinhaus My scripts are available free of charge for noncommercial (nonprofit) use, ONLY. For use of my scripts in commercial (forprofit) environments or nonfree applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or forprofit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. 
Applies a laplacian filter to an image. 
last modified: December 15, 2018
USAGE: laplacian [f filter] [t thresh] [m mix] infile outfile
f ...... filter ... filter=1 to 5; default=1 PURPOSE: To apply a Laplacian filter to an image. DESCRIPTION: LAPLACIAN generates an output image which is a user defined mix or blend of the original image and a Laplacian convolution filtered version of the image. This is achieved by forming a single convolution kernel whose weights depend upon a mixing of the Laplacian coefficients and the identity kernel. The script applies one of three different 3x3 Laplacian filters to an image to extract or enhance the edges in the image. It is a type of high pass filter which is constructed from the sum of the x and y second derivatives. The basic blended high pass filtering formula is F = (1m)*I + m*L, where I is the original image, L is the Laplacian high pass filtered image and m = mix/100. When m=0, we get only the original image and when m=1, we get only the high pass Laplacian filtered image. For intermediate value of m, we get a blend of the image and the Laplacian high pass filtered image. Now, we can consider both I and L as a convolution of some kernel with the original image, namely I = i x I and L = l x I, where x means convolution. Note that a convolution is simply a weighted average of all the pixels in some neighborhood of a give pixel. Usually an odd sized neighborhood, such as 3x3, etc is used to prevent having the resulting image be shifted a fractional pixel. The convolution kernel values are simply the weights for the average. So here, i is the identity kernel, which is all zeroes, except the center of the kernel which has a value of 1. Similarly, l is one of the three Laplacian kernels. They are different forms of a high pass filter. Thus we can consider the final filtered image, F = f x I, where f = (1m)*i + m*l. Consequently, we only have to do one convolution using the convolution kernel, f. Note, that all pure high pass filter convolution kernels will have weights that sum to 0. Also note, that the filters are actually the negatives of the true laplacian filters so that when mixed with the image they produce sharpening rather than blurring. For example, applying Laplacian 3 is equivalent the identity kernel minus the 3x3 average convolution kernel. ARGUMENTS: f filter is the form of the filter. Three different 3x3 filters, one 5x5 filter and one 7x7 filters are provided in order of the increasing edge strength they produce. Values for filter are 1 to 5. The default is filter=1.
Laplacian 1 t thresh is the thresholding percentage used to create a binary Laplacian edge image. Values range from 0 to 100. A higher value will result in fewer edges in the resulting image. m mix is the percentage mixing factor used to blend the Laplacian with the original image. A value of mix=0, results in the original image. A value of mix=100 results in a pure Laplacian filtered image. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. 
Laplacian Of A True Color Image  
Original Image 
Laplacian 1 
Laplacian 2 
Laplacian 3 
Laplacian 4 
Laplacian 5 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
Laplacian Of A Grayscale Image  
Original Image 
Laplacian 1 
Laplacian 2 
Laplacian 3 
Laplacian 4 
Laplacian 5 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
Laplacian Of A Binary Image  
Original Image 
Laplacian 1 
Laplacian 2 
Laplacian 3 
Laplacian 4 
Laplacian 5 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
2D Kernel 
Laplacian Blending  
Original Image 
Arguments: 
Arguments: 
Arguments: 

Original Image 
Arguments: 
Arguments: 
Arguments: 

Laplacian Thresholding  
Original Image 
Arguments: 
Arguments: 

What the script does is as follows:
This is equivalent to the following IM commands for
