Chapter 3 image preprocessing

Source: Internet
Author: User
Tags mathematical functions scale image

Chapter 3 image preprocessing

3.1 grayscale Transformation

I. Definition of grayscale Transformation

Definition of grayscale Transformation (vertex Operation)

★For input image f (x, y), grayscale T will generate an output image g (x, y), and g (x, y) the value of each pixel is determined by the value of the input pixel corresponding to f (x, y), g (x, y) = T (f (x, y )).

★For functions such as f (x, y) and T (f (x, y) of the original image, the gray value is always limited (for example, O ~ (2 5) Non-geometric transformations can be defined as R = T (r), llj r, R (o.255 ).

II. Implementation of grayscale Transformation

Implementation of grayscale Transformation (vertex Operation)

R = T (r) defines the ing between the input pixel value and the output pixel, which is usually achieved through Table query.

Iii. grayscale conversion example

1. Image Inversion

2. Contrast stretch

3. Dynamic range compression

4. grayscale Slicing

 

3.2 grayscale histogram of images

The gray histogram (histogram) counts the number of pixels of each gray level in the image.

I. gray histogram Calculation

If the image has an L-level gray scale (generally L = 256, that is, 8-bit gray scale), then the size of the gray-scale image is m (n, f (x, y) H [K], K = 0... L-1, which can be calculated as follows:

1) initialization: For (k = O; k <L; k ++) H [k] = O;

2) Statistics:

For (x = O; x <m; X ++)

For (y = O; y <n; y ++) H [F (x, y)] ++;

3) Normalization:

Flor (x = O; x <m; X ++)

