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::Subset Class Reference

Subsets are used to store temporary collections of pixels for comparison between the reference and deformed images. The data that is stored by a subset is a list of x and y corrdinates of each pixel (this allows for arbitrary shape) and containers for pixel intensity values. More...

#include <DICe_Subset.h>

Public Member Functions

 Subset (int_t cx, int_t cy, Teuchos::ArrayRCP< int_t > x, Teuchos::ArrayRCP< int_t > y)
 
 Subset (const int_t cx, const int_t cy, const int_t width, const int_t height)
 
 Subset (const int_t cx, const int_t cy, const Conformal_Area_Def &subset_def)
 
virtual ~Subset ()
 virtual destructor
 
int_t num_pixels () const
 returns the number of pixels in the subset
 
int_t centroid_x () const
 returns the centroid x pixel location
 
int_t centroid_y () const
 returns the centroid y pixel location
 
void update_centroid (const int_t cx, const int_t cy)
 update the centroid of a subset
 
const int_tx (const int_t pixel_index) const
 
const int_ty (const int_t pixel_index) const
 
const scalar_tgrad_x (const int_t pixel_index) const
 
const scalar_tgrad_y (const int_t pixel_index) const
 
bool has_gradients () const
 returns true if the gradients have been computed
 
Teuchos::ArrayRCP< scalar_tgrad_x_array () const
 returns a copy of the gradient x values as an array
 
Teuchos::ArrayRCP< scalar_tgrad_y_array () const
 returns a copy of the gradient x values as an array
 
intensity_tref_intensities (const int_t pixel_index)
 
intensity_tdef_intensities (const int_t pixel_index)
 
void initialize (Teuchos::RCP< Image > image, const Subset_View_Target target=REF_INTENSITIES, Teuchos::RCP< Local_Shape_Function > shape_function=Teuchos::null, const Interpolation_Method interp=KEYS_FOURTH)
 
void write_tiff (const std::string &file_name, const bool use_def_intensities=false)
 
void write_subset_on_image (const std::string &file_name, Teuchos::RCP< Image > image, Teuchos::RCP< Local_Shape_Function > shape_function=Teuchos::null)
 
intensity_t max (const Subset_View_Target target=REF_INTENSITIES)
 
intensity_t min (const Subset_View_Target target=REF_INTENSITIES)
 
scalar_t mean (const Subset_View_Target target)
 
scalar_t mean (const Subset_View_Target target, scalar_t &sum)
 
void round (const Subset_View_Target target)
 round the values in the subset to the nearest integer number
 
scalar_t gamma ()
 returns the ZNSSD gamma correlation value between the reference and deformed subsets
 
scalar_t diff_ref_def () const
 returns the un-normalized difference between the the reference and deformed intensity values
 
scalar_t sssig ()
 returns the SSSIG value for the reference intensities
 
void reset_is_active ()
 reset the is_active bool for each pixel to true;
 
bool & is_active (const int_t pixel_index)
 returns true if this pixel is active
 
int_t num_active_pixels ()
 returns the number of active pixels in the subset
 
bool & is_deactivated_this_step (const int_t pixel_index)
 returns true if this pixel is deactivated for this particular frame
 
void reset_is_deactivated_this_step ()
 reset the is_deactivated_this_step bool for each pixel to false
 
bool is_conformal () const
 True if the subset is not square and has geometry information in a Conformal_Area_Def.
 
const Conformal_Area_Defconformal_subset_def () const
 Returns a pointer to the subset's Conformal_Area_Def.
 
int_t sub_image_id () const
 Return the id of the sub-region of a global image to use.
 
void set_sub_image_id (const int_t id)
 set the sub_image_id
 
scalar_t noise_std_dev (Teuchos::RCP< Image > image, Teuchos::RCP< Local_Shape_Function > shape_function)
 Returns an estimate of the noise standard deviation for this subset based on the method of J. Immerkaer, Fast Noise Variance Estimation, Computer Vision and Image Understanding, Vol. 64, No. 2, pp. 300-302, Sep. 1996 The estimate is computed for a rectangular window that encompases the entire subset if the subset is conformal. More...
 
scalar_t contrast_std_dev ()
 Returns the std deviation of the image intensity values.
 
void turn_off_obstructed_pixels (Teuchos::RCP< Local_Shape_Function > shape_function)
 EXPERIMENTAL Check the deformed position of the pixel to see if it falls inside an obstruction, if so, turn it off. More...
 
void turn_on_previously_obstructed_pixels ()
 EXPERIMENTAL See if any pixels that were obstructed to begin with are now in view, if so use the newly visible intensity values to reconstruct the subset. More...
 
bool is_obstructed_pixel (const scalar_t &coord_x, const scalar_t &coord_y) const
 EXPERIMENTAL Returns true if the given coordinates fall within an obstructed region for this subset. More...
 
