File Exchange

image thumbnail

Augmented Lagrangian Digital Image Correlation and Tracking

version 4.1.2 (72.6 MB) by Jin Yang
2D-AL-DIC(Augmented Lagrangian DIC) is a fast, parallel-computing DIC algorithm which also considers global kinematic compatibility.


Updated 19 Apr 2021

From GitHub

View Version History

View license on GitHub

AL-DIC is a fast, parallel-computing DIC algorithm, which combines advantages of the Local Subset DIC (fast, compute in parallel) and the FE-based Global DIC (guarantee kinematic compatibility).

For full details, and to use this code, please cite our paper:
Yang, J. and Bhattacharya, K. Exp.Mech. (2019) 59: 187.
or request full text at:

Code manual is available at:

% =========================================
Here I highlight some advantages of AL-DIC algorithm:
• [1] It’s a fast algorithm using distributed parallel computing.
• [2] Global kinematic compatibility is added as a global constraint in the form of augmented Lagrangian, and solved using Alternating Direction Method of Multipliers scheme.
• [3] Both displacement fields and affine deformation gradients are correlated at the same time.
• [4] No need of much manual experience about choosing displacement smoothing filters.
• [5] It works well with compressed DIC images and adaptive mesh. See our paper: Yang, J. & Bhattacharya, K. Exp Mech (2019).;
• [6] Both accumulative and incremental DIC modes are implemented to deal with image sequences, which is especially quite useful for very large deformations.
• [7] ALDIC application example -- uniaxial compression experiment:
• [8] ALDIC is extended with adaptive quadtree mesh to solve complex geometry. Some examples:

% =========================================
ALDIC Matlab code demo:


I also attach my EASF webinar to introduce AL-DIC/DVC algorithm and review other DIC/DVC methods:


% =========================================
Finite-element-based Global DIC code is also available at:

Besides 2D-DIC, our new code "ALDVC" (augmented Lagrangian Digital Volume Correlation) to track deformations in volumetric images is also available:

% =========================================
Contact & support:
I appreciate your comments and ratings to help me further improve this code. If you have other questions, feel free to email me:

Cite As

Yang, J. and Bhattacharya, K. Augmented Lagrangian Digital Image Correlation. Exp.Mech. 59: 187, 2018.

Yang, Jin. Augmented Lagrangian Digital Image Correlation (2D_ALDIC). CaltechDATA, 2020, doi:10.22002/D1.1443.

View more styles

Comments and Ratings (19)



@Jin Yang Thanks for your reply! I'm looking forward to the updates!

Jin Yang

@tmiyam, thank you for the great idea. Yes, I have the plan to extend it to stereo 3D-DIC analysis. Since now I am also funded by other projects, I will keep you posted once it comes out in the near future. If you want more discussion or enrollment, feel free to contact me at:


Hi Dr. Yang. Do you have a plan to expand your code into stereo analysis ?




Jin Yang

@Ahmad Hosseini, thank you for reporting this issue. I checked both MATLAB R2018b, R2019a versions don't this problem. However, I came across the same problem in SECTION 4 as you said when using MATLAB R2020a. I find that this problem happens because of the ba_interp2.cpp mex file, which is originally written by Brian Amberg (cf:, has some inconsistency with updated mex functions in R2020a. To fix this issue for R2020a users, I update this "ba_interp2.cpp" file, so you can re-download this AL-DIC code here or just replace this "ba_interp2.cpp" file from this link: "". Hope this helps!

Ahmad Hosseini

Hello Dr. Yang.Every time I run this code,the SECTION 3 is done without asking any question or showing any messages in command window and the SECTION 4 starts but it gets stuck when this message appears: ''please wait for subproblem 1 IC-GN iterations".then MATLAB crashes and I have to restart the MATLAB.Could you help me?
my MATLAB version is R2020a.

Jin Yang

@Madhan Prabhu Gopi Singaravelu Thank you for the question.

(i) What ALDIC directly solved are displacements (U = x(X) - X) and deformation gradients (F = grad_{X} U = grad_{X} x - I), where x and X are coordinates in deformed and reference configurations. U is stored in ResultDisp, and F is stored in ResultDefGrad.
In 2D DIC, the length of U vector is two times of row# of coordinates (in ResultFEMesh{1}.coordinatesFEM),
and the U vector is assembled by the nodal displacements {u1, v1, u2, v2, … uN, vN};
The length of F vector is four times of row# of coordinates and assembled in the order of {F11(node 1), F21(node 1), F12(node 1), F22(node 1), F11(node 2), F21(node 2), F12(node 2), F22(node 2), … , F11(node N), F21(node N), F12(node N), F22(node N)} .

