apracticalguidetobiospecklelaseranalysis - non-gnu · apracticalguidetobiospecklelaseranalysis...
TRANSCRIPT
A Practical Guide to Biospeckle Laser Analysis
Theory and Software
Fernando Pujaico Rivera1 and Roberto Alves Braga1
1Universidade Federal de Lavras
Aula-1 2016
Fernando A Practical Guide
Datapack
Datapack
Fernando A Practical Guide
Datapack
Loading a Datapack
1.bmp 2.bmp 3.bmp ... 9.bmp
10.bmp 11.bmp 12.bmp ... 128.bmp
Loading a Datapack
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
Fernando A Practical Guide
Datapack
Loading a Datapack
cafe1.bmp cafe2.bmp cafe3.bmp ... cafe9.bmp
cafe10.bmp cafe11.bmp cafe12.bmp ... cafe128.bmp
Loading a Datapack (Pg. 69)
IMAGESDIR='~/data/cafe-biospeckle/sem2';
DATA=datapack(IMAGESDIR,'cafe',1,128,'bmp');
Fernando A Practical Guide
Datapack
Loading a Datapack
cafe001.bmp cafe002.bmp cafe003.bmp ... cafe009.bmp
cafe010.bmp cafe011.bmp cafe012.bmp ... cafe128.bmp
Loading a Datapack (Pg. 69)
IMAGESDIR='~/data/cafe-biospeckle/sem3';
DATA=datapack(IMAGESDIR,'cafe%03d',1,128,'bmp');
Fernando A Practical Guide
Datapack
Saving a datapack
1.bmp 2.bmp 3.bmp ... 9.bmp ... cafe128.bmp
Saving a datapack (Pg. 70)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
Frames=20;
Ts=0.5;
datapack_to_gif(DATA,'datapack.gif',Frames,gray,Ts);
colormap(’list’)
autumn bone gray ... jet ... winter
Fernando A Practical Guide
Numerical
Numerical
Fernando A Practical Guide
Numerical
THSP
Creating a THSP (Pg. 71)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'column',240);
imagesc(THSP);colormap gray;
20 40 60 80 100 120
100
200
300
400
Fernando A Practical Guide
Numerical
COM
Creating a COM (Pg. 72)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'line',240);
COM=coom(THSP);
imagesc(COM);colormap gray;
50 100 150 200 250
50
100
150
200
250
Fernando A Practical Guide
Numerical
IM
Where the IM moment [3] (IM1) is:
E [(i − j)2] =∑
ij
COM(i , j)∑
lm COM(l ,m)(i − j)2. (1)
And, the IM moment following [2] (IM2) is presented as in theEquation (2),
EAriz .[(i − j)2] =∑
ij
COM(i , j)∑
m COM(i ,m)(i − j)2. (2)
Fernando A Practical Guide
Numerical
IM
Calculating the IM value (Pg. 75)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'line',240);
COM=coom(THSP);
[IM1 IM2]=inertiamoment(COM,2)
IM1 = 359.36IM2 = 1.0547e + 05
Fernando A Practical Guide
Numerical
AVD
Where the AVD first moment [3] (AVD1) is:
E [|i − j |] =∑
ij
COM(i , j)∑
lm COM(l ,m)|i − j | (3)
The AVD second moment (AVD2) is:
E [(i − j)2] =∑
ij
COM(i , j)∑
lm COM(l ,m)(i − j)2 (4)
The AVD second central moment (AVD3) is:
Var [|i − j |] = E [(i − j)2]− E [|i − j |]2 (5)
And the AVD first moment following [2] (AVD4) is:
EAriz .[|i − j |] =∑
ij
COM(i , j)∑
m COM(i ,m)|i − j | (6)
Fernando A Practical Guide
Numerical
AVD
Calculating the AVD value (Pg. 76)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'line',240);
COM=coom(THSP);
[AVD1 AVD2 AVD3 AVD4]=avd(COM,2,3,4)
AVD1 = 13.780AVD2 = 359.36AVD3 = 169.48AVD4 = 3210.4
Fernando A Practical Guide
Numerical
NUMAD
Where the first moment (NUMAD1) is:
E
[
|i − j |
i + j
]
=∑
ij
COM(i , j)∑
lm COM(l ,m)
|i − j |
i + j(7)
And the second moment (NUMAD2) is:
E
[
(
|i − j |
i + j
)2]
=∑
ij
COM(i , j)∑
lm COM(l ,m)
(
|i − j |
i + j
)2
(8)
Fernando A Practical Guide
Numerical
NUMAD
Calculating the NUMAD value (Pg. 80)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'line',240);
COM=coom(THSP);
[NUMAD1 NUMAD2]=numad(COM,2)
NUMAD1 = 0.084686NUMAD2 = 0.013135
Fernando A Practical Guide
Numerical
Correlation
The correlation Cil [10] (Equation 9) is calculated between allpixels THSP(:, i) in the instant i and the pixels THSP(:, i + j) inthe instant i + j ,
Cil = corr(THSP(:, i),THSP(:, i + l)). (9)
The function finally returns, Cl (Equation 10), the mean value ofthis correlations for a lag of l ,
Cl =1
NTIMES/2
NTIMES/2∑
i=1
Cil . (10)
Fernando A Practical Guide
Numerical
Correlation
Calculating the correlation value (Pg. 81)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
THSP=thsp(DATA,'line',240);
[C1 L1] = thsp2corr(THSP,1);
plot(L1,C1,'-o');grid;xlabel('L1');ylabel('C1');
0 10 20 30 40 50 60 700.96
0.97
0.98
0.99
1
L1
C1
Fernando A Practical Guide
Numerical
Spatial-Temporal Correlation
The correlation C lτk0
[11] (Equation 11) is calculated between theimage Ik0 and the image Ik0+l , ∀ 1 ≤ k0 + l ≤ NTIMES. Here it isassumed that the images were taken with sampling rate equal to τ .
C lτk0
= corr(Ik0 , Ik0+l ), (11)
Fernando A Practical Guide
Numerical
Spatial-Temporal Correlation
Calculating the spatial-temporal correlation value [11] (Pg. 82)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
tau=1;
[C T]=stscorr(DATA,tau,42);
-40 -20 0 20 40 60 800.75
0.8
0.85
0.9
0.95
1
k tau
Cor
rela
tion
coef
ficie
nts
Spatial-Temporal Speckle Correlation Technique: k0=42
Fernando A Practical Guide
Graphical
Graphical
Fernando A Practical Guide
Graphical
Fujii
1.bmp 2.bmp 3.bmp ... 9.bmp ... cafe128.bmp
The function in Equation (12) [7, 6] is normalized to Equation(13):
FUJII =
NTIMES−1∑
k=1
|Ik − Ik+1|
Ik + Ik+1 + eps, (12)
Y = FUJII2× 100
NTIMES− 1. (13)
Where NTIMES=128.
Fernando A Practical Guide
Graphical
Fujii
Fujii [7, 6] (Pg. 83)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
FUJII=fujii(DATA);
Fujii Method
100 200 300 400
100
200
300
400
0
10
20
30
40
Fernando A Practical Guide
Graphical
GD
1.bmp 2.bmp 3.bmp ... 9.bmp ... cafe128.bmp
This function implements the Generalized Difference (GD)technique (Equation 14) [1]. It uses, as input data, a 3D matrix(DATA) created by grouping intensity matrices Ik ≡ DATA(:, :, k),1 ≤ k ≤ NTIMES ≡ 128.
GD =
NTIMES−1∑
k=1
NTIMES−k∑
l=1
|Ik − Ik+l | (14)
The function is normalized to Y (Equation 15) with the number ofelements in the sum.
Y =GD
(
NTIMES
2
) (15)
Fernando A Practical Guide
Graphical
GD
Generalized Difference (GD) [1] (Pg. 83)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
Y = gendiff(DATA);
Generalized Difference Method
100 200 300 400
100
200
300
400
0
10
20
30
40
Fernando A Practical Guide
Graphical
C D E
To get the temporal speckle contrast image [9], first it is necessaryto get the temporal speckle mean matrix (Equation 16), µ, as
µ = E [Ik ] =1
NTIMES
NTIMES∑
k=1
Ik , (16)
Then the temporal speckle standard deviation (Equation 17), σ, iscalculates as
σ =√
E [(Ik − µ)2] =
√
√
√
√
1
NTIMES
NTIMES∑
k=1
(Ik − E [Ik ])2. (17)
The temporal speckle contrast image can be calculated as
Contrast =σ
µ(18)
Fernando A Practical Guide
Graphical
C D E
temporal speckle contrast image [9] (Pg. 84)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
[C D E] = stdcont(DATA);
Images: Speckle Mean
100 200 300 400
100
200
300
400
50
100
150
200
Images: Speckle Standard Deviation
100 200 300 400
100
200
300
400
0
10
20
30
40
Images: Speckle Contrast
100 200 300 400
100
200
300
400
0
0.2
0.4
0.6
Fernando A Practical Guide
Graphical
Graphic IM
1.bmp 2.bmp 3.bmp ... 9.bmp ... cafe128.bmp
The function graphim() uses, as input data, a 3D matrix (DATA)created by grouping intensity matrices Ik ≡ DATA(:, :, k),1 ≤ k ≤ NTIMES = 128.
GIM = E [(Ik − Ik+1)2] =
1
NTIMES− 1
NTIMES−1∑
k=1
(Ik − Ik+1)2 (19)
Fernando A Practical Guide
Graphical
Graphic IM
Calculating the IM in graphic mode (Pg. 85)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
GIM = graphim(DATA);
Graphic IM Method
100 200 300 400
100
200
300
400
0
500
1000
1500
2000
Fernando A Practical Guide
Graphical
Graphic AVD
1.bmp 2.bmp 3.bmp ... 9.bmp ... cafe128.bmp
The function graphavd() uses, as input data, a 3D matrix (DATA)created by grouping intensity matrices Ik ≡ DATA(:, :, k),1 ≤ k ≤ NTIMES = 128.
GAVD = E [|Ik − Ik+1|] =1
NTIMES− 1
NTIMES−1∑
k=1
|Ik − Ik+1| (20)
Fernando A Practical Guide
Graphical
Graphic AVD
Calculating the AVD in graphic mode (Pg. 85)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
GIM = graphavd(DATA);
Graphic AVD Method
100 200 300 400
100
200
300
400
0
10
20
30
Fernando A Practical Guide
Graphical
MHI
The calculus of MHI matrix [8, 5], that is the result of applying theMHI technique, can be seen in the Equations (21-24).
Sk = Ik − Ik−1. (21)
Tk(i , j) =
{
1 if |Sk(i , j)| > U
0 if |Sk(i , j)| ≤ U(22)
MHI = 255NTIMES−2∑
i=0
TNTIMES−i hi , (23)
being that
hi =NTIMES− 1− i
M(24)
where NTIMES = 128 and M = NTIMES(NTIMES− 1)/2.
Fernando A Practical Guide
Graphical
MHI
Motion History Image [8, 5] (Pg. 90)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
MHI=graphmhi(DATA,11);
Motion History Image
100 200 300 400
100
200
300
400
Fernando A Practical Guide
Quality Test
Quality Test
Fernando A Practical Guide
Quality Test
Saturation
Saturated and dark zones [4] (Pg. 91)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
IMAGE1=DATA(:,:,1);
WIDTH=8; HEIGHT=8; MINL=20; MAXL=150; PERCENT=50;
[Img S D]=satdark(IMAGE1,WIDTH,HEIGHT,MINL,MAXL,PERCENT);
Preview
100 200 300 400
100
200
300
400
0
50
100
150
200
250
Saturation Zone Image
100 200 300 400
100
200
300
400
0
0.2
0.4
0.6
0.8
1
Dark Zone Image
100 200 300 400
100
200
300
400
0
0.2
0.4
0.6
0.8
1
Fernando A Practical Guide
Quality Test
Contrast
All the pixels in analysis windows are filled with the contrast valueC l [4],
C l =σl
µl, (25)
whereµl =< W l > (26)
and
σl =√
< (W l − µl)2 >. (27)
Fernando A Practical Guide
Quality Test
Contrast
Contrast [4] (Pg. 92)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
IMAGE1=DATA(:,:,1);
WIDTH=8; HEIGHT=8;
[C mC]=sscont(IMAGE1,WIDTH,HEIGHT);
Spatial speckle contrast method - 0.232431.
100 200 300 400
100
200
300
400
0.1
0.2
0.3
0.4
Fernando A Practical Guide
Quality Test
Homogeneity
H(i , j) = 100
(
1−C (i , j)
Cmax
)
, (28)
where the value C (i , j) is calculated as in the Equations (29), (30),(31), and (32),
C (i , j) =σZ (i,j)
µZ (i,j)
, (29)
µZ (i,j) =1
5
∑
l
Z (i ,j)(l), (30)
σ2Z (i,j) =
1
5
∑
l
(Z (i ,j)(l)− µZ (i,j))2, (31)
Z (i ,j) = {A(i , j − 1) A(i − 1, j) A(i , j) A(i + 1, j) A(i , j + 1)}
≡ {Z (i ,j)(0) Z (i ,j)(1) Z (i ,j)(2) Z (i ,j)(3) Z (i ,j)(4)}(32)
Fernando A Practical Guide
Quality Test
Homogeneity
Homogeneity [4] (Pg. 92)
IMAGESDIR='~/data/cafe-biospeckle/sem1';
DATA=datapack(IMAGESDIR,'',1,128,'bmp');
WIDTH=8; HEIGHT=8;
[Y X]=homogeneity(DATA,WIDTH,HEIGHT,0);% 0 - IM
Activity indicator: Inertia Moment
100 200 300 400
100
200
300
400
200
400
600
800
1000
Homogeneity test in analysis windows
100 200 300 400
100
200
300
400
0
20
40
60
80
100
Fernando A Practical Guide
Quality Test
References I
[1] Arizaga, R., Cap, N. L., Rabal, H. J., and Trivi, M. (2002).Display of local activity using dynamical speckle patterns.Optical Engineering, 41(2):287–294.
[2] Arizaga, R., Trivi, M., and Rabal, H. J. (1999). Speckle timeevolution characterization by the co-occurrence matrix analysis.Optics & Laser Technology, 31(2):163 – 169.
[3] Cardoso, R. R. and Braga, R. A. (2014). Enhancement of therobustness on dynamic speckle laser numerical analysis. Opticsand Lasers in Engineering, 63:19–24.
[4] Cardoso, R. R., Braga, R. A., and Rabal, H. J. (2012).Alternative protocols on dynamic speckle laser analysis. Proc.SPIE, 8413:84131F–84131F–6.
Fernando A Practical Guide
Quality Test
References II
[5] Davis, J. W. (2001). Hierarchical motion history images forrecognizing human motion. In Detection and Recognition of
Events in Video, 2001. Proceedings. IEEE Workshop on, pages39–46.
[6] Fujii, H. and Asakura, T. (1975). Statistical properties ofimage speckle patterns in partially coherent light. NouvelleRevue d’Optique, 6(1):5.
[7] Fujii, H., Nohira, K., Yamamoto, Y., Ikawa, H., and Ohura, T.(1987). Evaluation of blood flow by laser speckle image sensing.part 1. Applied Optics, 26(24):5321–5325.
[8] Godinho, R., Silva, M. M., Nozela, J. R., and Braga, R. A.(2012). Online biospeckle assessment without loss of definitionand resolution by motion history image. Optics and Lasers in
Engineering, 50:366–372.
Fernando A Practical Guide
Quality Test
References III
[9] Nothdurft, R. and Yao, G. (2005). Imaging obscuredsubsurface inhomogeneity using laser speckle. Optics Express,13(25):10034–10039.
[10] Xu, Z., Joenathan, C., and Khorana, B. M. (1995). Temporaland spatial properties of the time-varying speckles of botanicalspecimens. Optical Engineering, 34(5):1487–1502.
[11] Zdunek, A., Muravsky, L. I., Frankevych, L., andKonstankiewicz, K. (2007). New nondestructive method basedon spatial-temporal speckle correlation technique for evaluationof apples quality during shelf-life. International Agrophysics,21(3):305–310.
Fernando A Practical Guide