std::set< std::pair< int_t, int_t > > * pixels_blocked_by_other_subsets ()
 EXPERIMENTAL Returns a pointer to the set of pixels currently obstructed by another subset.
 
std::set< std::pair< int_t, int_t > > deformed_shapes (Teuchos::RCP< Local_Shape_Function > shape_function=Teuchos::null, const int_t cx=0, const int_t cy=0, const scalar_t &skin_factor=1.0)
 EXPERIMENTAL Return the deformed geometry information for the subset boundary.
 

Private Attributes

int_t num_pixels_
 number of pixels in the subset
 
Teuchos::ArrayRCP< intensity_tref_intensities_
 pixel container
 
Teuchos::ArrayRCP< intensity_tdef_intensities_
 pixel container
 
Teuchos::ArrayRCP< scalar_tgrad_x_
 container for grad_x
 
Teuchos::ArrayRCP< scalar_tgrad_y_
 container for grad_y
 
Teuchos::ArrayRCP< bool > is_active_
 pixels can be deactivated by obstructions (persistent)
 
Teuchos::ArrayRCP< bool > is_deactivated_this_step_
 pixels can be deactivated for this frame only
 
Teuchos::ArrayRCP< int_tx_
 initial x position of the pixels in the reference image
 
Teuchos::ArrayRCP< int_ty_
 initial x position of the pixels in the reference image
 
std::set< std::pair< int_t, int_t > > obstructed_coords_
 EXPERIMENTAL Holds the obstruction coordinates if they exist. NOTE: The coordinates are switched for this (i.e. (Y,X)) so that the loops over y then x will be more efficient.
 
std::set< std::pair< int_t, int_t > > pixels_blocked_by_other_subsets_
 EXPERIMENTAL Holds the pixels blocked by other subsets if they exist. NOTE: The coordinates are switched for this (i.e. (Y,X)) so that the loops over y then x will be more efficient.
 
int_t cx_
 centroid location x
 
int_t cy_
 centroid location y
 
bool has_gradients_
 true if the gradient values are populated
 
Conformal_Area_Def conformal_subset_def_
 Conformal_Area_Def that defines the subset geometry.
 
bool is_conformal_
 The subset is not square.
 
int_t sub_image_id_
 

Detailed Description

Subsets are used to store temporary collections of pixels for comparison between the reference and deformed images. The data that is stored by a subset is a list of x and y corrdinates of each pixel (this allows for arbitrary shape) and containers for pixel intensity values.

Constructor & Destructor Documentation

◆ Subset() [1/3]

DICe::Subset::Subset ( int_t  cx,
int_t  cy,
Teuchos::ArrayRCP< int_t x,
Teuchos::ArrayRCP< int_t y 
)

constructor that takes arrays of the pixel locations as input (note this type of subset has not been enabled for obstruction detection, only conformal subsets with defined shapes have this enabled. See the constructor below with a subset_def argument)

Parameters
cxcentroid x pixel location
cycentroid y pixel location
xarray of x coordinates
yarray of y coordinates

◆ Subset() [2/3]

DICe::Subset::Subset ( const int_t  cx,
const int_t  cy,
const int_t  width,
const int_t  height 
)

constructor that takes a centroid and dims as arguments (note this type of subset has not been enabled for obstruction detection, only conformal subsets with defined shapes have this enabled. See the constructor below with a subset_def argument)

Parameters
cxcentroid x pixel location
cycentroid y pixel location
widthwidth of the centroid (should be an odd number, otherwise the next larger odd number is used)
heightheight of the centroid (should be an odd number, otherwise the next larger odd numer is used)

◆ Subset() [3/3]

DICe::Subset::Subset ( const int_t  cx,
const int_t  cy,
const Conformal_Area_Def subset_def 
)

constructor that takes a conformal subset def as the input

Parameters
cxcentroid x pixel location
cycentroid y pixel location
subset_defthe definition of the subset areas

Member Function Documentation

◆ def_intensities()

intensity_t& DICe::Subset::def_intensities ( const int_t  pixel_index)

ref intensities accessor

Parameters
pixel_indexthe pixel id

◆ grad_x()

const scalar_t& DICe::Subset::grad_x ( const int_t  pixel_index) const

gradient x accessor

Parameters
pixel_indexthe pixel id note there is no bounds checking

◆ grad_y()

const scalar_t& DICe::Subset::grad_y ( const int_t  pixel_index) const

gradient y accessor

Parameters
pixel_indexthe pixel id note there is no bounds checking

◆ initialize()

void DICe::Subset::initialize ( Teuchos::RCP< Image image,
const Subset_View_Target  target = REF_INTENSITIES,
Teuchos::RCP< Local_Shape_Function shape_function = Teuchos::null,
const Interpolation_Method  interp = KEYS_FOURTH 
)