For (y = O; y <n; y ++) H [F (x, y)]/= float (M (N );

Ii. histogram equalization

Histogram equalization is a process of converting an image into another one with a balanced histogram, that is, the process of having the same number of pixels at each gray level.

Histogram equalization Transformation: sets the gray scale transformation S = f (r) as a non-decreasing continuous microfunction with a limited slope, which converts the input image II (x, y) convert to output image I/O (x, y), input image histogram is hi (R), output image histogram is Ho (s), then according to the meaning of the histogram, after gray scale transformation, the corresponding small area element is equal: Ho (s) ds = Hi (r) Dr

F (r) must meet the following two conditions:

★(1) f (R) (O (r (1) is a single-valued function and increases monotonically;

★(2) O (f (R) (1, (O (r (1 ).

The first condition above ensures the order of gray level from black to white, and the second condition ensures that the gray level of the transformed pixel is still within the permitted range. R = F-l (s) is a inverse transformation function and must also meet the preceding conditions.

Example of histogram correction

Suppose there is an image with a total of 6 4 pixels (6 4 pixels and 8 gray levels). We try histogram equalization. According to the formula:

S2 = 0.19 + 0.25 + 0.2l = o.65,

S3 = 0.19 + 0.25 + 0.2l + o.16 = 0.8l,

S4 = 0.89, S5 = 0.95, S6 = 0.98, S7 = 1.00.

Because only eight gray levels with equal spacing are used here, the transformed s value can only select the nearest gray level value. Therefore, we can select the following values based on the calculation values:

So "1/7, s 1, 3/7, S2, 5/7, S3" 6/7,

S4, 6/7, S5, 1, S6, L, S7, 1.

We can see that the new image has only five different gray levels, so we can redefine its symbol:

S 'o = L/7, S '1 = 3/7, s '2 = 5/7, s '3 = 6/7, s '4 = L.

Since RO = O is transformed and mapped to so = 1/7, there are N0 = 790 pixels to get the so gray value; from RL = 3/7 ing to SL = 3/7, therefore, the gray value of S 1 is obtained from 1 02 3 pixels, and so on. The gray value of S2 = 850 is obtained from 5/7 pixels; since R3 and R4 are mapped to the S3 = 6/7 gray value, 656 + 329 = 98 5 pixels get this gray value. Likewise, for 245 + 1 22 + 81 = 448 pixels, the gray value S4 = 1 is obtained. The preceding value is divided by N = 4096 to obtain a new histogram. It is impossible to make absolute consistency in discrete cases.

Iii. Nature of histograms

In a histogram, you only know the number of pixels with a gray value, but do not know the position of these pixels;

An image determines a unique histogram, but sometimes different images have the same histogram;

If the histogram of each region in an image is known, add them together to obtain the histogram of the image.

Iv. Typical use of histograms

When the image is digitalized, the Histogram can be used to check whether the gray value of the input image is properly allocated within the available gray range;

In medicine, low-radiation X-ray exposure can be used to improve the working conditions of X-ray operators. However, the gray-scale X-ray images obtained in this way are concentrated in the dark area, leading to the inability to see certain image details and difficulty in interpretation. By histogram correction, the gray level is distributed in the appropriate brightness area of the human eye, so that the details in the X-ray can be clearly visible.

The binarization threshold value can be determined based on the histogram;

When the gray value of the object part is larger than the gray value of other parts, you can use the histogram to find the area of the object (in fact, the gray value is greater than or equal to the sum of the pixels of Q );

When the gray value of the object part is larger than the gray value of other parts, you can use the histogram to find the area of the object (in fact, the gray value is greater than or equal to the sum of the pixels of Q ); color histograms can be used for color-based image segmentation.

 

3.3 geometric Transformation

Ry transformation can change the spatial relationship between objects (pixels) in an image. This operation can be seen as the process of moving each pixel in an image.

In geometric transformation, gray-level interpolation is an essential component, because images are generally integrated

It is defined by pixels at the number position. After a point is transformed, it may be mapped to multiple points.

Affine Transformation and imagewarping are two common geometric operations.

I. grayscale Interpolation

1. Nearest Neighbor Interpolation

★The simplest interpolation method is the nearest neighbor interpolation, that is, the gray value of the input pixel closest to the position mapped to it is the interpolation result.

2. bilinear interpolation:

Ii. Spatial transformation

Spatial transformations include simple transformations that can be expressed by mathematical functions (such as translation and stretching) and complex transformations that depend on the actual image but are not easy to use in the form of functions (for example, to correct the image taken by the camera with geometric distortion, the actual Raster image needs to be taken, create a spatial transformation based on the actual distorted data of the raster, and then describe the spatial transformation by specifying the displacement of some control points in the image and interpolation methods ).

1. Affine transfomation)

The formula for the transformation is as follows: f (x) = Ax = B

Where a is the deformation matrix, and B is the translation vector.

Any radiation transformation can be divided into a combination of scale, scaling, distortion, rotation, and translation.

2. Basic Transformation

(1) Definition of basic geometric Transformation

For the original image f (x, y), the Coordinate Transformation Function

X' = A (x, y); y' = B (X, Y)

It uniquely determines the geometric Transformation: G (x', y') = f (a (x, y), B (X, Y ));

G (x, y) is the target image.

(2) Translation Transformation

(3) rotation and Transformation: rotate around the origin (degree

(4) Horizontal Image

(5) vertical image

(6) Scaling

3. persp ective tmnsfomation)

Perspective transformation is the projection transformation of center projection. In non-homogeneous projection coordinate expression, it is a fractional linear transformation of the plane. perspective transformation is often used for Image Correction.

4. Geometric correction

Ry correction is to correct the typical geometric structure in the image as a form without deformation for a certain purpose.

For example, correction of corridor images such as F is divided into two situations: Correction of floor tile shapes and correction of door shapes with handles on the rightmost side.

5. Image Warping)

Image winding defines the image deformation processing of spatial transformation by specifying the displacement of a series of control points. The displacement of non-control points is determined by interpolation of control points.

 

3.4 partial image preprocessing

1. Smooth

L. neighborhood average

★A. Neighborhood Definition

★B. neighborhood average method

★For a digital image f (x, y), take (x, y) as the center, take a sliding window -- the neighbor s (for example:

Processing:

★Disadvantage: the boundary is blurred while noise is eliminated.

★Note: When the neighboring center falls on the Image Boundary: (o rows/columns or N-l rows/columns)

★A. the boundary row/column points are not processed;

★B I. Expand the upper and lower rows and the left and right columns (copy ).

2. Gaussian filtering

Ii. Median Filtering

Median Filtering)

Unlike the weighted average method for smooth filtering, the median filter sorts the pixels in the neighboring area according to the gray level, and uses the median value as the output pixel.

★1) The median filter can protect the image boundary;

★2) the more people the median filtering window is, the more powerful the filtering effect will be, but the details will be lost.

Median Filter is a non-linear filter that can filter out impulsive or granular noise and protect the image edge. Here, we take one-dimensional median filter as an example: one-dimensional median filter uses a one-dimensional sliding window containing odd points, replacing the value of the point in the middle of the window with the value of the values arranged by the size of each point in the window. Suppose the Window Length is 5 points, and the value is (80, 90, 11 O, 1 20), then the value in this window is 11o.

Iii. Edge Detection

Edge refers to the area where the gray scale in the image changes sharply. The variation of the gray scale of the image can be reflected by the gradient of the gray scale distribution. Given the continuous image f (x, y), its direction derivative obtains the local maximum value in the edge normal direction.

The edge of a point in the image is defined as a vector, and the modulus is the direction derivative of the person at the current point. The direction is the direction represented by this angle. Generally, we only consider its model and do not care about the direction.

Iv. Gradient Operators

(1) gradient operators can be divided into three types:

★1. An operator that uses the differential approximation function derivative of the image. Some are rotating immutability (such as the Laplacian operator), so only one convolution mask is needed for computation. Other operators that approximate the first derivative use several masks.

★2. An Operator Based on the second derivative of the image function over zero point (for example, m arr-hild Reth or Canny edge detection operator.

★3. Try to match the image function with the parameter model of the edge.

(2) First Class gradient Operators

The Laplace operator usually uses a 3 × 3 mask, and sometimes uses a Laplace operator that emphasizes the center pixel or its joining property (this approximation does not have rotation immutability ).

Disadvantages of the laplace operator: it generates a dual response to some edges in the image.

Shapeening)

The purpose of image sharpening is to make the image edge more steep and clear. The sharpening output image F is obtained from the input image G according to the following formula: f (I, j) = g (I, j)-c s (I, j ), c is the positive coefficient that reflects the degree of sharpening, and S (I, j) is the measure of the degree of sharpening of the image function. It is calculated using the gradient operator. The Laplacian operator is often used for this purpose.

Prewitt Edge Detection Operator

Sob E1 Edge Detection Operator

(3) The second type of gradient operator -- the second derivative zero crossing Operator

According to the fact that the first-order differential (gradient) at the edge of the image should be the extreme point, the second-order differential at the edge of the image should be zero, it is much easier and more accurate to determine the position over zero point than to determine the Extreme Point. The right side is the result of Lena's zero point detection.

To suppress noise, smooth filtering can be performed first before secondary differentiation. Gaussian Functions are usually used for smooth filtering, so there is a log (Laplacian of Gaussian) operator.

Gaussian-Laplace (log, Laplacian of Gaussian) operator.

Noise has a greater impact on edge detection. The edge detector with better performance is a Gaussian-Laplace (lO G) operator. It combines Gaussian smoothing filter with Laplace sharpening filter to smooth out noise first and then perform edge detection, so the effect is better.

 

Zero crossing detection

During implementation, the difference dog (difference ofgaussians) of two Gaussian Functions with different parameters is generally used to perform convolution for the image. In this way, the edge points detected are called f (x, y) zero-crossing ).

Different from the previous differential operator that uses only a small neighborhood to detect the edge, the zero-crossing (zero-crossing) detection relies on the norm and parameters. Yes, but the edge position is irrelevant to the selection of 0. If you only care about the global edge, you can select a large neighborhood (for example, when 0 = 4, the neighborhood is close to 40 pixels) to obtain the obvious edge. Zero-crossing detection is more reliable and difficult to be affected by noise. However, the disadvantage is that the shape is smoothed out too much, for example, less obvious corner points will be lost, and the tendency to generate the ring edge.

The cause of the ring edge is that the edge of the image appears mostly at the position where the brightness is raised or concave. Two Extreme Points will appear in the first order of the line by the edge method, that is, there will be two zeros over zero. The overall result is that the edge shows a loop.

(4) edge extraction by using the "quick bi" command or edge detection by using the "Edge Detection" command)

In the following three standard values, the Canny edge detection operator is optimal for the step edge affected by the latch noise:

★1) detection standard-no loss of important edges, no false edges;

