crack inspection - adr - advance robotics - image processing

25
Advanced Robotics EE001-3.5-3-AR Vision-Based Crack Detection using Image Processing ELAHEH SHAKERI TP020832 UC4F1504ME MECHATRONICS ENGINEERING MR. SURESH GOBEE ASIA PACIFIC UNIVERSITY OF TECHNOLOGY & INNOVATION 15 th of September 2015

Upload: ella-sh

Post on 26-Jan-2016

16 views

Category:

Documents


0 download

DESCRIPTION

crack detection usingImage processing in MATLABCrack size measurementAutomatic Inspection Matlab CodeGui

TRANSCRIPT

Page 1: Crack Inspection - ADR - Advance Robotics - Image processing

Advanced Robotics

EE001-3.5-3-AR

Vision-Based Crack Detection using Image Processing

ELAHEH SHAKERI

TP020832

UC4F1504ME

MECHATRONICS ENGINEERING

MR. SURESH GOBEE

ASIA PACIFIC UNIVERSITY OF TECHNOLOGY & INNOVATION

15th of September 2015

Page 2: Crack Inspection - ADR - Advance Robotics - Image processing

Page 1 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Acknowledgement

I would like to acknowledge the assistance of following mechatronic engineering

faculty members at Asia Pacific University of Technology and Innovation who helped in

making this assignment a success. Particular thanks to my lecturer, Mr. SURESH GOBEE

who performed valuable proofreading and made suggestion for improvement. His expertise

and insights has helped tremendously throughout the development of this assignment. In

addition, the management of APU should be given credit for providing top–notch facilities

especially the labs and library. I would also like to thank my family and friends that had

helped in contributing ideas, resources and generous assistance that was very helpful to my

assignment.

Page 3: Crack Inspection - ADR - Advance Robotics - Image processing

Page 2 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Table of Contents

List of Figures ............................................................................................................................ 3

List of Tables ............................................................................................................................. 3

Introduction ................................................................................................................................ 4

Objectives .................................................................................................................................. 5

Flow Chart ................................................................................................................................. 6

MATLAB Codes ........................................................................................................................ 7

Video Acquisition .................................................................................................................. 7

Inspection ............................................................................................................................... 7

Image Colour Conversion ...................................................................................................... 8

Image Enhancement & Filtering ............................................................................................ 9

Image Scaling..................................................................................................................... 9

Weiner Filter ...................................................................................................................... 9

Median Filter .................................................................................................................... 10

Image Adjust and Contrast............................................................................................... 11

Image Negative ................................................................................................................ 12

Further Noise Reduction ...................................................................................................... 12

Crack Detection ................................................................................................................... 13

Crack Dimensions Measurement ......................................................................................... 14

Crack Type Detection .......................................................................................................... 16

Vision-Based Crack Detection GUI......................................................................................... 17

Discussion & Result ................................................................................................................. 18

Conclusion ............................................................................................................................... 21

Reference ................................................................................................................................. 22

Appendix .................................................................................................................................. 23

Page 4: Crack Inspection - ADR - Advance Robotics - Image processing

Page 3 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

List of Figures

Figure 1 Pipe crack outer inspection (Olympus Corporation, 2015) ......................................... 4

Figure 2 Types of pipe crack to be detected .............................................................................. 5

Figure 3 Vision-based crack detection flow chart ..................................................................... 6

Figure 4 Image colour conversion from YCbCr to RGB ........................................................... 8

Figure 5 Image conversion from RGB to Grayscale ................................................................. 8

Figure 6 Image scaling process before & after .......................................................................... 9

Figure 7 Weiner filter application process before & after ....................................................... 10

Figure 8 Median filter application process before & after ....................................................... 10

Figure 9 Image adjust and high contrast .................................................................................. 11

Figure 10 Image auto threshold before & after ........................................................................ 11

Figure 11 Image negative process before & after .................................................................... 12

Figure 12 Image further noise reduction using bwareaopen before & after ............................ 12

