# Pipeline Crack Detection Using Mathematical Morphological Operator

• A. Prema Kirubakaran
• I. V. Murali Krishna
Chapter

## 1 Introduction

### 1.1 Image Analysis and Processing

Image analysis is the process of taking out required information from digitized pictures or images by means of the technique known as digital image processing. Increasing digitization has paved way for many new techniques, and this leads to data complexities which are continuously posing new challenges. These challenges are conquered with various techniques and solutions. Big data concepts termed as new era of data analysis and processing helps to handle with volume of data from various structures and sources. Data is coming in variety of forms like structured, semi-structured, unstructured, and sensor data. An excellent image analysis tool is our own eyes, which extracts high-level information. Proper mechanism is required to handle decision-making situations. Digital image processing is the only practical technology for
• Classification

• Feature extraction

• Pattern recognition

• Projection

• Multi-scale signal analysis

### 1.2 Image Coordinates

Signals are also used for image processing. These image outputs are treated as 2D signals, and standard signal processing techniques are applied for image detection. Image analyzed will be considered to be a function of two real variables as A(X, Y), where A will be considered as amplitude defined as the brightness of the image at the real coordinate position (X, Y). This chapter will deal with three important categories of manipulating an image: image processing, image analysis, and image understanding.

## 2 Pipeline

Crude oil and natural gas over land transporting are safe and efficient through pipelines. Each and every day, oil companies transport enough crude oil and petroleum products to fill 15,000 tanker truck loads and 4,200 railcars. Pipeline network transports three million barrels of oil every day. Everything from water to crude oil even solid capsule is being transported across millions of miles.

### 2.1 Pipeline Design

This chapter to begin with needs to learn about the designing of a pipeline system. Factors like distance to be traveled, quantity of liquid or gas that is to be transported, and the quality of the substances to be traveled have to be considered.

NACE defines the following for the pipeline designers’ concentration before designing a pipeline:
• Sensitive areas nearby

• Communities located nearby and their concern

• Temperature and climatic conditions

• Public safety concern and any other risk that is posing near

• The terrain facility for the construction of a pipeline (Fig. 1)
In case of pipelines underwater, the condition is still hectic at the time of inspection. To overcome these problems, a computer-based monitoring system was proposed to set up and as a part to make it efficiently work, image analysis with mathematical morphological operators to detect the defects and edge detection principle to remove the shadow images is being implemented (Figs. 2 and 3).

### 2.2 Causes for Pipeline Damage

Though there are many reasons, the main cause is due to corrosion. This occurs because the pipeline runs for long meters, and for many years together, they get damaged due to rust and the residue formation in the inner wall of the pipeline, and this results in the cause of cracks and holes thus leading to oil leakage affecting the environment badly. A crack in the pipeline can be identified as given in Fig. 4.

### 2.3 Pipelines Monitoring—Smart Pigs

Monitoring of pipelines should be done with weekly, bi-weekly or monthly inspection by the operators and they inspect the pipelines with all relevant safety measures. Manually, internal inspection is carried out by gadgets like high-resolution inspection tools also called as intelligent pigs or pipeline intervention gadget, to detect the dents, damages, and corrosions.

### 2.4 Drawbacks of Existing Pipeline Models

One of the most extensive representations is smart pigs (pigs) pipeline intervention gadget. Earlier smart balls and X-ray machine detection were used.

Drawbacks
1. 1.

Routine leak surveys, including pinhole-sized leaks are required.

2. 2.

Emergency leak location, minimizing product loss evaluation is mandatory, and cleanup costs are high.

3. 3.

Validation of alarms generated by CPM systems (with leak location) is not successful.

4. 4.

Acceptance testing of new pipelines failed.

### 2.5 Image Analysis and Processing Model of a Pipeline

Image defects encountered can be accessed by the sizing methods in the piping industry. Although the focus of this chapter with research has been on image analysis and processing of pipeline applications, the technology can be extended for many other applications also, including the inspection of stainless steel and aluminum-based products. Defects in a pipeline are identified using a computerized program in this chapter. As discussed earlier, a camera is sent inside the pipeline path that captures the images and sends to the system.

### 2.6 Characteristics of Image Analysis Model