(ii) With these solved u and F, we compute strains in code Section 8.
For example, if strains are small (<5%), infinitesimal strain is a good option, where exx = F11, eyy = F22, exy = 0.5*(F12+F21). For engineering shear strains, Exx = F11, Eyy = F22, Exy = (F12+F21). For large strain, other finite strain measurements can be computed. In the code, Eluerian strain, Green-Lagrangian strain are also implemented and the code will ask you to choose
“Infinitesimal stran or finite strain?
0: Infinitesimal stran;
1: Eulerian strain;
2: Green-Lagrangian strain;
3: Others: code by yourself; ”.
You can easily modify the code to compute your own defined strains from computed F or FStraintemp.

(iii) Comment about difference between F and FStraintemp.
In code Section 8, you will be also be asked:
What method to use to compute strain?
0: Direct output from ALDIC;
1: Finite difference(Recommended);
2: Plane fitting;
3: Finite element;
If you choose method 0, FStraintemp is exactly the same with F;
If you choose method 1-3, the FStraintemp is re-computed from the computed u. The size of FStraintemp is cropped by ~“Rad” since the strains near the edges are less accurate. The coordinates of FStraintemp are: x0(1+Rad:M-Rad,1+Rad:N-Rad),y0(1+Rad:M-Rad,1+Rad:N-Rad).

Hello Dr. Yang. When i run this code, i receive a final ResultStrain. How is this compared with mechanical strain? Any suggestions?

Jin Yang

@PythonZhou Thank you for posting your question. This problem usually happens when there are too few local subsets get convergence in Subproblem 1 (local step), which breaks down the gridfit function. Could you please check the bad subsets % which is expected to display on the command window. For example, if you have almost 100% bad subsets which means all the subsets are not converged in Subpb 1. Here are three possible steps to fix this problem. (i) In code Section 2, Check parameter of DIC local subset size (DICpara.winsize ). In 2D-DIC, each subset is expected to have at least 3~5 features (e.g. speckle dots) in your DIC pattern. Usually with larger subset size, Subpb 1 will have better convergence. But this subset size cannot be too large since it will also decrease the DIC overall spatial resolution. Theoretically, distance between neighboring subsets can be an arbitrary integer. Considering speed and accuracy, I recommend the winstepsize (DICpara.winstepsize) to be (0.25~1)* winsize (ii) In code Section 3, Check the initial guess (around main_ALIDC.m line 56~64), plot initial guess U0 to see whether this initial guess makes sense or not (U0 = Init(u,v,cc.max,DICmesh.x0,DICmesh.y0,0); PlotuvInit;). Here the newest version of code is to use the multiscale-method (line 60, IntegerSearchMg), if this initial guess doesn't look great, please replace line (60) with line (58), where you can manually define the size of FFT-search zone. (iii) After checking (i-ii), please re-run code Section 4. To see whether each local subset obtains convergence or not, you can uncomment (LocalICGN.m: line 35 (ClusterNo=1) or line 58 (ClusterNo>1)) to display this info message on the command window (However, this will slow down the code). If there are still problems or most subsets still get converged. Feel free to report the error message here or send a pair of your image samples to (


Dr. Yang. When I use this code, it points out that 'Insufficient data for surface estimation.', '[u1temp] = gridfit(coordinatesFEM(notnanindex,1), coordinatesFEM(notnanindex,2),U(2*notnanindex-1),Coordxnodes,Coordynodes,'regularizer','springs'); u1temp = u1temp';' and 'main_ALDIC (line 106)

Could you help me? Thank you very much.

Jin Yang

@James Bezer, Could you please tell me which line you got this error message?

James Bezer

Whenever I run this, at the final step (section 8) I get an error message: "Error using
Value must be a scalar, vector or array of numeric type" I've tried rewriting the code to remove the surf function which it doesn't seem to like, but then the original and strain images are no longer correctly registered. Has anyone else had this problem?

Jin Yang

@Daheng Wei, Have you add all the subfolders ('./src', './plotfiles', ... ) to the matlab path?

Deheng WEI

Sorry to disturb you Dr. Yang. When I go to Section 2 of the 'main_ALDIC.m' after succeeding in Section 1, the error "Undefined function or variable 'ReadImage'." appears. How to solve it? Thank you.

Hao Zhou

Really good code, strongly recommend!


MATLAB Release Compatibility
Created with R2018b
Compatible with R2017b to R2020a
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!