Figure 13 Command window result return of black & white image confected components .. 13

Figure 14 Image objects labelling process before & after ....................................................... 14

Figure 15 Command window result return of regionprops function ....................................... 14

Figure 16 Command window result return of crack length and width measurements ............ 15

Figure 17 Command window result return of identified crack type ........................................ 16

Figure 18 Vision-based crack detection developed GUI ......................................................... 17

Figure 19 Hairline crack detection and size measurements result through GUI ..................... 19

Figure 20 Corrosion crack detection and size measurements result through GUI .................. 20

Figure 21 Catastrophic crack detection and size measurements result through GUI .............. 20

List of Tables

Table 1 bwconncomp function return fields ............................................................................ 13

Page 5: Crack Inspection - ADR - Advance Robotics - Image processing

Page 4 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Introduction

Nowadays, million kilometres of high pressure pipelines are used in variety of

applications to transport oil, water or other types of liquids. Based on each application’s

requirements pipes are selected and classified into different materials and dimensions.

However, pipes can be vulnerable and exposed to cracks which normally are caused by

external factors due to their operational condition. Respectively, regular inspection of

pipeline is required and considered crucial since any defects may occur and propagate

overtime, leading to dire consequences if they remain unattended. Currently, crack detection

methods are practiced in industry considered for inspection. Vision-based crack detection is

one of the common methods which is used to monitor and ensure the safety of the pipe line

condition. Pipe lines are usually located at hostile environments and often manual visual

inspection is not feasible or it may not efficient to detect the pending failures. Figure 1

represents a pipe outer inspection robot example.

Figure 1 Pipe crack outer inspection (Olympus Corporation, 2015)

In this assignment, an automatic vision based crack detection system is to be

developed using image processing tool MATLAB. The machine vision is to be accomplished

by taking information from a visual sensor (webcam) to enable the image processing. The

system attempts to be capable of pipe crack detection irrespective to crack’s orientation, size,

distance as well as environmental changes including the lighting. The developed program is

required to obtain actual result with a high accuracy and repeatedly in order to be considered

applicable.

Page 6: Crack Inspection - ADR - Advance Robotics - Image processing

Page 5 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

The major challenge of the system to overcome is crack size measurement with

respect to the distance. As it is known, an object size may be appear larger when is captured

closer to the camera and appear small when is captured further. This is due the varying of the

pixels representing the object in the image. As the distance of capturing varies the size of the

object varies accordingly. Similarly, in this case, the pipe may not be exposed to the webcam

at a constant distance, however the system is still required to obtain the crack size

measurement with reasonable accuracy.

Usually, the relationship between the camera distance to the object and the real object

size is obtained by utilizing an additional sensor for distance measurement such as ultrasonic,

IR and etc. Whereas, this system has utilized a reference with a known size in cm to be

detected in the same image as the crack in order to calculate the crack’s real size

measurements in cm with no external distance sensor.

Objectives

This assignment attempts to achieve the vision-based crack detection by achieving the

following objectives:

1. Inspect three different types of crack: as shown in Figure 2, catastrophic, hair line and

corrosion.

2. Measure the value of width and length of the crack.

3. Capture video streaming from the webcam image for crack inspection.

4. Not sensitive to colours, distance, orientation and environment changes.

5. Develop GUI to display the crack detected and update the measurements accordingly.

Figure 2 Types of pipe crack to be detected

Page 7: Crack Inspection - ADR - Advance Robotics - Image processing

Page 6 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Flow Chart

Figure 3 illustrates the flow chart of the program to be developed toward the

achievement of the objectives, where the concept flow of the vision based crack detection

program is obtained.

Figure 3 Vision-based crack detection flow chart

Page 8: Crack Inspection - ADR - Advance Robotics - Image processing

Page 7 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

MATLAB Codes

The vision-based crack detection program has been developed using image processing

toolbox in MATLAB which provides a broad of built-in functions for image processing. The

