mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Image Padding

Functions for padding images.

These functions pad an image by adding rows and columns, and filling in the new pixels with appropriate values. This can be a constant, or nearest neighbor. A version is also provided which expands an aribtrary 1/0 mask, which is useful when working with, say, circular regions of an image.

template<typename imOutT , typename imInT >
int mx::improc::padImage (imOutT &imOut, imInT &imIn, unsigned int padSz, typename imOutT::Scalar value)
 Pad an image with a constant value. More...
 
template<typename imOutT , typename imInT >
int mx::improc::padImageRef (imOutT imOut, imInT imIn, unsigned int padSz, typename imOutT::Scalar value)
 Pad an image with a constant value for reference types. More...
 
template<typename imOutT , typename imInT >
int mx::improc::padImage (imOutT &imOut, imInT &imIn, unsigned int padSz)
 Pad an image by repeating the values in the edge rows and columns. More...
 
template<typename imOutT , typename imInT >
int mx::improc::padImage (imOutT &imOut, imInT &imIn, imInT &imMask, unsigned int padSz)
 Pad an image by repeating the values at the edge of a 1/0 mask. More...
 
template<typename imOutT , typename imInT >
int mx::improc::cutPaddedImage (imOutT &imOut, const imInT &imIn, unsigned int padSz)
 Cut down a padded image. More...
 

Function Documentation

◆ cutPaddedImage()

template<typename imOutT , typename imInT >
int mx::improc::cutPaddedImage ( imOutT &  imOut,
const imInT &  imIn,
unsigned int  padSz 
)

Cut down a padded image.

Return values
0on success
-1on error
Template Parameters
imOutTis an Eigen-like array
imInTis an Eigen-like array
Parameters
[out]imOutOn return contains the cut image. This will be resized.
[in]imInThe image to be cut down.
[in]padSzThe size of the pad. The output image will be smaller by 2*padSz rows and cols.

Definition at line 273 of file imagePads.hpp.

◆ padImage() [1/3]

template<typename imOutT , typename imInT >
int mx::improc::padImage ( imOutT &  imOut,
imInT &  imIn,
imInT &  imMask,
unsigned int  padSz 
)

Pad an image by repeating the values at the edge of a 1/0 mask.

Allocates imOut to match imMask, and copies imIn to the center multiplied by the mask. Then fills in the new pixels by copying the edge pixels outward. For each pixel on the edge of the mask (touching at least one 1-valued pixel in the mask), the value is chosen as the value of the nearest pixel with a 1 in the mask. If the closest pixels are more than one equidistant pixels, their mean value is used.

Return values
0on success
-1on error
Template Parameters
imOutTis an Eigen-like array
imInTis an Eigen-like array
Parameters
[out]imOutOn return contains the padded image. This will be resized.
[in]imInThe image to be padded.
[in]imMaskThe 1/0 mask image.
[in]padSzThe number of iterations of the padding loop.

Definition at line 174 of file imagePads.hpp.

◆ padImage() [2/3]

template<typename imOutT , typename imInT >
int mx::improc::padImage ( imOutT &  imOut,
imInT &  imIn,
unsigned int  padSz 
)

Pad an image by repeating the values in the edge rows and columns.

Allocates imOut to hold 2*padSz more rows and columns, and copies imIn to the center. Then fills in the new pixels by copying the edge pixels outward.

Return values
0on success
-1on error
Template Parameters
imOutTis an Eigen-like array
imInTis an Eigen-like array
Parameters
[out]imOutOn return contains the padded image. This will be resized.
[in]imInThe image to be padded.
[in]padSzThe size of the pad. The padded image (imOut) will be 2*padSz rows and cols larger than the input.

Definition at line 111 of file imagePads.hpp.

◆ padImage() [3/3]

template<typename imOutT , typename imInT >
int mx::improc::padImage ( imOutT &  imOut,
imInT &  imIn,
unsigned int  padSz,
typename imOutT::Scalar  value 
)

Pad an image with a constant value.

Return values
0on success
-1on error
Template Parameters
imOutTis an Eigen-like array
imInTis an Eigen-like array
Parameters
[out]imOutOn return contains the padded image. This will be resized.
[in]imInThe image to be padded.
[in]padSzThe size of the pad. The padded image (imOut) will be 2*padSz rows and cols larger than the input.
[in]valuethe value to use for padding.

Definition at line 57 of file imagePads.hpp.

Referenced by mx::wfp::idealCoronagraph< _realT >::setPupil().

◆ padImageRef()

template<typename imOutT , typename imInT >
int mx::improc::padImageRef ( imOutT  imOut,
imInT  imIn,
unsigned int  padSz,
typename imOutT::Scalar  value 
)

Pad an image with a constant value for reference types.

This version can be used with Eigen reference types.

Return values
0on success
-1on error
Template Parameters
imOutTis an Eigen-like array reference
imInTis an Eigen-like array reference
Parameters
[out]imOutOn return contains the padded image. This will be resized.
[in]imInThe image to be padded.
[in]padSzThe size of the pad. The padded image (imOut) will be 2*padSz rows and cols larger than the input.
[in]valuethe value to use for padding.

Definition at line 83 of file imagePads.hpp.