File Exchange

image thumbnail

Augmented Lagrangian Digital Image Correlation and Tracking

version 3.4 (71 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 Jul 2020

GitHub view license on GitHub

AL-DIC is a fast, parallel-computing DIC algorithm, which combines advantages of Local Subset DIC (fast, compute in parallel) and 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:

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

% =========================================
Besides 2D-DIC, a new code "AL-DVC" (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 at:

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 (10)

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!




Minor changes: (i)Fix bugs in Section 8 "ComputeStrain.m" to assign ALDIC-direct-computed F; (ii)Fix possible bugs in Section 8 "Plotdisp, Plotstrain, Plotstrain0" in the special conditions when mesh spatial resolution is very fine (stepsize < 4px).


Update manual(v3); update Caltech DATA record.


(i) Correct bugs in Section 3: adaptive initial guess; (ii) Update code licenses;


Update "initial guess fft search method" in an adaptive way, and no need to manually assign search region anymore


(1) Include finite element method in Subproblem 2. (2) Include both accumulative and incremental DIC modes.


Update software filename


Correct typos.


1. Multi-frames image sequence can be loaded automatically. 2. We can Provide output deformation fields with original DIC grayscale images as the background. 3. ALDIC Subproblem 2 can handle both finite difference and finite element scheme.


Update Manual


Change logo image.


Change logo image


Change logo image


Add researchgate paper add


Change folder name.

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