functions are selected in a way to enable the system to obtain persistent result for all types of

crack at any environment lighting condition with minimum measurement error. The stability

and efficiency of the crack detection system are achieved by appropriate selection of

functions to minimize the computation power while speeding the detection process.

Video Acquisition

Primarily, real time input video has been acquired for inspection using videoinput

function. Videoinput constructs a video input object vid, where 2 represents the device ID

which is a numeric scalar value that identifies the particular device webcam which is

available through the specified adaptor, in this case ‘winvideo’.

The device ID has been identified using imaqhwinfo(‘winvideo’) syntax, in order to

determine the devices available through that specified adaptor. Often, the first available

device ID is used however in this case an external webcam has been used for inspection, for

that reason the device ID has been set as 2.

Once the input video has been acquired, the video displayed using preview function.

Preview creates a preview window that displays live video data from the webcam.

Inspection

The inspection process has been done by taking snaps from the video input to

facilitate image processing for crack detection and measurements. The inspection has been

done using getsnapshot function. Getsnapshot returns a single image frame from the video

input. The captured single image frame is saved as jpeg file using imwrite function

accordingly. Imwrite writes image data snap as I, to the file specified by foto.jpeg in the

same folder.

Once the inspection is done, the stored image snapped from the live video input is

read from the same folder using imread function. Basically, imread reads the image from the

file specified by foto.jpeg while inferring the format of the file from its contents. The I1 is

assigned as the variable to represent the read image throughout the processing.

Page 9: Crack Inspection - ADR - Advance Robotics - Image processing

Page 8 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Image Colour Conversion

As it is shown in Figure 4, the acquired image by default is stored as YCbCr colour,

however, using vision.ColorSpaceConverter system object, the image colour can be

converted into RGB. Vision.ColorSpaceConverter converts the colour information between

colour spaces. The colour space input and output in this case has been assigned as ‘YCbCr to

RGB’ where the converted RGB image is stored in variable I.

Figure 4 Image colour conversion from YCbCr to RGB

Afterwards, the RGB image is converted to grayscale image to enable convenient

processing and enhancement using rgb2gray function. Rgb2gray converts the true colour

image RGB to the grayscale intensity image. Figure 5 represents the converted colour image

to grayscale however not much difference may be visible since the pipe colour is grey and the

crack is black.

Figure 5 Image conversion from RGB to Grayscale

Page 10: Crack Inspection - ADR - Advance Robotics - Image processing

Page 9 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Image Enhancement & Filtering

Image Scaling

Due to the very high sensitivity of the vision-based crack detection to the

environment, before crack detection, the image has been processed and enhance in order to

achieve a stable result with minimum dependency of the environment changes. Basic

arithmetic and logical function have been applied on the image together with filters for

existing noise removal.

Image multiplication by a constant is referred as scaling which is considered as a

common image processing operation. The scaling factor greater than one, scaling brightens

an image; a factor less than one darkens an image. Scaling generally produces a much more

natural brightening/darkening effect than simply adding an offset to the pixels, since it

preserves the relative contrast of the image better. In this case, scaling has enabled processing

the image captured on low lightning condition. Immultiply function effectively minimizes

the dependency of this vision-based crack detection on the environment lighting condition

therefore, obtaining an image output result with minimum noises. Figure 6 represents the

image after scaling process.

Figure 6 Image scaling process before & after

Weiner Filter

Besides, wiener 2 is a low pass filter which is to be applied on grayscale image which

has been degraded by a constant power additive noise. Wiener 2 is used for local processing

which uses a pixelwise adaptive Wiener method based on statics estimated from each pixel

neighbourhood (Gonzales, R. C. & Wintz, P., 1987). This filter forces each pixel to be more

alike to its neighbour and as a result reduces the additive noises while inverts the blurring

Page 11: Crack Inspection - ADR - Advance Robotics - Image processing

Page 10 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

simultaneously. This filter has been used in order to remove the blur and restoration in image

due to poor image acquisition while minimize the additive noises cause by external