After reading the theory of pipeline, the analysis process of an image has to be considered, and the size of the digitized camera used to capture and send the images to the data section for image analysis should be sized conveniently according to the inner diameter of the pipeline. The miniature cameras come with different specifications, but the right one has to be chosen depending on the diameter of the pipeline that helps to select the right camera for image capturing. Choosing a camera depends on the diameter of the pipeline that is used for transporting different substances.

### 2.7 Implementation of Digitized Camera with Fiber Optic Cable

The rapid deployment of fiber optic technology to enhance the transportation of images through light sources helps to capture the picture from the camera and sent to the system that is prepared to monitor the pipeline image techniques. Impact technologies like LLC help to explore the possibilities in attaching a fiber optic cable to a digitized camera to capture the pictures from inside the pipeline. This helps to have a good knowledge of the type of image processing technique involved in taking pictures. A study with the help of any cameraman will helps us to select the perfect one for picture capturing inside the pipeline.

### 2.8 Pipeline Evaluation

Pipelines have to be evaluated before choosing the fiber optic cable (FOC) and the camera for further processing. This is carried out with the help of an inspection engineer who guides to tell the structure, material, and the inside coating of the pipeline that are buried underneath. Pipelines are drained, and this process is termed as a “shut-down operation,” where the path is closed for evaluation before the next process commences. In this duration, pipelines are checked for cracks, holes, or any other defects, and these are replaced or repaired to carry out the next assigned task. This may take 10–30 days, and numerous people evolve in this process because even a minor negligence will cause oil spills that results in heavy loss to the industry and also to the environment. After the study of the pipeline characteristics, computerized methods to detect the defects are carried out with the insertion of the digitized camera inside the pipeline to find and locate the damaged areas in the pipeline.

### 2.9 Fiber Optic Cable

A pipeline runs for meters together; a camera travels or stretches to cover this distance with an attached fiber optic cable. To achieve longer distance travel of data without any loss and to resist electromagnetic interferences, optical fibers are widely used. This novel procedure of camera attached to a fiber optic cable to capture pictures is the first step in this image analysis process (Fig. 5).

The jacket is used to hold the cable without movement while traveling inside the pipeline to capture a jerk-free image. Microbend clamping device is used to hold the jacket that has an optical photo detector, and this is connected to the laptop or desktop or to an IPAD through the optical electrical converter. This design of the system helps to capture and send the pictures for image analysis and processing.

## 3 Image Detection Techniques

### 3.1 Gate Turn-Off Thyristors

A GTO is implemented here because it acts as rectifiers, switches, and as a voltage regulator. PNPN technique is applied in these GTOs which helps to detect repeated occurrence of 0s.

### 3.2 High-Frequency Filter

A high-frequency filter is applied here to filter the images and give the required section of an image for further image processing. Proposed cluster algorithm enhances the design to perform image modifications and noise reductions using high-pass and low-pass filters (Fig. 6).
A cluster image developed from the defected image is sent from the camera. Visual images on a computer are manipulated by computer graphics software. There are two categories of computer graphics raster and vector graphics. Focus on either vector or raster graphics is performed by many graphics programs, but there are a few that combine them in interesting ways. The concept of raster graphics is instigated for image analysis and processing. Raster graphics is set up as raster images that hold the bit images. This option in raster graphics helps to develop the bit manipulation concept in this chapter. The bits transmitted are then grouped into sets for mathematical morphological implementation (Fig. 7).

### 3.3 Image Analysis Using Bitmaps

Digital images can also be represented as raster image, and it is also called a bitmap. .gif, .jpg, .bmp are the various formats for storing images in the system. Red–Green–Blue (RGB) is one of the best methods to identify the image with pixel notifications.

### 3.4 Methods to Identify Hidden Structures in an Image

Implementation through machine learning for hidden structure images, a precise concept of unsupervised learning algorithm plays a major role, unsupervised learning refers to the problem of trying to find hidden structure in unlabeled data. Since the samples taken to identify the images are unlabeled, there is no error or reward signal to evaluate a potential solution. This discriminates unsupervised learning from supervised learning. Unsupervised learning is closely related to the problem of density estimation in statistical application. Approaches to unsupervised learning include:
1. i.

clustering (e.g., k-means, mixture models, hierarchical clustering),

2. ii.

blind signal separation using feature extraction technique for dimension reduction

Through this chapter since the bits are analyzed without predefined set of results, k-means clustering algorithm is used to detect the hidden structure in the image. Images classified into bitmaps are applied through k-means structure to classify the hidden bit images. Images can be as clusters or can be as a single image, these are converted to bitmap image and then through the k-means, the defected parts are identified. Length and the exact position are calculated using the mathematical morphological operators.