initialization method:

Parameters
imagethe image to get the intensity values from
targetthe initialization mode (put the values in the ref or def intensities)
shape_functioncontains the deformation map (optional)
interpinterpolation method (optional)

◆ is_obstructed_pixel()

bool DICe::Subset::is_obstructed_pixel ( const scalar_t coord_x,
const scalar_t coord_y 
) const

EXPERIMENTAL Returns true if the given coordinates fall within an obstructed region for this subset.

Parameters
coord_xglobal x-coordinate
coord_yglobal y-coordinate

◆ max()

intensity_t DICe::Subset::max ( const Subset_View_Target  target = REF_INTENSITIES)

returns the max intensity value

Parameters
targeteither the reference or deformed intensity values

◆ mean() [1/2]

scalar_t DICe::Subset::mean ( const Subset_View_Target  target)

returns the mean intensity value

Parameters
targeteither the reference or deformed intensity values

◆ mean() [2/2]

scalar_t DICe::Subset::mean ( const Subset_View_Target  target,
scalar_t sum 
)

returns the mean intensity value

Parameters
targeteither the reference or deformed intensity values
sum[output] returns the reduction value of the intensities minus the mean

◆ min()

intensity_t DICe::Subset::min ( const Subset_View_Target  target = REF_INTENSITIES)

returns the min intensity value

Parameters
targeteither the reference or deformed intensity values

◆ noise_std_dev()

scalar_t DICe::Subset::noise_std_dev ( Teuchos::RCP< Image image,
Teuchos::RCP< Local_Shape_Function shape_function 
)

Returns an estimate of the noise standard deviation for this subset based on the method of J. Immerkaer, Fast Noise Variance Estimation, Computer Vision and Image Understanding, Vol. 64, No. 2, pp. 300-302, Sep. 1996 The estimate is computed for a rectangular window that encompases the entire subset if the subset is conformal.

Parameters
imagethe image for which to estimate the noise for this subset
shape_functioncontains the deformation map (optional)

◆ ref_intensities()

intensity_t& DICe::Subset::ref_intensities ( const int_t  pixel_index)

ref intensities accessor

Parameters
pixel_indexthe pixel id

◆ turn_off_obstructed_pixels()

void DICe::Subset::turn_off_obstructed_pixels ( Teuchos::RCP< Local_Shape_Function shape_function)

EXPERIMENTAL Check the deformed position of the pixel to see if it falls inside an obstruction, if so, turn it off.

Parameters
shape_functioncontains the deformation map (optional)

This method uses the specified deformation map to deform the subset to the current position. It then checks to see if any of the deformed pixels fall behind an obstruction. These obstructed pixels are turned off by setting the is_deactivated_this_step_[i] flag to true. These flags are reset on every frame. When methods like gamma() are called on an objective, these pixels get skipped so they do not contribute to the correlation or the optimization routine.

◆ turn_on_previously_obstructed_pixels()

void DICe::Subset::turn_on_previously_obstructed_pixels ( )

EXPERIMENTAL See if any pixels that were obstructed to begin with are now in view, if so use the newly visible intensity values to reconstruct the subset.

Some pixels in the subset may be hidden in the first frame by an obstruction (or another subset that sits on top of this one). As the frames progress, these pixels eventually become visible. This method can be used to evolve the reference subset intensities by taking the intensity value of the pixel when it becomes visible. The location of the pixel in the current frame is not needed because it is assumed that the reference and deformed subset intensity arrays are ordered the same. So all that needs to be checked is if it was deactivated at frame zero, and is now not deactivated this step, that particular pixel can be used.

◆ write_subset_on_image()

void DICe::Subset::write_subset_on_image ( const std::string &  file_name,
Teuchos::RCP< Image image,
Teuchos::RCP< Local_Shape_Function shape_function = Teuchos::null 
)

draw the subset over an image

Parameters
file_namethe name of the tif file to write
imagepointer to the image to use as the background
shape_functioncontains the deformation map (optional)

◆ write_tiff()

void DICe::Subset::write_tiff ( const std::string &  file_name,
const bool  use_def_intensities = false 
)

write the subset intensity values to a tif file

Parameters
file_namethe name of the tif file to write
use_def_intensitiesuse the deformed intensities rather than the reference

◆ x()

const int_t& DICe::Subset::x ( const int_t  pixel_index) const

x coordinate accessor

Parameters
pixel_indexthe pixel id note there is no bounds checking on the index

◆ y()

const int_t& DICe::Subset::y ( const int_t  pixel_index) const

y coordinate accessor

Parameters
pixel_indexthe pixel id note there is no bounds checking on the index

Member Data Documentation

◆ sub_image_id_

int_t DICe::Subset::sub_image_id_
private

if sub regions of the frame are used instead of reading in the whole sub image, this sub_image_id defines which region to draw the pixel information from