conditions.

Figure 7 Weiner filter application process before & after

Median Filter

Moreover, median filter has been used for further noise reduction using function

medfilt2. This function performs median filtering which the output pixel is the result of the

median value in the neighbourhood matrix around the applied pixel. The matrix in this case

has been assigned as [10 10]. Noise reduction performed by median filter is done as a pre-

processing step to improve the image output results of later processing for crack detection

and measurement accordingly. The Figure 8 illustrates the output image after median filter

which has reduces the existing noise.

Figure 8 Median filter application process before & after

Page 12: Crack Inspection - ADR - Advance Robotics - Image processing

Page 11 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Image Adjust and Contrast

The image has been further enhance by imadjust function which is used to increase

the image contrast. Stretchlim function returns a two elements vector containing low and

high pixel values which are used to specify the lower and upper limits to be used for contrast

stretching image. The default value returned by this function is the bottom 1% and the top 1%

of all the pixel values. Figure 9 represents the result image with high contrast which has also

subjected to unwanted noise at the image corners.

Figure 9 Image adjust and high contrast

Once the image has been filtered and enhanced, it is converted from grayscale to

black and white image. Black and while image is a binary image representation using 0 and 1.

Im2bw replaces all pixels value of the input image with luminance greater than level resulted

by threshold function as 1 (white) and all the other pixel blues with 0 (black). The level

resulted by the function graythresh is a global threshold level which is used to convert an

intensity to binary image. The binary image has emphasized the existing noises at the corners

as shown in Figure 10.

Figure 10 Image auto threshold before & after

Page 13: Crack Inspection - ADR - Advance Robotics - Image processing

Page 12 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Image Negative

Once the image has been converted to black and white, it has been negative using “~”.

Negative function will averse the image intensity to opposite. This process is done in order to

assign the cracks as white and the pipe background as black as shown in Figure 11 to proceed

to proceed to further noise reduction and crack detection.

Figure 11 Image negative process before & after

Further Noise Reduction

After the image enhancement and filtering, there may be still noises depending on the

lightening condition which inspection has been performed. The final noise reduction has been

done using bwareaopen function. This function effectively removes any object in the image

which contains connected components fewer than 700 pixel. Since the focus is only

concentrated on crack itself, the other objects detected less than 700 pixels are typically

noises and unwanted lightning effects and reflection of the pipe. As it is shown in Figure 12,

the image noises at corners are now eliminated since their connected components had values

less than 700 pixels. Finally, the output result noiseless image enables for crack detected has

been achieved throughout the enhancement and filtering process.

Figure 12 Image further noise reduction using bwareaopen before & after

Page 14: Crack Inspection - ADR - Advance Robotics - Image processing

Page 13 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Crack Detection

As it has been mentioned earlier, the crack is to be detected together with the inserted

measurement reference. In order to identify and differentiate the crack from the reference

bwconncomp function is used primarily to obtain object detection. This function return the

connected components detected in the binary image. This output structure of this function is

associated with four fields tabulated below in Table 1:

Table 1 bwconncomp function return fields

Field Description

Connectivity Connectivity of the connected components (objects )

ImageSize Size of the black and white image

NumObjects Number of connected components in black and white image (No. objects)

PixelIdxList NumObjects cell array elements index

Figure 13 Command window result return of black & white image confected components

As the result displayed in command window Figure 13, the program can identify two

objects successfully in the processed image which is the crack and the reference. This means

that there is no existing noise or objects are taken into account and the process can be proceed

to crack measurement. In order to differentiate the crack from the detected reference bwlabel

function has been used so that crack length and width can be measured and calculated

accordingly. This function labels the connected objects in the binary image which are

detected as crack in this case. In order to be able to visualize the labels on the image itself

every time it is processed the vislabels function has been used. The Figure 14 shows the

labelled image detecting both crack and reference as object 1 and 2 respectively.

Page 15: Crack Inspection - ADR - Advance Robotics - Image processing

