µDIC: Digital Image Correlation Toolkit

repository·master·Indexed 41 days ago

https://github.com/polymerguy/mudic

A pure-Python toolkit for Digital Image Correlation (DIC) used for experimental data analysis and virtual experiments. It provides tools for image reading, B-spline finite element meshing with a GUI, correlation routines using a non-linear least squares solver, and post-processing for strain calculation. The toolkit includes a 'Virtual Lab' for simulating experiments via speckle generation, image deformation, noise injection, and down-sampling.

Tokens
7.2K
Snippets
30
Records
51
Agent score
52%

What's inside µDIC

  1. Overview of the µDIC toolkit components

    master

    µDIC is a 'batteries included' Python toolkit for Digital Image Correlation (DIC), designed for both experimental data analysis and virtual experiments. The toolkit is organized into several specialized packages:

    • IO-Tools: For handling input and output operations.
    • Virtual Lab: Tools for simulating experimental conditions, including:
      • Speckle generation
      • Image deformation
      • Noise injection
      • Image downsampling
    • Mesh generation: Includes a lightweight GUI for structured meshing and support for B-spline elements (with arbitrary polynomial order and manipulatable knot vectors).
    • Image correlation routines: Implements a non-linear least squares solver.
    • Post processor: Calculates common strain measures and provides lightweight visualization tools.
    • Test suites: Automated function tests to ensure reliability.
  2. Overview of µDIC functionality

    master

    µDIC is a "batteries included" Python toolkit for Digital Image Correlation (DIC), designed for both experimental data analysis and virtual experiments. It is implemented in pure Python (relying on Scipy and Numpy) to ensure transparency and ease of extension.

    Key components include:

    • Image reader tools: For loading experimental data.
    • Virtual lab: Tools for speckle image generation, image deformation, noise injection, and down-sampling.
    • B-spline finite elements: Supports arbitrary polynomial orders and manipulatable knot vectors.
    • Meshing tools: Includes a lightweight GUI for structured meshing.
    • Image correlation routines: Uses a non-linear least squares solver.
    • Post processor: Calculates common strain measures and provides lightweight visualization (including quiver plots for displacements).
  3. Use the Virtual lab to perform virtual tensile tests

    master

    The Virtual lab is a collection of tools designed to simulate virtual tensile tests on speckle patterns. It allows you to combine various effects to create realistic synthetic datasets for Digital Image Correlation (DIC) testing. You can chain together the following capabilities:

    • Speckle Generation: Create patterns using Perlin noise or drop spray methods, with additional tools for blurring.
    • Downsampling: Simulate sensor resolution limits using bi-cubic spline interpolation. Supports configurable downsampling factors, fill-factors, and random pixel offsets.
    • Noise Injection: Add Gaussian noise to simulate sensor artifacts.
    • Image Deformation: Apply arbitrary deformation gradients or complex deformation gradient fields.
    • Virtual Test Orchestration: Use the VirtualTest class to combine all these features into a single workflow.
  4. What is µDIC and why use it?

    master
    µDIC is a pure Python toolkit for Digital Image Correlation (DIC). It is designed to be transparent and easily extensible without requiring deep knowledge of C or C++. It leverages high-performance third-party packages like SciPy and NumPy for its underlying computations, making it accessible for researchers who need to modify or extend the core logic.
  5. What is Digital Image Correlation (DIC)?

    master

    Digital Image Correlation (DIC) is a method used to measure the deformation of an object by analyzing a sequence of images captured during the deformation process.

    Instead of tracking individual points manually, DIC relies on the conservation of optical flow. This fundamental assumption states that the grayscale values of pixels in an initial image ($g$ at position $\boldsymbol{x}_0$) are preserved and simply convected to new positions ($\boldsymbol{x}$) in a subsequent image ($f$).

    Mathematically, the goal is to find $\boldsymbol{x}$ such that:

    $$g(\boldsymbol{x}_0) = f(\boldsymbol{x})$$

    Because the new positions $\boldsymbol{x}$ are often not aligned with the center of a pixel, the routine must use interpolation to determine the grayscale values of $f$ at those non-integer coordinates.

  6. The correlation step and back-warping

    master

    A correlation step aims to find the transformation that makes a deformed image match the original undeformed image.

    The Workflow:

    1. Identify Discrepancy: Subtracting a deformed image $f$ from an undeformed image $g$ ($g(\boldsymbol{x}_0) - f(\boldsymbol{x}_0)$) reveals that grayscale values are not conserved at the original coordinates.
    2. Find Movement: The routine searches for the new positions $\boldsymbol{x}$ where the grayscale values from the original image $g$ can be found in the deformed image $f$.
    3. Back-warping: Once the nodal movement is estimated, the deformed image $f$ is "un-warped." This involves sampling the grayscale values of the deformed image at the calculated new positions $\boldsymbol{x}$ and mapping them back to the original coordinates $\boldsymbol{x}_0$.
    4. Verification: If the correlation is successful, the "un-warped" image should be nearly identical to the original undeformed image $g$.
  7. Simulate image deformation with ImageDeformer

    master

    The ImageDeformer class and its associated functions in muDIC.vlab.image_deformer allow you to apply controlled deformations to images to simulate physical strain or movement.

    Key ways to initialize a deformer include:

    • imageDeformer_from_defGrad: Create a deformer based on a specific deformation gradient.
    • imageDeformer_from_uFunc: Create a deformer based on a user-defined function (uFunc) that describes the displacement field.

    Related utility functions:

    • deformation_gradient: Computes the deformation gradient from displacement data.
    • num_diff: Provides numerical differentiation capabilities required for deformation calculations.
  8. Generate speckle patterns using Sneeze

    master

    Sneeze is an algorithm used to generate synthetic speckle patterns for Digital Image Correlation (DIC). It simulates a spray-painting process by iteratively adding random ink drops to a canvas.

    The algorithm follows these steps:

    1. Initializes an empty canvas.
    2. Generates a random ink drop radius and location.
    3. Appends the drop to the canvas.
    4. Repeats the process for the specified number of drops.
    5. Applies a Gaussian blur to the canvas to round the droplets and simulate realistic speckle morphology.
  9. How finite element discretization works in DIC

    master

    In DIC, tracking every individual pixel's movement is computationally infeasible and noisy because it creates too many unknowns (two coordinate components per pixel) for the available equations (one grayscale conservation equation per pixel).

    To solve this, DIC uses finite element discretization. Instead of treating pixels independently, it assumes pixels move collectively according to an assumed kinematic model.

    The Process:

    1. A mesh of nodes is defined over the image.
    2. The positions of pixels (points) are determined by interpolating the positions of these nodes using shape functions.
    3. The solver's objective is reduced from finding the position of every pixel to finding only the nodal positions (the red dots in a mesh).

    This approach effectively reduces the problem from many unknowns to a few nodal unknowns, while still utilizing the grayscale conservation equations from every pixel to find the best match.

  10. Create an image stack from a list of images

    master

    If you already have a list of image objects loaded in memory, you can convert them into a µDIC image stack using dic.image_stack_from_list(list_of_images).

    import muDIC as dic
    
    # Assuming list_of_images is already defined
    image_stack = dic.image_stack_from_list(list_of_images)
  11. Import images from a folder

    master

    Use dic.image_stack_from_folder(path, filetype=".png") to load all images of a specific type from a directory into a µDIC image stack. The path should be the directory containing the images, and filetype specifies the extension to look for.

    import muDIC as dic
    
    path = r"/the/path/to/the/images/"
    image_stack = dic.image_stack_from_folder(path, filetype=".png")
  12. Run a DIC analysis using DIC_job

    master

    Once you have configured your DIC_settings, you execute the analysis by creating a DIC_job object and calling its .run() method. The results of the entire analysis are returned directly by the .run() method.

    import muDIC as dic
    
    # Assuming settings is already configured
    dic_job = dic.DIC_job(settings)
    results = dic_job.run()