★2) Positioning standard-Minimum deviation between the actual edge and the detected edge position;

★3) single response standard-reduce multiple responses to a single edge response.

The concept of the edge moderation operator is based on the following concepts:

(1) edge detection operators are expressed for one-dimensional signals and the first two optimal standards (namely detection and positioning standards), and complete solutions can be obtained using calculus methods;

(2) If you consider the third standard (multiple responses), you must use a numerical optimization method to obtain the optimal solution, the optimal filter can be effectively approximate to the standard deviation (first-order differential of Gaussian smoothing filter, and its error is less than 20%, so as to facilitate implementation; this is similar to the M ar-hild Reth edge detection operator, which is based on the log edge detection operator;

(3) spread the edge detection token to a two-dimensional situation. The step edge is determined by the position, direction, and possible amplitude (intensity. It can be proved that the image and a pair of 2 D Gaussian are convolution and then differentiated along the ladder degree, which constitutes a simple and effective direction operator (recall, the log zero-crossing operator does not provide edge information because it uses the Laplacian filter ).

(4) A false response to a single edge caused by noise usually results in a so-called "streaking" problem. In general, this problem is very common in edge detection.

The output of edge detection operators usually requires threshold processing to determine which edges are prominent.

Ripple refers to the disconnection of the edge contour, which is caused by fluctuations in the output of the operator that exceed or below the threshold. The ripple phenomenon can be eliminated through the threshold processing with lag (thresh01ding withhysteresis;

If the edge response exceeds a given high threshold, these pixel points constitute the final output of edge detection operators at a certain scale.

Some weak responses usually correspond to noise, but if these points are connected to some vertices with strong response, they are likely to be the real edges in the image. These connected pixel points are treated as edge pixels when their response exceeds a given low threshold.

The low threshold and high threshold must be determined based on the estimation of the signal-to-noise ratio.

(5) The proper scale of the operator depends on the situation of objects contained in the image. The solution to this unknown number is to use multiple scales to collect the obtained information. The value of the standard deviation (to represent) of Gauss. There may be several scales of operators that give a prominent response to the edge (that is, the signal-to-noise ratio exceeds the threshold); in this case, select an operator with the smallest scale, because it is the most accurate.

Feature synthesis appmach)

First, all the prominent edges obtained by the smallest scale operator are marked. The edges generated by operators with large scales are synthesized based on them (marked edges) (I .e, based on the evidence collected from a small scale to predict a large scale (the expected effect ). Then compare the merged edge response with the larger scale (actual edge response. They are marked as edges only when they are significantly stronger than responses made by merging predictions.

This process can repeat a scale sequence (from small to large) and generate an edge chart by constantly adding edge points that are not in a small scale.

 

Canny edge detection algorithm

L. For the ascending standard deviation (repeated steps (2) to (6 );

2. convolution of image F and scale as Gaussian functions;

3. Estimate the normal direction N of the local edge for each pixel in the image;

4. Use the non-maximum suppression formula to locate the edge;

5. Use the formula to calculate the edge strength;

6. Perform lag threshold processing on edge images to eliminate false responses;

7. Use the feature Synthesis Method to collect final edge information from multiple scales. (This step is omitted for normal implementation .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.