Page 14 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Figure 14 Image objects labelling process before & after

Crack Dimensions Measurement

The crack type detection and dimensions measurement have been achieved by

utilizing the regionprops function. This function returns each connected components or

objects measurements in the binary image. As the result shown in command window Figure

15, the regionprops returns the detected objects specification as an array. The measurements

can be done now by the values returned by this function for each object.

Figure 15 Command window result return of regionprops function

Since the detected reference and crack may not be always in the same position

therefore the area of the both has been compared in order to identify the reference from the

detected crack.

Page 16: Crack Inspection - ADR - Advance Robotics - Image processing

Page 15 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Using if else statement the comparison has been obtained. If detected object 1 area is

less than object 2 area therefore, the object 1 is the reference and the other is the detected

crack. Based on this identification, the calibration factor now can be obtained by dividing the

reference length in cm over its length in pixels obtained by the regionprops at every

distance.

Calibration factor = Reference length (cm)

Reference length (pixel) =

0.35 (cm)

Object 1 Major Axis Length (pixel)

By using the obtained calibration factor, finally the crack length and width is

measured as shown in Figure 16, whereas, the MajorAxisLength as its length and

MinorAxisLength as its width.

Figure 16 Command window result return of crack length and width measurements

Page 17: Crack Inspection - ADR - Advance Robotics - Image processing

Page 16 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Crack Type Detection

In order to identify the type of the crack, the MajorAxisLength of the crack is divided

by the MinorAxisLength of the crack. This ratio is found to be identical for each type of

crack. Using if else statement, the condition of each cracks type has been defined to

determine the crack type. The condition assigned is as follow:

If crack’s MajorAxisLength is greater than twice the MinorAxisLength then it is

considered as a hairline crack type.

If crack’s MajorAxisLength is less than twice the MinorAxisLength and they are not

similar in size then it is considered as a catastrophic crack type.

If crack’s MajorAxisLength and MinorAxisLength are similar in size with difference

of 0.1 then it is considered as a corrosion crack type.

In this case since the crack’s MajorAxisLength is less than twice the crack’s

MinorAxisLength and it’s not similar in size, it is identified to be as catastrophic crack type.

The result displayed in the command window is as follow:

Figure 17 Command window result return of identified crack type

Page 18: Crack Inspection - ADR - Advance Robotics - Image processing

Page 17 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Vision-Based Crack Detection GUI

The GUI developed for this system is to enable the user to be able to inspect the crack

on pipe, detect and monitor the crack type as well as its length and width. The developed GUI

is designed to be user-friendly while providing the essential information about the crack

detected. The Figure 18 represents the GUI of the system which is consists of input video

display, original captured image and final processed labelled image.

Figure 18 Vision-based crack detection developed GUI

There are eight main components used in this graphical user interface to enable vision-

based crack detection. The components are as follow:

1. Inspect Push Button – This button will display the video input for inspection.

2. Detect Push Button – This button is to capture the detected crack for measurement.

3. Input Video Axes – This axes will display the live video input to monitor the pipe.

4. Original Image – This axes represents the captured image when the crack is detected.

5. Final Processed Image – This axes represents the resulted image after processing for

crack detection while labelling the crack and the reference.

6. Crack Type – Shows the detected crack type (hairline, catastrophic and corrosion).

7. Crack Length – Shows the detected crack length, its major axis length in cm.

8. Crack Width – Shows the detected crack width, its minor axis length in cm.

1

2

3 4

5

6

7

8

Page 19: Crack Inspection - ADR - Advance Robotics - Image processing

Page 18 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Discussion & Result

In the developed program, image processing considered as a trial and error process

while achieving the desirable outcome of the image to facilitate accurate crack size

measurement. The values and filters are assigned based on the heuristic manual process while

observing the effects on the results. Often the processing for a type crack considered

applicable while being inappropriate for the other two types of cracks. However, by

adjustment of the assigned values and filter in the program, the desirable outcome could be

