Digital Image Correlation Engine  Version 1.0
A modular, high-performance, image correlation tool used to compute full-field displacements and strains from digital images
Public Member Functions | Private Attributes | List of all members
DICe::Image Class Reference

#include <DICe_Image.h>

Public Member Functions

 Image (const char *file_name, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
 Image (const char *file_name, const int_t offset_x, const int_t offset_y, const int_t width, const int_t height, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
 Image (intensity_t *intensities, const int_t width, const int_t height, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
 Image (const int_t width, const int_t height, Teuchos::ArrayRCP< intensity_t > intensities, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null, const int_t offset_x=0, const int_t offset_y=0)
 
 Image (const int_t width, const int_t height, const intensity_t intensity=0.0, const int_t offset_x=0, const int_t offset_y=0)
 
 Image (Teuchos::RCP< Image > img, const int_t offset_x=0, const int_t offset_y=0, const int_t width=-1, const int_t height=-1, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
void initialize_array_image (intensity_t *intensities)
 
void default_constructor_tasks (const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 default constructor tasks
 
void update_image_fields (const char *file_name, const Teuchos::RCP< Teuchos::ParameterList > &params)
 update an already allocated image class with new intensity field and gradients
 
void post_allocation_tasks (const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 post allocation tasks
 
virtual ~Image ()
 virtual destructor
 
void write (const std::string &file_name)
 
void write_overlap_image (const std::string &file_name, Teuchos::RCP< Image > top_img)
 
void write_grad_x (const std::string &file_name)
 
void write_grad_y (const std::string &file_name)
 
int_t width () const
 returns the width of the image
 
int_t height () const
 return the height of the image
 
int_t num_pixels () const
 returns the number of pixels in the image
 
int_t offset_x () const
 returns the offset x coordinate
 
int_t offset_y () const
 returns the offset y coordinate
 
scalar_t mean () const
 returns the mean value of the image
 
const intensity_toperator() (const int_t x, const int_t y) const
 
const intensity_toperator() (const int_t i) const
 
Teuchos::ArrayRCP< intensity_tintensities () const
 returns a copy of the intenisity values as an array
 
Teuchos::ArrayRCP< scalar_tgrad_x_array () const
 returns a copy of the grad_x values as an array
 
Teuchos::ArrayRCP< scalar_tgrad_y_array () const
 returns a copy of the grad_y values as an array
 
void replace_intensities (Teuchos::ArrayRCP< intensity_t > intensities)
 
void interpolate_keys_fourth_all (intensity_t &intensity_val, scalar_t &grad_x_val, scalar_t &grad_y_val, const bool compute_gradient, const scalar_t &local_x, const scalar_t &local_y)
 interpolate intensity and gradients
 
intensity_t interpolate_keys_fourth_global (const scalar_t &global_x, const scalar_t &global_y)
 
intensity_t interpolate_keys_fourth (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_x_keys_fourth (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_y_keys_fourth (const scalar_t &local_x, const scalar_t &local_y)
 
intensity_t interpolate_bilinear_global (const scalar_t &global_x, const scalar_t &global_y)
 
void interpolate_bilinear_all (intensity_t &intensity_val, scalar_t &grad_x_val, scalar_t &grad_y_val, const bool compute_gradient, const scalar_t &local_x, const scalar_t &local_y)
 interpolate intensity and gradients
 
intensity_t interpolate_bilinear (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_x_bilinear (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_y_bilinear (const scalar_t &local_x, const scalar_t &local_y)
 
intensity_t interpolate_bicubic_global (const scalar_t &global_x, const scalar_t &global_y)
 
void interpolate_bicubic_all (intensity_t &intensity_val, scalar_t &grad_x_val, scalar_t &grad_y_val, const bool compute_gradient, const scalar_t &local_x, const scalar_t &local_y)
 interpolate intensity and gradients
 
intensity_t interpolate_bicubic (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_x_bicubic (const scalar_t &local_x, const scalar_t &local_y)
 
scalar_t interpolate_grad_y_bicubic (const scalar_t &local_x, const scalar_t &local_y)
 
const scalar_tgrad_x (const int_t x, const int_t y) const
 
const scalar_tgrad_y (const int_t x, const int_t y) const
 
const scalar_tlaplacian (const int_t x, const int_t y) const
 
const scalar_tmask (const int_t x, const int_t y) const
 
void create_mask (const Conformal_Area_Def &area_def, const bool smooth_edges=true)
 
void apply_mask (const Conformal_Area_Def &area_def, const bool smooth_edges=true)
 
void apply_mask (const bool smooth_edges)
 
Teuchos::RCP< Imageapply_transformation (Teuchos::RCP< Local_Shape_Function > shape_function, const int_t cx, const int_t cy, const bool apply_in_place=false)
 
Teuchos::RCP< Imagenormalize (const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
Teuchos::RCP< Imageapply_rotation (const Rotation_Value rotation, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 
void compute_gradients (const bool use_hierarchical_parallelism=false, const int_t team_size=256)
 compute the image gradients
 
void smooth_gradients_convolution_5_point ()
 compute the image gradients
 
void compute_gradients_finite_difference ()
 compute the image gradients
 
bool has_gradients () const
 returns true if the gradients have been computed
 
bool is_video_frame () const
 returns true if the image is a frame from a video sequence cine or netcdf file
 
bool has_file_name () const
 returns true if the image was created from a file not array
 
bool has_gauss_filter () const
 returns true if the image has been gauss filtered
 
void gauss_filter (const int_t mask_size=-1, const bool use_hierarchical_parallelism=false, const int_t team_size=256)
 filter the image using a 7 point gauss filter
 
void set_file_name (const std::string &file_name)
 sets the file name of the image
 
std::string file_name () const
 returns the name of the file if available
 
void set_file_name (std::string &file_name)
 
scalar_t diff (Teuchos::RCP< Image > rhs) const
 returns the difference of two images:
 
int_t gauss_filter_mask_size () const
 returns the size of the gauss filter mask
 

Private Attributes

int_t width_
 pixel container width_
 
int_t height_
 pixel container height_
 
int_t offset_x_
 
int_t offset_y_
 
Teuchos::ArrayRCP< intensity_tintensity_rcp_
 rcp to the intensity array (used to ensure it doesn't get deallocated)
 
Teuchos::ArrayRCP< intensity_tintensities_
 pixel container
 
Teuchos::ArrayRCP< intensity_tintensities_temp_
 device intensity work array
 
Teuchos::ArrayRCP< scalar_tmask_
 mask coefficients
 
Teuchos::ArrayRCP< scalar_tgrad_x_
 image gradient x container
 
Teuchos::ArrayRCP< scalar_tgrad_y_
 image gradient y container
 
Teuchos::ArrayRCP< scalar_tlaplacian_
 image gradient y container
 
bool has_gradients_
 flag that the gradients have been computed
 
bool has_gauss_filter_
 flag that the image has been filtered
 
scalar_t grad_c1_
 coeff used in computing gradients
 
scalar_t grad_c2_
 coeff used in computing gradients
 
scalar_t gauss_filter_coeffs_ [13][13]
 Gauss filter coefficients.
 
int_t gauss_filter_mask_size_
 Gauss filter mask size.
 
int_t gauss_filter_half_mask_
 half the gauss filter mask size
 
std::string file_name_
 name of the file that was the source of this image
 
bool has_file_name_
 true if the image was read from a file not created from an array
 
Gradient_Method gradient_method_
 gradient method
 

Detailed Description

A container class to hold the pixel intensity information and provide some basic methods Note: the coordinates are from the top left corner (positive right for x and positive down for y) intensity access is always in local coordinates, for example if only a portion of an image is read into the intensity values, accessing the first value in the array is via the indicies (0,0) even if the first pixel is not in the upper left corner of the global image from which the poriton was taken

Constructor & Destructor Documentation

◆ Image() [1/6]

DICe::Image::Image ( const char *  file_name,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

constructor that reads in a whole tiff file

Parameters
file_namethe name of the tiff file
paramsimage parameters

◆ Image() [2/6]

DICe::Image::Image ( const char *  file_name,
const int_t  offset_x,
const int_t  offset_y,
const int_t  width,
const int_t  height,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

constructor that stores only a portion of a tiff file given by the offset and dims

Parameters
file_namethe name of the tiff file
offset_xupper left corner x-coordinate
offset_yupper left corner y-coorindate
widthx-dim of the image (offset_x + width must be < the global image width)
heighty-dim of the image (offset_y + height must be < the global image height)
paramsimage parameters

◆ Image() [3/6]

DICe::Image::Image ( intensity_t intensities,
const int_t  width,
const int_t  height,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

constrtuctor that takes an array as input note: assumes the input array is always stored LayoutRight or "row major"

Parameters
intensitiespre-allocated array of intensity values
widththe width of the image
heightthe height of the image
paramsimage parameters

◆ Image() [4/6]

DICe::Image::Image ( const int_t  width,
const int_t  height,
Teuchos::ArrayRCP< intensity_t intensities,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null,
const int_t  offset_x = 0,
const int_t  offset_y = 0 
)

constructor that takes a Teuchos::ArrayRCP as input note: assumes the input array is always stored LayoutRight or "row major"

Parameters
widthimage width
heightimage height
intensitiesimage intensity values
paramsoptional image parameters
offset_xthe x offset for a sub image
offset_ythe y offset for a sub image

◆ Image() [5/6]

DICe::Image::Image ( const int_t  width,
const int_t  height,
const intensity_t  intensity = 0.0,
const int_t  offset_x = 0,
const int_t  offset_y = 0 
)

constructor that creates a zero image

Parameters
widththe width of the image
heightthe height of the image
intensityvalue to fill the array with
offset_xoffset to upper left corner x coord if this is a subregion of a larger image
offset_yoffset to upper left corner y coord if this is a subregion of a larger image no params allowed since the intensity values are all zeros so gradients or filters would not make sense

◆ Image() [6/6]

DICe::Image::Image ( Teuchos::RCP< Image img,
const int_t  offset_x = 0,
const int_t  offset_y = 0,
const int_t  width = -1,
const int_t  height = -1,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

constructor that takes another image and dims of a sub portion note: no params arg because the parent image's are copied

Parameters
imgthe image to copy
offset_xthe upper left corner x-coord in image coordinates
offset_ythe upper left corner y-coord in image coordinates
widththe width of the sub image
heightthe height of the sub image
paramsimage parameters (for example compute_gradients, etc.)

Member Function Documentation

◆ apply_mask() [1/2]

void DICe::Image::apply_mask ( const bool  smooth_edges)

apply the mask field to the image and sync up the arrays between device and host assumes that the mask field is already populated

Parameters
smooth_edgesuse Gaussian smoothing along the edges

◆ apply_mask() [2/2]

void DICe::Image::apply_mask ( const Conformal_Area_Def area_def,
const bool  smooth_edges = true 
)

creates the image mask and then applies it to the intensity values For the area_def, the boundary defines the outer edge of the region for which the mask will be set to 1.0. For the excluded region within the boundary, the mask will be set to 0.0 mask values will be 1.0 for excluded regions. note: mask coordinates are always global, if the image is a portion of a larger image, the offsets will be applied to the coordinates to align the mask

Parameters
area_defdefines the shape of the mask and what is included/excluded
smooth_edgessmooths the edges of the mask to avoid high freq. content

◆ apply_rotation()

Teuchos::RCP<Image> DICe::Image::apply_rotation ( const Rotation_Value  rotation,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

apply a rotation to this image to create another image in this case, there are only three options 90, 180, and 270 degree rotations

Parameters
rotationenum that defines the rotation
paramsparameters to apply to the new image

◆ apply_transformation()

Teuchos::RCP<Image> DICe::Image::apply_transformation ( Teuchos::RCP< Local_Shape_Function shape_function,
const int_t  cx,
const int_t  cy,
const bool  apply_in_place = false 
)

apply a transformation to this image to create another image

Parameters
shape_functionthe deformation mapping parameters u,v,theta,... (in this case return is null pointer)
cxcentroid of mapping in the current image (used when applying rotation)
cycentroid of mapping in the current image (used when applying rotation)
apply_in_placetrue if the mapped intensity values should replace the existing values in the image

◆ create_mask()

void DICe::Image::create_mask ( const Conformal_Area_Def area_def,
const bool  smooth_edges = true 
)

create the image mask field, but don't apply it to the image For the area_def, the boundary defines the outer edge of the region for which the mask will be set to 1.0. For the excluded region within the boundary, the mask will be set to 0.0 mask values will be 1.0 for excluded regions. note: mask coordinates are always global, if the image is a portion of a larger image, the offsets will be applied to the coordinates to align the mask

Parameters
area_defdefines the shape of the mask and what is included/excluded
smooth_edgessmooths the edges of the mask to avoid high freq. content

◆ grad_x()

const scalar_t& DICe::Image::grad_x ( const int_t  x,
const int_t  y 
) const

gradient accessors: note the internal arrays are stored as (row,column) so the indices have to be switched from coordinates x,y to y,x y is row, x is column

Parameters
ximage coordinate x
yimage coordinate y

◆ grad_y()

const scalar_t& DICe::Image::grad_y ( const int_t  x,
const int_t  y 
) const

gradient accessor for y

Parameters
ximage coordinate x
yimage coordinate y

◆ initialize_array_image()

void DICe::Image::initialize_array_image ( intensity_t intensities)

perform initialization of an image from an array

Parameters
intensitiesthe array of intensity values

◆ interpolate_bicubic()

intensity_t DICe::Image::interpolate_bicubic ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_bicubic_global()

intensity_t DICe::Image::interpolate_bicubic_global ( const scalar_t global_x,
const scalar_t global_y 
)
inline

interpolant

Parameters
global_xglobal image coordinate x
global_yglobal image coordinate y

◆ interpolate_bilinear()

intensity_t DICe::Image::interpolate_bilinear ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_bilinear_global()

intensity_t DICe::Image::interpolate_bilinear_global ( const scalar_t global_x,
const scalar_t global_y 
)
inline

interpolant

Parameters
global_xglobal image coordinate x
global_yglobal image coordinate y

◆ interpolate_grad_x_bicubic()

scalar_t DICe::Image::interpolate_grad_x_bicubic ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_grad_x_bilinear()

scalar_t DICe::Image::interpolate_grad_x_bilinear ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_grad_x_keys_fourth()

scalar_t DICe::Image::interpolate_grad_x_keys_fourth ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_grad_y_bicubic()

scalar_t DICe::Image::interpolate_grad_y_bicubic ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_grad_y_bilinear()

scalar_t DICe::Image::interpolate_grad_y_bilinear ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_grad_y_keys_fourth()

scalar_t DICe::Image::interpolate_grad_y_keys_fourth ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_keys_fourth()

intensity_t DICe::Image::interpolate_keys_fourth ( const scalar_t local_x,
const scalar_t local_y 
)

interpolant

Parameters
local_xlocal image coordinate x
local_ylocal image coordinate y

◆ interpolate_keys_fourth_global()

intensity_t DICe::Image::interpolate_keys_fourth_global ( const scalar_t global_x,
const scalar_t global_y 
)
inline

interpolant

Parameters
global_xglobal image coordinate x
global_yglobal image coordinate y

◆ laplacian()

const scalar_t& DICe::Image::laplacian ( const int_t  x,
const int_t  y 
) const

laplacian accessor: note the internal arrays are stored as (row,column) so the indices have to be switched from coordinates x,y to y,x y is row, x is column

Parameters
ximage coordinate x
yimage coordinate y

◆ mask()

const scalar_t& DICe::Image::mask ( const int_t  x,
const int_t  y 
) const

mask value accessor

Parameters
ximage coordinate x
yimage coordinate y

◆ normalize()

Teuchos::RCP<Image> DICe::Image::normalize ( const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null)

normalize the image intensity values

Parameters
paramsthe image parameters to use

◆ operator()() [1/2]

const intensity_t& DICe::Image::operator() ( const int_t  i) const

intensity accessors: note the internal arrays are stored as (row,column) so the indices have to be switched from coordinates x,y to y,x y is row, x is column

Parameters
ipixel index

◆ operator()() [2/2]

const intensity_t& DICe::Image::operator() ( const int_t  x,
const int_t  y 
) const

intensity accessors: note the internal arrays are stored as (row,column) so the indices have to be switched from coordinates x,y to y,x y is row, x is column

Parameters
ximage coordinate x
yimage coordinate y

◆ replace_intensities()

void DICe::Image::replace_intensities ( Teuchos::ArrayRCP< intensity_t intensities)

replaces the intensity values of the image

Parameters
intensitiesthe new intensity value array

◆ set_file_name()

void DICe::Image::set_file_name ( std::string &  file_name)
inline

set the filename for the image

Parameters
file_namethe string name to use

◆ write()

void DICe::Image::write ( const std::string &  file_name)

write the image to a file (tiff, jpeg, or png, depending on which file extension is used in the name) Tiff, jpeg, and png will truncate the intensity values to an 8-bit integer value and scale the image so that the histogram is spread over the entire 0-255 range. The rawi format saves the full intesity_t precision value to file

Parameters
file_namethe name of the file to write to

◆ write_grad_x()

void DICe::Image::write_grad_x ( const std::string &  file_name)

write the image x gradients to a file (tiff, jpeg, or png, depending on which file extension is used in the name) Tiff, jpeg, and png will truncate the intensity values to an 8-bit integer value and scale the image so that the histogram is spread over the entire 0-255 range. The rawi format saves the full intesity_t precision value to file

Parameters
file_namethe name of the file to write to

◆ write_grad_y()

void DICe::Image::write_grad_y ( const std::string &  file_name)

write the image y gradients to a file (tiff, jpeg, or png, depending on which file extension is used in the name) Tiff, jpeg, and png will truncate the intensity values to an 8-bit integer value and scale the image so that the histogram is spread over the entire 0-255 range. The rawi format saves the full intesity_t precision value to file

Parameters
file_namethe name of the file to write to

◆ write_overlap_image()

void DICe::Image::write_overlap_image ( const std::string &  file_name,
Teuchos::RCP< Image top_img 
)

write an image to file that combines this image and another of the same size with both overlayed using transparency

Parameters
file_namethe name of the file to output
top_imgpointer to the image to be overlayed on top of this one

Member Data Documentation

◆ offset_x_

int_t DICe::Image::offset_x_
private

offsets are used to convert to global image coordinates (the pixel container may be a subset of a larger image)

◆ offset_y_

int_t DICe::Image::offset_y_
private

offsets are used to convert to global image coordinates (the pixel container may be a subset of a larger image)