Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

KATHMANDU UNIVERSITY

School of Engineering
Department of Mechanical Engineering
Dhulikhel, Kavrepalanchok

Image Processing and analysis

Tutorial 02

Submitted to
Dr. Ranjit Shrestha
Department of Mechanical Engineering
Kathmandu University

Submitted by
Balkrishna Chaudhary
Exam Roll No.: 41155
Mechanical Engineering (Hydropower)
A square shaped sample of austenitic stainless steel (SUS 316) plate has been taken to simulate
the defects. The plate consists of flat bottom holes where defect mean is to calculate and Signal to
noise ratio (SNR) is to be computed with respected to sound area. The dimension of plate is 180mm
× 180mm and thickness of 10mm. Artificial FBHs of different sizes at varying depth levels were
milled at the rear surface to evaluate the detection capability of the proposed technique. The FBHs
in each column represents the defects with a constant diameter, but of different depth from
uppermost to lowermost row.

Figure 1: Schematic diagram of austenitic steel sample

The flat bottom holes in figure 1 are defined in a way that ‘A’, ‘B’, ‘C’, and ‘D’ represent defects
along the horizontal rows and have different defect diameters. Similarly, ‘1’, ‘2’, ‘3’, and ‘4’
represent the defect size along with vertical columns and have different depths.

Procedure of geometrical operation:

The binary images S1, S2, S3 and S4 is loaded and the images are defined with the name of X1,
X2, X3 and X4 respectively. The images are cropped into the size of [97 15 459 459] defining
with name Y1, Y2, Y3 and Y4 respectively. S3 and S4 are subtracted from S1 and S2 respectively.
The two subtracted value are assigned as I and J. I was divided by J and the result is defined by K.
The phase is calculated using equation(𝑝ℎ𝑖 = 𝑡𝑎𝑛−1 𝑘). The image of phase is then computed to
calculate SNR of defects. The matlab command done to calculate phase is given below:
The phase of combined image is computed is extracted and the defects on sample are seen. The
region of interest of defect and sound area are selected to find SRN of each defect.

Figure 2: Phase of combined image


The region of Interest (ROI) of 10× 10 has been taken on each defect except the holes on 2nd
column. The average defect mean (dmean) of every holes are calculated and average sound mean
(Smean) of sound area is calculated. Standard deviation of average sound mean is then calculated.
The absolute value of difference of dmean and Smean is calculated.

Roipoly has been used to select the polygon of region of interest with in image. Roipoly returns a
binary image that we can use as a mask for masked filtering. BW = roipoly (phi, defx, defy) returns
the region of interest selected by the polygon described by vectors defx and defy. The matlab
command on futher procedure to calculated SNR1 is:
The matlab codes mentioned above have calculated the SNR value of A1 region. SNR of other
defect regions have also been calculated using similar process and codes. The average sound mean
at ROI of center [230, 230] calculated is -1.1185. The standard deviation calculated is 0.0217.
The values calculated in other defect regions of interest while computing with single sound region
have been tabulated below:

Defect Centre of ROI Average mean of abs(dmean-smean) DIV SNR


zone defects ABS
A1 [392,74] -0.6436 0.4750 21.8548 26.7910
A3 [175,74] -0.9687 0.1498 6.8944 16.7699
A4 [75,74] -0.8188 0.2998 13.7931 22.7932
B1 [392,182] -0.9930 0.1256 5.773 15.2350
B3 [175,182] -1.0731 0.0455 2.0929 6.4151
B4 [70,182] -1.0256 0.0927 4.2657 12.5998
C1 [392,290] -0.8091 0.3094 14.2373 23.0685
C3 [175,290] -1.0106 0.1079 4.9664 13.9209
C4 [70,290] -0.9020 0.2615 9.9620 19.9669
D1 [392,400] -0.9174 0.2011 9.2533 19.3260
D3 [172,400] -1.0745 0.0441 2.0275 6.1393
D4 [70,400] -0.9781 0.1404 6.4601 16.2048

The codes used in matlab to find out SRN values of all defects have been mentioned below:

>> load('S1.mat') (Load image)

>> X1=S1; (Assign the name to S1 image as X1)

>> Y1=imcrop(X1,[97 15 459 459]); (crop the image X1 into size of [97 15 459 459])

>> imagesc(Y1),colorbar (Display cropped image Y1)

>> load('S2.mat') (Similar to above commands)

>> X2=S2;

>> Y2=imcrop(X2,[97 15 459 459]);

>> imagesc(Y2),colorbar

>> load('S3.mat')

>> X3=S3;

>> Y3=imcrop(X3,[97 15 459 459]);

>> imagesc(Y3),colorbar

>> load('S4.mat')

>> X4=S4;

>> Y4=imcrop(X4,[97 15 459 459]);

>> imagesc(Y4),colorbar

>> I=imsubtract(Y1,Y3); (Subtract Y1 from Y3)

>> J=imsubtract(Y2,Y4); (Subtrract Y2 from Y4)

>> K=imdivide(I,J); (Divide I by J)

>> phi=atan(K); (𝑝ℎ𝑖 = 𝑡𝑎𝑛−1 𝑘)


>> imagesc(phi),colorbar (Display phase image)

>> defx=[387 387 397 397]; (Define x components of ROI of defect)

>> defy=[69 79 79 69]; (Define y components of ROI of defect)

>> DBW=roipoly(phi,defx,defy); (ROI selected by the polygon with vectors defx and defy)

>> imshow(DBW); (Display the region of interest)