achieved for all types of crack. As an example, for hairline crack the bwareaopen pixel value

to be eliminated was set at 500 while this value for the catastrophic crack could not be able to

remove the unwanted small objects and noise accordingly.

Noise is the main factor leading inaccuracies in image processing results. Noise may

be added to the image due to poor image acquisition, improper environment lighting

condition or other external factors. The image is considered inappropriate when it is

associated with noise. To improve the appearance of the image the image processing tools in

MATLAB are used. Mainly filters obtained the significant noise reduction whereas affecting

the contrast and blurriness of the image. For this application, blurriness of the image is not to

be completely undesirable as long as it does not affect the detected crack size by washing out

its edge.

Besides, environment changes effects are also had significant in this detection system.

As mentioned eelier lighting condition of the place system operating at could impact the

result to the point that detection may not achieved. This issue has overcome effectively by

using image scaling process. Scaling refers as image multiplication by a constant to correct

the bad lighting condition causing sharp noises on the pipe. The scaling factor greater than

one, scaling brightens an image; a factor less than one darkens an image. Scaling could be

able to produce a much more natural brightening/darkening effect than simply adding an

offset to the pixels, since it preserved the relative contrast of the image better.

On the other hand, poor image acquisition due to fast movement and inspection could

result in inappropriate picture to enable crack detection and measurements. These undesirable

effects of blurriness and poor acquisition mainly been filtered and adjusted using Weiner

filter. This filter could correct the image appearance enabling the process to be carried on.

Page 20: Crack Inspection - ADR - Advance Robotics - Image processing

Page 19 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

As a result, the developed program and MATLAB codes could be applicable for

detection of any types of crack effectively. Figure 19, illustrates the hairline crack detection

through the GUI which could be able to identify the crack type as Hairline and measure the

crack length and crack width accordingly. The measurements in cm were very close to the

real crack measurements with accuracy:

Forecast Error = Actual Crack Size−Measured Crack Size

Actual Crack Size =

1.9 −1.88

1.9 * 100 = 1.05%

Forecast Accuracy = 100 – 1.05% = 99.9 %

Figure 19 Hairline crack detection and size measurements result through GUI

The same crack type has been exposed to the webcam from various distance between

1 to 6 cm and the result obtained has been stable with 0.1 cm difference. As discussed earlier,

the reference point with a known measurements in cm detected in the same image as the

crack can be measured as a calibration factor in order to calculate the real crack size from

difference distance to camera while obtaining reliable results.

Similarly, the developed vision- based crack detection could obtain the real

measurements for other types of crack without being sensitive to their orientation shape and

Page 21: Crack Inspection - ADR - Advance Robotics - Image processing

Page 20 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

size. Figure 20 shows the corrosion crack detection and Figure 21 shows the catastrophic

crack detection.

The corrosion crack type has been identified and its dimension obtained by the

developed GUI shown in Figure 20. Similarly, the catastrophic crack type has been identified

and its dimensions obtained by the developed GUI successfully shown in Figure 21.

Figure 20 Corrosion crack detection and size measurements result through GUI

Figure 21 Catastrophic crack detection and size measurements result through GUI

Page 22: Crack Inspection - ADR - Advance Robotics - Image processing

Page 21 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Conclusion

In conclusion, the vision based crack detection system is developed using MATLAB

successfully. The system by capturing video input from webcam has been able to inspect,

detect and measure the crack length and width on the pipe accordingly while identify the

crack type. Three different types of crack hairline, catastrophic and corrosion could be

identified and their respective dimensions values in centimetre. The system has been

developed in a way to not to be sensitive to colours, distance, orientation and environment

changes to provide accurate and reliable results. Besides, a user-friendly GUI for the program

has been developed in order to display the detected crack and update the measurements in

real time. Finally, the requirements of this assignment has been met and the vision-based

crack detection objectives achieved effectively. The developed system may be more

enhanced by utilizing more filter however from the efficiency point of view, the objectives of

