# Solver stability issues in DIC.jl

I have been working on a functional Digital Image Correlation program in the Julia language. The approach seeks to find 2 mathematical functions (in particular polynomials) to approximate the displacement field. (One of the functions predicts x displacement, the other y displacement). The idea is that the displacement is very simple in the space-time domain, and could be represented by a small set of polynomial parameters. Anything that isn't simple (like a tear) would not be represented well in this domain. One feature is that strain rate heat maps will be extremely easy to create, which is of interest in the high strain rate testing domain. The data I am working with is that of a twisting motion to produce a torsional stress on a tube. Force is imparted as displayed below.

The algorithm works as follows: a test set of local neighborhoods is constructed using Sobol sampling in the region of interest, with neighborhoods iteratively assigned to frames. A cost function for the polynomial parameters is constructed as follows:

- Combine parameters and model to form prediction polynomial
- Iterate through local area samples
- Predict a location in a projected image for each polynomial
- Measure the distance between the values of the original image and the predicted results, where bicubic interpolation is used to determine predicted pixel values

Then, a numerical optimization is run on the polynomial parameters to minimize the constructed cost function. Since a gradient cannot be established easily because of the discrete video samples, we selected the Nelder-Mead approach.

There are some convergence issues with the selected approach. Often, the algorithm will go offroading, probably due to a flat error function outside of a local neighborhood. Here is an example of what the error function might look like:

This can create some interesting "art," as the polynomial coefficients end up predicting totally crazy results. Clearly, some fine-tuning is needed.

## Road forward

The way forward is to build a better error function. This can be done by using classical DIC techniques to get close approximations of pixels. Discussions with Alex Hirzel led me to adopt a technique where the pixel close error function would be used to pre-optimize the polynomial coefficients so that the optimization reaches the correct global minimum.

## Why Julia for this project?

Julia has some excellent packages to make this fairly easy to implement. First, there is the Dynamic Polynomials package, which allows for multivariate polynomials to be expressed easily and evaluated. The Optim solver library had a fairly simple to use interface, though there is not multithreaded Nelder-Mead (If I want it I should write it, I know). The Interpolations package was extremely helpful in providing fast and high order interpolations of image data.