>> dmean=mean(phi(DBW)) (Calculation of Average mean of defective region)

dmean =

-0.6436

>> soundx=[225 225 235 235]; (Define x components of ROI of sound area)

>> soundy=[225 235 235 225]; (Define x components of ROI of sound area)

>> SBW=roipoly(phi,soundx,soundy);

(ROI selected by the polygon with vectors soundx and soundy)

>> imshow(SBW); (Display ROI of sound area)

>> smean=mean(phi(SBW)) (Average mean calculation of sound area ROI)

smean =

-1.1185

>> ABS=abs(dmean-smean) (Calculation of absolute value of dmean and smean difference)

ABS =

0.4750

>> sigma=std2(SBW) (Standard deviation calculation)

sigma =

0.0217
>> DIV=ABS/sigma (Dividing Absoulte value with standard deviation)

DIV =

21.8548

>> SNR1=20*log10(DIV) (Calculatison of SRN value at A1)

SNR1 =

26.7910

>> defx=[170 170 180 180];

>> defy=[69 79 79 69];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.9687

>> ABS=abs(dmean-smean)

ABS =

0.1498

>> DIV=ABS/sigma

DIV =

6.8944

>> SNR3=20*log10(DIV) (Calculation of SRN value at A3)

SNR3 =

16.7699
>> defx=[65 65 75 75];

>> defy=[69 79 79 69];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.8188

>> ABS=abs(dmean-smean)

ABS =

0.2998

>> DIV=ABS/sigma

DIV =

13.7931

>> SNR4=20*log10(DIV) (Calculation of SRN value at A4)

SNR4 =

22.7932

>> imagesc(phi),colorbar

>> defx=[387 387 397 397];

>> defy=[177 187 187 177];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =
-0.9930

>> ABS=abs(dmean-smean)

ABS =

0.1256

>> DIV=ABS/sigma

DIV =

5.7777

>> SNR5=20*log10(DIV) (Calculation of SRN value at B1)

SNR5 =

15.2350

>> imagesc(phi),colorbar

>> defx=[170 170 180 180];

>> defy=[177 187 187 177];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-1.0731

>> ABS=abs(dmean-smean)

ABS =

0.0455

>> DIV=ABS/sigma

DIV =
2.0929

>> SNR6=20*log10(DIV) (Calculation of SRN value at B3)

SNR6 =

6.4151

>> imagesc(phi),colorbar

>> defx=[65 65 75 75];

>> defy=[177 187 187 177];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-1.0258

>> ABS=abs(dmean-smean)

ABS =

0.0927

>> DIV=ABS/sigma

DIV =

4.2657

>> SNR7=20*log10(DIV) ( Calculation of SRN value at B4)

SNR7 =

12.5998

>> imagesc(phi),colorbar

>> defx=[387 387 397 397];


>> defy=[285 295 295 285];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.8091

>> ABS=abs(dmean-smean)

ABS =

0.3094

>> DIV=ABS/sigma

DIV =

14.2373

>> SNR8=20*log10(DIV) ( Calculation of SRN value at C1)

SNR8 =

23.0685

>> imagesc(phi),colorbar

>> defx=[170 170 180 180];

>> defy=[285 295 295 285];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-1.0106
>> ABS=abs(dmean-smean)

ABS =

0.1079

>> DIV=ABS/sigma

DIV =

4.9664

>> SNR9=20*log10(DIV) ( Calculation of SRN value at C3)

SNR9 =

13.9209

>> defx=[65 65 75 75];

>> defy=[285 295 295 285];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.9020

>> ABS=abs(dmean-smean)

ABS =

0.2165

>> DIV=ABS/sigma

DIV =

9.9620

>> SNR10=20*log10(DIV) ( Calculation of SRN value at C4)


SNR10 =

19.9669

>> defx=[387 387 397 397];

>> imagesc(phi),colorbar

>> defy=[395 405 405 395];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.9174

>> ABS=abs(dmean-smean)

ABS =

0.2011

>> DIV=ABS/sigma

DIV =

9.2533

>> SNR11=20*log10(DIV) ( Calculation of SRN value at D1)

SNR11 =

19.3260

>> defx=[170 170 180 180];

>> defy=[395 405 405 395];

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);
>> dmean=mean(phi(DBW))

dmean =

-1.0745

>> ABS=abs(dmean-smean)

ABS =

0.0441

>> DIV=ABS/sigma

DIV =

2.0275

>> SNR12=20*log10(DIV) ( Calculation of SRN value at D3)

SNR12 =

6.1393

>> defx=[65 65 75 75];

>> defy=[395 405 405 395];

>> DBW=roipoly(phi,defx,defy);

>> DBW=roipoly(phi,defx,defy);

>> imshow(DBW);

>> dmean=mean(phi(DBW))

dmean =

-0.9781

>> ABS=abs(dmean-smean)

ABS =

0.1404
>> DIV=ABS/sigma

DIV =

6.4601

>> SNR13=20*log10(DIV) ( Calculation of SRN value at D4)

SNR13 = 16.2048

Comparison of SRN values with respect to depth of hole:

SNR values
30

25

20
SRN Values

15

10

0
0 1 2 3 4 5 6
depth of hole (mm)

Figure 3: SRN values VS. Depth of hole

The figure 3 has been extracted by computing the SRN values of A1, B1, C1 and D1 region. The
sizes of these holes are same but the depth of holes differ. The result of Figure 3 shows that SRN
value decreases with increase in depth of holes.

You might also like