project may be achieve by considering efficient lines of codes in order to reduce the

computation power while providing a faster process. As a result, the complementation of this

assignment has clarified understanding of image processing and analysis in real world

application.

Page 23: Crack Inspection - ADR - Advance Robotics - Image processing

Page 22 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Reference

Boyle, R., Milan, S. and Vaclav, H. (1993), Image Processing, Analysis, and Machine Vision,

1st Edition, University Press, Cambridge.

Gonzales, R. C. and Wintz, P. (1987), Digital Image Processing, 2nd Edition, Addison-Wesley

Publishing Co., Massachusets.

Ioannis, P. (1993), Digital Image Processing Algorithms, Prentice Hall International (UK)

Ltd., Cambridge.

Olympus Corporation (2015), Pipeline Surface Inspection Technology [online], Available at

http://www.olympus-ims.com/en/applications/stress-corrosion-crack-detection-pipelines-

eddy-current-array/, [Accessed on 5th August 2015]

Page 24: Crack Inspection - ADR - Advance Robotics - Image processing

Page 23 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

Appendix

The developed MATLAB Codes for vision-based crack detection is as follow:

vid = videoinput('winvideo', 2); %Input video acquisition preview(vid); %Display Video I = getsnapshot(vid); %Snap from video input imwrite(I, 'foto.jpeg'); %Save captured image I1 = imread('foto.jpeg'); %Read image file

hcsc = vision.ColorSpaceConverter; %Image colour conversion hcsc.Conversion = 'YCbCr to RGB'; %YCbCr to RGB I = step(hcsc, I1); %Colour converted image i2=rgb2gray(I); %image conversion from rgb to grayscale

i2 = immultiply(i2,4); %Image scaling i2 = immultiply(i2,0.5); %Image scaling

i2 = wiener2(i2); %Weiner low pass filter i2 = medfilt2(i2, [10 10]); %Median filter

i2 = imadjust(i2);

i3=imadjust(i2,stretchlim(i2)); %Image enhancement (High contrast) bw=im2bw(i3,graythresh(i3)); %Convert image grayscale to BW bw1=~bw; %Negative the image

negImage1=bwareaopen(bw1,700); %Remove all object<700 pixels negImage1 =negImage1 * 1/2; %Image Scaling

cc = bwconncomp(negImage1); %Connected components (Crack Detection) L = bwlabel(negImage1); %Lablling the detected objects vislabels(L); %Display the lablling number

S = regionprops(L,'all'); % Connected components measurement

if S(1).Area < S(2).Area % Idnetify the reference from crack

f = 0.35 / S(1).MajorAxisLength ; %Calibration Factor Length = S(2).MajorAxisLength * f; %Crack length Width = S(2).MinorAxisLength * f; %Crack width

set(handles.edit2, 'String', Length) set(handles.edit3, 'String', Width)

Page 25: Crack Inspection - ADR - Advance Robotics - Image processing

Page 24 of 24

Elaheh Shakeri Asia Pacific University of Innovation & Technology TP020832

Advanced Robotics

T = S(2).MajorAxisLength/S(2).MinorAxisLength;

if T >2 set(handles.edit1, 'String', 'Hairline')

end

if T>= 1.1 && T <=2 set(handles.edit1, 'String', 'Catastrophic')

end

if T>= 0.9 && T <=1.1 set(handles.edit1, 'String', 'Corrosion')

end

else

f = 0.35 / S(2).MajorAxisLength ;

Length = S(1).MajorAxisLength * f; Width = S(1).MinorAxisLength * f; set(handles.edit2, 'String', Length) set(handles.edit3, 'String', Width)

T = S(1).MajorAxisLength/S(1).MinorAxisLength;

if T >2 set(handles.edit1, 'String', 'Hairline')

end

if T>= 1.1 && T <=2 set(handles.edit1, 'String', 'Catastrophic')

end

if T>= 0.9 && T <=1.1 set(handles.edit1, 'String', 'Corrosion')

end

end