### 3.5 Filtration of an Image

A filtering of an image is useful for many applications, including smoothing, sharpening, removing noise, and edge detection. A filter starts its process work from a kernel which is a small array applied to each pixel and its neighbors within an image. Filters are always applied to images for clear view, and this process is known as convolution and this is achieved by applying either in spatial or frequency domain. Image domains are used to overview transformations between images. This helps to make a study of filtered images. The high-frequency filter design is used here to refine the image before bit valuation. The design is very important because the anomaly caused during image perfection is rectified with this design. The decision whether to use a high-pass filter or low-pass filter should be taken with all properties in concern. With these reviews, the images taken by the digitized camera with a fiber optic cable connection are implemented to get the resultant structure as required for the detection faults in the pipeline.

### 3.6 Characteristics of Cluster Algorithm Model

Cluster analysis used for image processing is a general task to be solved. The clusters are represented as groups with small distances within the cluster members and data space dense areas. Clustering can therefore be originated as a multi-objective optimization problem, and an approximate process based on cluster algorithm can be opted depending upon the density threshold, maximum occurrence of projected clusters that depends on individual dataset, and the results to be expected. Cluster analysis is an iterative process of knowledge with trial and failure involvement and not automatic. Thus, it is required to modify data preprocessing and parameters, till the result with desired properties is achieved.

### 3.7 K-Means Algorithm

To implement in a best way k centroids are declared, each representing a cluster. All centroids should be planned and placed because they are received from different location causing different results. The better choice is to place them as much as possible far away from each other and take each point that belongs to a given dataset and relate it to the nearest centroid for further analysis. When no point is pending, the first step is completed and an early group age is done. At this point k new centroids are used as centres of the clusters resulting from the previous steps has to be recalculated, a knowledge discovery approach helps to clarify the different methods used in k-means algorithm in case of clustering large datasets. To read the values in a much faster method, the technique of learning fast nets has been applied.

## 4 Morphological Image Processing System

In this chapter, the method for background of the theory is discussed and evaluation of the theory used to identify the defects is identified. Based on the mathematical theories of sets and to logical notations, its principle supports in studying the morphological properties (shape, size, orientation, and other forms) of the object (patterns) through nonlinear transformations as associated with reference object (restructuring element). Through these continued processing, image processing to detect the cracks is achieved. The techniques used to perform these tasks are as follows (Fig. 8).

This is a vital and initial step to keep the pipeline infrastructure in proper shape (quality-wise); the pig (pipeline intervention gadget) used needs a lot of manual operation and there are differences between the image photographed and the picture marked manually. Thus, automated system implementation is required. The basic task for automated operation is to find out the cracks, holes, joints, and fissures in the images taken by the camera. These cracks have their own specific patterns (images described as such), matching the Gaussian profile on which pattern recognition has to be performed. Mathematical morphology is used to extract image components with regard to geometric features. An image is not taken under assumption; the features are extracted from the image that is used for representation and description of the image. This is possible by taking the values from the image domain, and this can be used as semantic information.

### 4.1 Implementation of the Operator Tool

#### 4.1.1 Design of the Algorithm

Morphological operations are used mainly to detect expanding and shrinking image to a given structuring element. When the images are operated in the initial state, it appears only in black and white called binary images and later after technical development, they are applied for color images called grayscale images.

The image domain is mapped as 2D coordinates from minimum to maximum range, which defines the possible intensity values of the image. The values for a binary image (black and white) range from [0–1], for grayscale images (taken as 8 bit), it ranges from [0–255]. Mathematical morphology operates on nonlinear structures and thus uses totally different type of algebra, required for 2D attributes than the linear algebra. As defined the 2D image F is defined as follows:
$$F = Z^{ \wedge } 2|\square \;[I({\text{Min}});I({\text{Max}})]$$
(1)
I

image intensity represented as bits

Z

bit error recovery

That maps 2D coordinates to the range [I(min) to I(max)] that defines the possible intensity values. If an image is black and white, the dark colors are considered as background and white are parts of the image. But now to locate a perfect crack position, white parts are placed as background and dark ones are parts of an image. When the image is photographed and sent to the system, with the leak software, the data is read for pixel image and it is analyzed for picture perfection. Leak software is a tool that helps to find the leak values with leak detection methods.

