DICpy.DIC_2D¶
The module DIC_2D of DICpy contain classes for performing 2D digital image correlation with Python. The module follows the objected-oriented paradigm and the DIC is performed following a sequence of object instantiation. Next, a detailed description of each class is presented.
DICpy.DIC_2D.Images¶
- class DICpy.DIC_2D.Images[source]¶
Bases:
objectThis class contains the methods for reading and processing images used in digital image correlation (DIC). Input: Attributes:
- path_speckle (str)
Path to the speckle images.
- path_calibration (str)
Path to the calibration image.
- ref_image (ndarray)
Reference image.
- calibration_image (ndarray)
Calibration image.
- images (ndarray)
Gray images.
- images_normalized (ndarray)
Gray images normalized by 255.
- lx (int)
Number of columns of each image.
- ly (int)
Number of rows of each image.
- num_img (int)
Number of images.
- pixel_dim (float)
Size of each pixel in length dimension.
Methods:
- calibration(ref_length=None, pixel_dim=None, path=None, file_name=None, point_a=None, point_b=None, verbose=True)[source]¶
Method for the analysis calibration.
Input: * ref_length (str)
Length used as reference.
- pixel_dim (float)
Size of each pixel in length dimension.
- path (str)
Path for the calibration image used in the DIC analysis.
- file_name (str)
Name of the calibration image.
- point_a (float)
First corner of the region of interest (ROI).
- point_b (float)
Corner opposed to point_b of the region of interest (ROI).
- verbose (bool)
Boolean variable to print some information on screen.
Output/Returns:
- read_speckle_images(path=None, extension=None, file_names=None, ref_id=0, verbose=False)[source]¶
Read the speckle images.
Input: * path (str)
Path for the images used in the DIC analysis.
- extension (str)
The extension of the files located in path.
- file_names (str)
Define the files to be read in the sequence of your preference.
- ref_id (int)
Define a file to be used as reference, the default is zero, which means that the first image in the stack will be used as reference.
- verbose (bool)
Boolean varible to print some information on screen.
Output/Returns:
DICpy.DIC_2D.RegularGrid¶
- class DICpy.DIC_2D.RegularGrid(images_obj=None)[source]¶
Bases:
objectThis class contains the methods for creating a rectangular grid used in the DIC analysis.
Input: * images_obj (object)
Object containing the speckle images, reference images, and calibration images, as well as calibration parameters.
Attributes: * images_obj (object)
Object containing the speckle images, reference images, and calibration images, as well as calibration parameters.
- stepx (ndarray)
Steps for the grid in the x direction (columns).
- stepy (ndarray)
Steps for the grid in the y direction (rows).
- centers (list)
Center of each cell in the grid.
- wind (list)
Dimensions in both x and y dimensions of each cell.
- xp (ndarray)
Position of the upper right corner of each cell (grid in the x direction - columns).
- yp (ndarray)
Position of the upper right corner of each cell (grid in the y direction - rows).
- nx (int)
Number of nodes in the x direction (columns).
- ny (int)
Number of nodes in the y direction (rows).
- point_a (float)
First corner of the region of interest (ROI).
- point_b (float)
Opposed corner of the region of interest (ROI).
Methods:
- define_mesh(point_a=None, point_b=None, nx=2, ny=2, show_grid=False)[source]¶
Method to construct the rectangular grid used in the DIC analysis.
Input: * point_a (float)
First corner of the region of interest (ROI).
- point_b (float)
Corner opposed to point_b of the region of interest (ROI).
- nx (int)
Number of nodes in the x direction (columns), default 2.
- ny (int)
Number of nodes in the y direction (rows), default 2.
- show_grid (int)
This functionality is only available when point_a and point_b are provided. When noplot is True, the grid is not plotted for express calculations.
Output/Returns:
DICpy.DIC_2D.ImageRegistration¶
- class DICpy.DIC_2D.ImageRegistration(mesh_obj=None)[source]¶
Bases:
objectThis class has the methods to perform the DIC analysis with integer resolution. This is a parent class for children classes implementing methods with subpixel resolution.
Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
Methods:
DICpy.DIC_2D.Oversampling¶
- class DICpy.DIC_2D.Oversampling(mesh_obj=None, over_x=1, over_y=1)[source]¶
Bases:
DICpy.DIC_2D._image_registration.ImageRegistrationDIC with subpixel resolution using oversampling.
Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
- over_x (int)
Parameter used for oversampling in the x direction (columns).
- over_y (int)
Parameter used for oversampling in the y direction (rows).
Methods:
DICpy.DIC_2D.GradientZero¶
- class DICpy.DIC_2D.GradientZero(mesh_obj=None, max_iter=20, tol=0.001)[source]¶
Bases:
DICpy.DIC_2D._image_registration.ImageRegistrationDIC with subpixel resolution using gradients. This class implement a method using zeroth order shape functions, and It is a child class of ImageRegistration.
Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
- max_iter (ndarray)
Maximum number of iterations in the optimization process.
- tol (ndarray)
Error tolerance in the optimization process.
Methods:
DICpy.DIC_2D.GradientOne¶
- class DICpy.DIC_2D.GradientOne(mesh_obj=None, max_iter=20, tol=0.001)[source]¶
Bases:
DICpy.DIC_2D._image_registration.ImageRegistrationDIC with subpixel resolution using gradients. This class implement a method using zeroth order shape functions, and It is a child class of ImageRegistration.
Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
- max_iter (ndarray)
Maximum number of iterations in the optimization process.
- tol (ndarray)
Error tolerance in the optimization process.
Methods:
DICpy.DIC_2D.CoarseFine¶
- class DICpy.DIC_2D.CoarseFine(mesh_obj=None, niter=1)[source]¶
Bases:
DICpy.DIC_2D._image_registration.ImageRegistrationDIC with subpixel resolution using an coarse-fine search approach as presented in the following paper:
“An advanced coarse-fine search approach for digital image correlation applications.”
(By: Samo Simoncic, Melita Kompolsek, Primoz Podrzaj)
Further, this class is a child class of
ImageRegistration, and it inherit the method run and override _registration.Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
niter (int)
Number of iterations in the coarse-fine algorithm.
Methods:
DICpy.DIC_2D.LucasKanade¶
- class DICpy.DIC_2D.LucasKanade(mesh_obj=None)[source]¶
Bases:
DICpy.DIC_2D._image_registration.ImageRegistrationDIC with subpixel resolution using the Lucas-Kanade algorithm implemented in OpenCV-Python, and It is a child class of ImageRegistration.
Input: * mesh_obj (object)
Object of
RegularGrid.Attributes:
- pixel_dim (float)
Constant to convert pixel into a physical quantity (e.g., mm).
- mesh_obj (object)
Object of the
RegularGrid.
- u (ndarray)
Displacements in the x (columns) dimension at the center of each cell.
- v (ndarray)
Displacements in the y (rows) dimension at the center of each cell.
Methods:
DICpy.dic2d.PostProcessing¶
- class DICpy.DIC_2D.PostProcessing(analysis_obj=None)[source]¶
Bases:
objectThis class contains the methods for visualizing the results of the DIC analysis. Input: * analysis_obj (object)
Object of the Analysis class.
Attributes:
- analysis_obj (float)
Object of the Analysis class.
- mesh_obj (object)
Object of the RectangularMesh class.
- strain11 (ndarray)
Strain xx at the center of each cell.
- strain22 (ndarray)
Strain yy at the center of each cell.
- strain12 (ndarray)
Strain xy at the center of each cell.
- strain21 (ndarray)
Strain yx (equal to Strain xy) at the center of each cell.
Methods:
- visualization(results='u', step=0, smooth=False)[source]¶
Method to plot the results in terms of displacements and strains.
Input: * results (str)
Visulaize the results: -‘u’: displacement x. -‘v’: displacement y. -‘e11’: strain xx. -‘e22’: strain yy: -‘e12’: strain xy. -‘e21’: strain yx.
- step (int)
Load step of interest.
- smooth (bool)
Gaussian filtering.
Output/Returns:
DICpy.DIC_2D.Synthetic¶
- class DICpy.DIC_2D.Synthetic(num_images=None, size=None, extension='png', random_state=None, save_images=True)[source]¶
Bases:
objectThis class contains the methods for generate synthetic data for the DIC analysis. Input:
Attributes:
- num_images (int)
Number of images.
- size (tuple)
Images shapse.
- extension (str)
Extension to save the files.
- random_state (int)
Random seed
- save_images (bool)
Boolean variable to save the generated images.
Methods:
- generate_images(num_speckles=100, sigma=2, displacement_x=None, displacement_y=None, shear=None)[source]¶
Generate images.
Input: * num_speckles (int)
Number of speckles per images.
- sigma (float)
Variable to control the size the speckles.
- displacement_x (list)
Displacement x to include in each image.
- displacement_y (list)
Displacement y to include in each image.
- shear (list)
Shear to include in each image.
Output/Returns: