Image processing

1 to 1 Filters 

Transform is given by function:

             Color out = F( Color in )

1 to 1 filter is usually shown as an input-output relationship graph with the original pixel value on the horizontal axis as the input, and the new pixel value on the vertical axis as the output.

 

 

Useful 1-to-1 transforms:

1. Null transform

2. Photo-inversion transform

3. Brightness correction

4. Contrast enhancement transform

5 Gamma correction




 

 

Convolution Filters

One of the most powerful techniques in all of image processing is convolution. 

Convolution is the modification of a pixel's value on the basis of the value of neighboring pixels. 

Images are convolved by multiplying each pixel and its neighbors by a numerical matrix, called a kernel. This matrix is essentially moved over each pixel in the image, each pixel under the matrix is multiplied by the appropriate matrix value, the total is summed and normalized, and the central pixel is replaced by the result. 

Cx,y = å(å(Pi,j*Mi,j))/(å(å(Mi,j))

 

Kernel can be virtually any size (3x3, 5x5, 5x7, 15x15, whatever), but 3x3 sizes are generally the most useful--they operate only on a pixel and its directly adjacent neighbors.

Convolution requires a lot of computational power. To calculate a pixel for a given mask of size m x n, m * n multiplications, m * n - 1 additions, and one division are required. So to perform a 3 x 3 convolution on a 1024 x 1024 color image (a minimal convolution on an average-size image), 27 million multiplications, 24 million additions, and 3 million divisions are performed. For more substantial convolutions, such as 5 x 5 or 8 x 8, on larger images the amount of computation required becomes very large indeed.

if a filter results in RGB values outside 0..255, we can:

At the edge of an image:

  • We usually want the filter to act as if the pixels beyond the edge are “just like” the ones in the image.
  • so, for example, we can perform computations as if the (nonexistent) column of pixels just to the left of the image is identical to the left-most column of the image.

 

 

 

 



 

1. Low-frequency filters - Smoothing convolutions 

Low frequency filters:

 

 

 


The blur filters - Unweighted smoothing

The blur filters smooth transitions by averaging the pixels next to the hard edges of defined lines and shaded areas in an image

3x3 matrix

   

9x9 matrix

   

 


Gaussian filters  - weighted smoothing

The Gaussian distribution in 1-D has the form:

 

Eqn:eqngaus1

where Eqn:eqnsigma is the standard deviation of the distribution. We have also assumed that the distribution has a mean of zero (i.e. it is centered on the line x=0)




 1-D Gaussian distribution with mean 0 and Eqn:eqnsigma=1

In 2-D, an isotropic (i.e. circularly symmetric) Gaussian has the form:

 

Eqn:eqngaus2




 2-D Gaussian distribution with mean (0,0) and Eqn:eqnsigma=1

The idea of Gaussian smoothing is to use this 2-D distribution as a `point-spread' function, and this is achieved by convolution. Since the image is stored as a collection of discrete pixels we need to produce a discrete approximation to the Gaussian function before we can perform the convolution. In theory, the Gaussian distribution is non-zero everywhere, which would require an infinitely large convolution kernel, but in practice it is effectively zero more than about three standard deviations from the mean, and so we can truncate the kernel at this point. 

 

3x3 matrix

   


5x5 matrix

   

 

5x5 matrix - discrete approximation to Gaussian function with Eqn:eqnsigma=1.0

 

 

 



2. High-frequency filters -sharpening convolution 


How a sharpening convolution works

 


Sharpening filters

a) High Pass (HP) Filters

e.g.  a=1, b=5

  

b) Mean Removal

  

 



 

3. Edge-detection filters

a) Shift and difference filters

These  filters can be constructed to detect edges in specific directions. Due to their limited size, these kernels can only detect edges along the horizontal, vertical, and diagonals.

 

Vertical

0 -1 0
0 1 0
0 0 0

Horizontal

0 0 0
-1 1 0
0 0 0

Diagonal

-1 0 0
0 1 0
0 0 0
 

b) Laplacian filters

    L(f(x,y)) = d2f/dx2 + d2f/dy2

for discrete function

    d2f/dx2 = f(x+1,y)-2*f(x,y)+f(x-1,y)

    d2f/dy2 = f(x,y+1)-2*f(x,y)+f(x,y-1)

kernel matrix:

    

 



 

4. Emboss filters

 

East filter:

-1 0 1
-1 1 1
-1 0 1

South-East filter:

-1 -1 0
-1 1 1
0 1 1

 

South-East filter (2):

0 0 0
0 3 1
0 1 1

 

South filter:

-1 -1 -1
0 1 0
1 1 1