In case of grayscale image, to differentiate the colors, homogeneous technique is followed, where same colors are grouped together as white and the remaining as dark color (Fig. 9).
Picture showing the crack being locked with a redline indicating the location of a crack in the pipe (Fig. 10).

### 4.2 Analysis with the Bitmap Set

Dilation is a morphological expansion operation—this operation is used both in binary and grayscale images. In binary images, structural element is moved over the image where the dilation takes on binary images. Two pieces of data are taken as data inputs.

#### 4.2.1 Data Gathering Procedure

First the image to be dilated is collected from the images sent by the camera (a digitized fiber optic cable is connected). Then the fiber optic cables carry the communication signals using pulses of light. The second step is to collect the samples from the image. The structuring element determines the precise effect of the dilation on the input image. Thus, the data is gathered by the images that are sent by the camera (for 1 s minimum 500 images). Foreground pixels are represented by 1s and background pixels by 0s. An example of a structuring element with a 3 × 3 squares and origin in the center is shown in Fig. 4, and then these images are scanned for pixels (Table 1).
Table 1

Values for evaluation of 3 × 3 pixels

 1 1 1 1 1 1 1 1 1

### 4.3 Mode of Analysis—Detection of the Crack with the Morphological Operator

#### 4.3.1 Types: Erosion and Corrosion

After the procedure of grayscale binary value application, now the image should be reduced using erosion. Erosion is a morphological shrinking operation: In binary images, structural element is moved over the images; here pixel is taken to the result image, and it is written as:
$$F - E = \left\{ {XEZ^{ \wedge } 2|E*{\text{CF}}} \right\}$$
(2)
CF

correction factor (calculated from the available bit set)

where F is an image and E is a structured element for evaluation. In case of gray scale, each pixel touched by E is considered and the minimum intensity for all the pixels is calculated.

Dilation plays a vital role, and this operation mostly uses a structuring element for probing and expanding the shapes that is present in the input image. It is one of the most prominent operations in mathematical morphology.

#### 4.3.2 Opening and Closing Techniques

Dilation and erosion can be combined to form two important higher order operations. The opening technique is used to remove small objects from the image and closing removes small holes (for original images). For defected images, closing removes small objects and opening removes small holes.

### 4.4 Proposed Method to Implement the Image Analysis Model

Now with all these techniques, cracked image is to be located. First a subtraction is performed to obtain the defected image as follows:
$${\text{OI}}-{\text{CI}} = {\text{UDI}}$$
(3)
where OI stands for original image, CI stands for cracked image, and DI stands for undetected image. So the remaining dilation (defected image as called) is taken for morphological evaluation. If there are two or more cracks (multiple), then mathematical morphology deals with two image processing techniques. In this method, two images are considered, in which the first one is taken as input and uses an isotropic structural element, for a dilation or erosion process. This process is same for any number of cracks. Now to proceed further with multiple cracks geodesic reconstruction technique is applied, where as stated earlier the first one is taken as input and the second one is used to confirm the result. This process is repeated (iteration) until the stability of the image is obtained. By applying this process, the original image is either reduced or expanded in size by one pixel, for every iteration. Such an image called as the marker image is then confirmed by a mask image. The number of iterations gives a measure for the distance of the pixels in a cracked image. Repetition of dilation and erosion takes place until the defected image is successfully evaluated.

## 5 Edge Detection of an Image

Edge detection is a process that is used to make the image of an oil pipeline to appear bright and clear for further analysis, after smearing mathematical morphology for curves, error detection must be used, to read the pixel values and eliminate the shadow images that appear. It reads the coordinate values and builds accurate pixel values using this method. It also mainly helps to remove the shadow images if it occurs during the camera intervention inside the oil pipeline. The line or part where an object or area begins or ends is an edge (Fig. 11).

### 5.1 Methods to Detect Edge Defects

Edge detection has many methods, but they are grouped under two categories such as search-based and zero crossing-based methods. Smoothing filters’ application helps in differentiating the way of computing edge strength. The different types of edge detection algorithms are gradient-based algorithm includes Laplacian-based algorithm and Canny’s edge detection algorithm. Canny’s edge detection algorithm is the best one when compared to other edge detection algorithms.

#### 5.1.1 Smoothing of the Detected Image

In smoothing, the data points of a signal are modified so individual points (presumably because of noise) are reduced, and points that are lower than the adjacent points are increased leading to a smoother signal.

