mkfilter - returns popular 2D convolution kernels |
K = mkfilter(name) |
name |
a string, the name of the filter mask. May be 'sobel', 'prewitt', 'laplace1', laplace2', 'laplace3','sh1' (or 'sharp1'), 'sh2' (or 'sharp2'), 'low-pass', mean', 'circular', 'circular-mean'. In the future there will be more options. |
K |
a 2D array containing the convolution kernel. |
mkfilter builds well-known 2D filter "masks" (kernels), such as sobel, prewitt, mean, etc. to be used together with a function such as imconv. |
K = mkfilter('sobel') returns a 3x3 edge-finding and y-derivative approximation filter. To find vertical edges, use -K'. |
K = mkfilter('prewitt') returns another 3x3 edge-finding and y-derivative approximation filter. To find vertical edges, use -K'. |
K = mkfilter('laplace1') returns a 3x3 kernel which shows points of an image where intensity is varying quickly. The "laplacien" of an image is the two-dimensionnal second derivative. Because images are discrete (and not continuous), the "laplacien" can only be approximated. The 3 different kernels often used to estimate it are given by "laplace1", "laplace2" and "laplace3". These kernels can be used to detect edges of an image. |
K = mkfilter('sh1'): "sharp enhancer". Returns a 3x3 kernel which renforce high frequencies of the image: it accentuates the variations of a pixel compared to its neighbours. Problem: it enhances the noise too (it may be useful to denoise the image before). |
K = mkfilter('sh2') has the same effect than "sh1" but its coefficients are more powerfull. |
K = mkfilter('low-pass') : this is a low-pass filter. The goal is inverse of sharp enhancer filters - the image is smoothed. This kernel is only one of the possible kernels. |
K = mkfilter('mean') : this is another low-pass filter. The mean value of the central pixel and its neighbours is affected at the central pixel. |
K = mkfilter('circular',rad) is an euclidean circular mask with radius "rad" pixels, whose elements are all 1. |
K = mkfilter('circular-mean',rad) is a low pass filter, the same as 'circular', but the matrix K is divided by the number of 1-elements. |
initial_dir = PWD; chdir (SIPDIR + 'images'); Img = imread('tru.jpg'); Img = im2gray(Img); xbasc() imshow(Img); sob = mkfilter('sobel'); // stamp effect A = imconv(Img, sob); xbasc() imshow(A, []) chdir(initial_dir); |
The Matlab equivalent to mkfilter is "fspecial". |
"Processamento Digital de Imagens", O. M. Filho and H. V. Neto, Brasport -- Rio de Janeiro, pp. 47-56. |
"Algorithms for Image Processing and Computer Vision", J.R. Parker, Wiley, chapter 1. |
Ricardo Fabbri <rfabbri@if.sc.usp.br> Jocelyn Druel <jocelyn.druel1@libertysurf.fr> Leandro Estrozi <lfestrozi@if.sc.usp.br> |
The latest version of the Scilab Image Processing toolbox can be found at |
http://siptoolbox.sourceforge.net |
imconv, edge |