Project Title: Spatial Domain Image Processing
Project Title: Spatial Domain Image Processing
Abstract Principle objective of Spatial Domain Image Processing is to process an image so that result is sharper than original image for specific application. Spatial Domain Image Processing techniques provide a multitude of choices for improving the visual quality of images. This project will provide an overview of underlying concepts, along with algorithms and programs commonly used for spatial filtering. The project focuses on techniques for image enhancement using various filters such as image enhancement using the laplacian filter and high-boost filtering.
Technical description Special Filtering: Spatial filtering is one of the principal tools used in this filter for a broad filtering is one of the principal tools for broad spectrum of applications. Filtering creates a new pixel with coordinates equal to the coordinates of the center of the neighborhood, and whose value is the result of the filtering operation. Filtering creates a new pixel with coordinates
equal to the coordinates equal to the coordinates of the neighborhood, and whose value is the result of the filtering option. If the operation performed on the image pixels is linear, then the filter is called linear spatial filter otherwise it is called non-linear spatial filter. Assuming w is a filter of matrix with 3x3 neighborhoods. At any point (x,y) in the image, the response g(x,y), of the filter is the sum of products of the filter coefficients and the image pixels encompassed by g(x,y)= w(-1,-1)f(x-1,y-1)+w(-1,0)f(x-1,y)+..+w(0,0)f(x,y)+.+w(1,1)f(x+1,y+1) In general
Algorithm spatial filter step 1: read the input image. step 2: convert the input image to double data type. step 3: enter the details of the filter step 4: create the padded matrix filled with zeros and with extra two rows and columns step 5: store the values of the input image in the padded matrix, by taking starting pixel of the image coordinates as (2,2) step 6: traverse the array and apply the filter (using the equation discussed above)in order to get the sum of all pixels step 7: the above output is the filtered image Enhancement Using the Laplacian The approach basically consists of defining a discrete formulation of the secondorder derivative and then constructing a filter mask based on that formulation. The
simplest isotropic derivative operator is the laplacian, in which, for a function (image) f(x,y) of two variables, is defined as
In discrete form
As laplacian is a derivative operator, its use highlights intensity discontinuities in an image and deemphasizes regions with slowly varying intensity levels. This will tend to produce images that have grayish edges lines and other discontinuities, all superimposed on a dark, featureless background. Background features can be recovered while still preserving the sharpening effect of laplacian simply by adding or subtracting (depends on the filter value) the laplacian image to the original.
Where f(x,y), g(x,y) are the input and sharpened images respectively. The constant c=-1 if the central coefficient is negative and c=1 if the central coefficient is positive. Algorithm step 1: use the spatial filter algorithm which gives the laplacian image step 2: calculate g(x,y) using the equation discussed above with the input as original image and laplacian image in step1 Unsharp Masking and High boosting filter A process commonly used by printing and publishing industry called unsharp masking, consists of the following steps 1. Blur the original image 2. Subtract the blurred image from the original image (the result is called the mask)
here k is a weight. When k=1 - unsharp masking K>1 - high boost filtering
K<1 - de emphasize the contribution of the mask. The 1-D illustration is shown below, explains how unsharp masking works. The original image can be interpreted as a horizontal scan line through a vertical edge that transitions from a dark to a light region in an image. The blurred image is the result of smoothing, superimposed on the original signal. The unsharp mask in the below figure is obtained by subtracting the blurred signal from the original. The final sharpened image is obtained by adding the mask to the original signal.
Algorithm step1: read the input image step 2: create the blurred image using spatial filtering process algorithm step 3: obtain the unsharp image i.e. gmask using the equation provided in step 2. It subtracts blurred image from original image. step 3: calculate the mask image g(x,y) using the equation provided above which gives high boost image.
Discussion of results: Enhancement using laplacian The image in Figure-1(a) is before enhancement and Figure-1(b) through (c) are obtained after spatial filtering with the given filter [-1,-1,-1;-1, 8,-1;-1,-1,-1]. Figure-1(b) is obtained after doing spatial correlation of the laplacian filter with the input image which does double differentiation on input image, results in highlighting the boundaries of objects in the input image. The Figure-1(c) is obtained after adding Figure-1(b) to the original image
at k=-1, so that the boundaries of objects are added to the original image where the objects in the image can be observed clearly. Unsharp Masking The image in Figure-2(a) is before enhancement before high-boosting. By using the figure2(a) , a blurred image can be obtained using a filter 1/9[1,1,1;1,1,1;1,1,1] or Gaussian smoothing filter of 5x5 with sigma=3. The figure-2(b) is the blurred image which is slightly white text on a gray background. Figure-3(c) is the unsharp mask, obtained by equations discussed in theory above i.e. the mask is the difference between blurred image and original image hence the mask image is dark. Figure-2(d) was obtained using unsharp masking with k=1. The image is slightly better than original, the figure-2(e) shows the result using k=4.5 which is clearer then figure-2(d) as k>1 high-boosting in the image occurs. The change is due to addition of the mask to the original image. Results: Enhancement using laplacian
Figure-1(a)
figure-1(b)
figure-2(a)
figure-2(b)
figure-2(c)
figure-2(d)
% Date: 02/08/2014 %-------------------------------------------------------------------------% Check for right number of parameters %-------------------------------------------------------------------------if nargin ~= 2 error('Requires two input arguments addition(image1,image2)'); exit 1 end output=input1 + input2; end
Conclusion: After completion of the project I came to know about the ways to enhance an image using various filters such as laplacian filter, high-boost filer etc. References 1. Gonzalez R.C, Woods R.E, Digital Image Processing, Pearson Education 2005. 2. www.wikipedia.com 3. www.mathworks.com