Smoothing is used in two important ways that can aid in data analysis
1. (1)

It must be able to retrieve more data after smoothing process

2. (2)

It must be able to give analysis details that is both easy to access and robust.

## 6 Conclusion

The purpose of this chapter is to develop an algorithm to ease the work of a manual operator in identifying the cracks in an oil pipeline, with better accuracy and reduced false detection of image recognition. Our proposed approach is also suitable for any type of computerized pipeline intervention. The study aims to construct a computerized mobility model which is useful to an environmental protection service. This model handles the problem of image analyzes interruption on the computing during the transportation of any form of liquid in a pipeline, where the substance travels from one location to another. The solution might be the boundary of convex and non-convex environment, which is successful. Furthermore, mathematical morphological operators and edge detection algorithms applied here are evaluated, thus giving an appreciated result.

The performance of existing X-ray image analysis and smart pigs for pipeline analysis over this computer-based monitoring system (CBMS) is compared and analyzed. Based on the performance analysis of the existing models, the developed CBMS shows a good result, and it is faster and the time duration is limited when compared to the other two existing models. These two models, X-ray and smart pigs, take 2 days and a day, respectively, for image analysis. CBMS gives the result within seconds and gives approximately 90% result. Thus, human errors and time delay in detecting the cracks or holes or any other defects caused due to natural calamities or due to human errors is avoided. The overall performance of CBMS may vary depending on the type of algorithm chosen to remove clusters, but the ultimate output remains the same with a good record of result.

## References

1. 1.
Aldenderfer, M. S., & Blashfield, R. K. (1988). Sage university paper on quantitative applications in social science. Cluster Analysis, 36(1), 1–13.Google Scholar
2. 2.
Wardhani, A. W., & Gonzalez, R. (1998). Automatic image structure analysis. e-prints (pp. 1–9). Google Scholar
3. 3.
Ledda, A., & Luong, H. Q. (2006). Image interpolation using mathematical morphology (pp. 12–49).Google Scholar
4. 4.
Bhoite, A. (2011) Automated fiber optic cable end face field inspection. Technologic, 3–8.Google Scholar
5. 5.
Blashfield, R. K., & Aldenderfer, M. S. (1978). The literature on cluster analysis. Multivariate Behavioral Research, 13, 271–295.
6. 6.
Busch, C., & Eberle, M. (1995). Morphological operations for color-coded images. In F. Post & M. Göbel (Eds.), Proceedings of the European Association for Computer Graphics (pp. 193–204).Google Scholar
7. 7.
Can, F., & Ozkarahan, E. A. (1984). Two partitioning type clustering algorithms. Journal of the Association for Information Science and Technology, 35, 268–276.Google Scholar
8. 8.
Can, F., & Ozkarahan, E. A. (1989). Dynamic cluster maintenance. Information Processing and Management, 25, 275–291.
9. 9.
Canny, J. (1986). A computational approach to edge detection (pp. 3–6).Google Scholar
10. 10.
Crouch, C. J. (1988). A cluster-based approach to thesaurus construction. In 11th International Conference on Research and Development in Information Retrieval (pp. 309–320). New York.Google Scholar
11. 11.
Domingo, J., Benavent, X., Vegara, F., & Pelechano, J. (2005). A new approach for image colour morphology (pp. 234–245). Tech. Rep., Institute of Robotics, University of Valencia.Google Scholar
12. 12.
Dougherty, E. R., & Astola, J. (1994). Introduction to non-linear image processing. Bellingham, Washington: Spie.Google Scholar
13. 13.
El-Hamdouchi, A. (1987). The use of inter-document relationships in information retrieval. Ph.D. thesis, University of Sherfield.Google Scholar
14. 14.
Ester, M., Kriegel, H.-P., & Sander, J. (1996). A density based algorithm for discovering clusters in large spatial database with noise (pp. 226–231).Google Scholar
15. 15.
Everitt, B. (1980). Cluster analysis. In F. Khalvati (Ed.), Computational redundancy in image processing (pp. 4–6, 3–57, 2nd ed.).Google Scholar
16. 16.
Gonzalez, P., Cabezas, V., Mora, M., Cordova, F., & Vidal, J. (2010). Morphological color images processing using distance-based and lexicographic order operators. In Proceedings of the 29th International Conference of the Chilean Computer Science Society.Google Scholar