mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Functions for masking images.
Functions | |
template<class eigenT > | |
void | mx::improc::radiusImage (eigenT &m, typename eigenT::Scalar xc, typename eigenT::Scalar yc, typename eigenT::Scalar scale=1) |
Fills in the cells of an Eigen 2D Array with their radius from the center. More... | |
template<class eigenT > | |
void | mx::improc::radiusImage (eigenT &m, typename eigenT::Scalar scale=1) |
Fills in the cells of Eigen-like 2D Array with their radius from the canonical center. More... | |
template<class angleT , class eigenT > | |
void | mx::improc::angleImage (eigenT &m, typename angleT::realT xc, typename angleT::realT yc) |
Fills in the cells of an Eigen-like 2D Array with their angle relative to the center. More... | |
template<class angleT , class eigenT > | |
void | mx::improc::angleImage (eigenT &m) |
Fills in the cells of Eigen 2D Array with their angle relative the canonical center. More... | |
template<class angleT , class eigenT1 , class eigenT2 > | |
void | mx::improc::radAngImage (eigenT1 &rIm, eigenT2 &qIm, typename angleT::realT xc, typename angleT::realT yc, typename angleT::realT rscale=1) |
Fills in the cells of Eigen-like arrays with their radius amd angle relative to the center. More... | |
template<typename angleT , typename eigenT1 , typename eigenT2 , typename eigenT3 = eigenT1> | |
std::vector< size_t > | mx::improc::annulusIndices (const eigenT1 &rIm, const eigenT2 &qIm, typename angleT::realT xcen, typename angleT::realT ycen, typename angleT::realT min_r, typename angleT::realT max_r, typename angleT::realT min_q, typename angleT::realT max_q, eigenT3 *mask=0) |
Get the vector indices of an annular region in an image. More... | |
template<typename angleT > | |
void | mx::improc::annulusBoundingRect (int &x0, int &y0, int &x1, int &y1, typename angleT::realT xcen, typename angleT::realT ycen, typename angleT::realT min_r, typename angleT::realT max_r, typename angleT::realT min_q, typename angleT::realT max_q) |
Get the coordinates of the bounding rectangle of an annulus. More... | |
template<class eigenT > | |
void | mx::improc::applyMask (eigenT &maskedIm, const std::vector< size_t > &idx, typename eigenT::Scalar maskval) |
Apply a mask to an image. More... | |
template<class arrayT > | |
void | mx::improc::maskCircle (arrayT &m, typename arrayT::Scalar xcen, typename arrayT::Scalar ycen, typename arrayT::Scalar rad, typename arrayT::Scalar val, typename arrayT::Scalar pixbuf=0.5) |
Mask a circle in an image. More... | |
template<class arrayT > | |
void | mx::improc::maskCircle (arrayT &m, typename arrayT::Scalar rad, typename arrayT::Scalar val, typename arrayT::Scalar pixbuf=0.5) |
Mask a circle in an image at the standard center. More... | |
template<class arrayT > | |
void | mx::improc::maskEllipse (arrayT &m, typename arrayT::Scalar xcen, typename arrayT::Scalar ycen, typename arrayT::Scalar xrad, typename arrayT::Scalar yrad, typename arrayT::Scalar ang, typename arrayT::Scalar val=0, typename arrayT::Scalar pixbuf=0.5) |
Mask an ellipse in an image. More... | |
template<typename realT > | |
int | mx::improc::drawLine (eigenImage< realT > &mask, realT x0, realT y0, realT x1, realT y1, realT val) |
Draw a thin (1-pixel) line from one point to another. More... | |
template<typename realT > | |
int | mx::improc::drawLine (eigenImage< realT > &mask, realT x0, realT y0, realT x1, realT y1, realT width, realT val) |
Draw a thick line from one point to another. More... | |
template<typename imT > | |
int | mx::improc::ccdBleedMask (imT &im, typename imT::Scalar x0, typename imT::Scalar y0, typename imT::Scalar rad, typename imT::Scalar height, typename imT::Scalar lwidth, typename imT::Scalar rwidth) |
Populate a mask based on a typical CCD bleeding pattern. More... | |
template<typename imageTout , typename imageTin > | |
void | mx::improc::cutImageRegion (imageTout &imout, const imageTin &imin, const std::vector< size_t > &idx, bool resize=true) |
Cut out a region of an image specified by an index-mask. More... | |
template<typename imageTout , typename imageTin > | |
void | mx::improc::insertImageRegion (imageTout imout, const imageTin &imin, const std::vector< size_t > &idx) |
Insert a region of an image specified by an index-mask. More... | |
void mx::improc::angleImage | ( | eigenT & | m | ) |
Fills in the cells of Eigen 2D Array with their angle relative the canonical center.
The center is \( (x_c, y_c) = (0.5*(dim_1-1), 0.5*(dim_2 -1)) \).
angleT | is the angle type, either radiansT<realT> or degreesT<realT>. Note that realT sets the type for all arithmetic. |
eigenT | is an Eigen-like 2D array type |
m | < [out] the allocated angle array. Will be filled in with angle values. |
Definition at line 135 of file imageMasks.hpp.
void mx::improc::angleImage | ( | eigenT & | m, |
typename angleT::realT | xc, | ||
typename angleT::realT | yc | ||
) |
Fills in the cells of an Eigen-like 2D Array with their angle relative to the center.
angleT | is the angle type, either radiansT<realT> or degreesT<realT>. Note that realT sets the type for all arithmetic. |
eigenT | is an Eigen-like 2D array type |
[out] | m | the allocated angle array. Will be filled in with angle values. |
[in] | xc | the x center |
[in] | yc | the y center |
Definition at line 105 of file imageMasks.hpp.
void mx::improc::annulusBoundingRect | ( | int & | x0, |
int & | y0, | ||
int & | x1, | ||
int & | y1, | ||
typename angleT::realT | xcen, | ||
typename angleT::realT | ycen, | ||
typename angleT::realT | min_r, | ||
typename angleT::realT | max_r, | ||
typename angleT::realT | min_q, | ||
typename angleT::realT | max_q | ||
) |
Get the coordinates of the bounding rectangle of an annulus.
angleT | is the angle type, either radiansT<realT> or degreesT<realT>. Note that realT sets the type for all arithmetic. |
[out] | x0 | The lower left x-coordinate of the bounding rect. |
[out] | y0 | The lower left y-coordinate of the bounding rect. |
[out] | x1 | The upper right x-coordinate of the bounding rect. |
[out] | y1 | The upper right y-coordinate of the bounding rect. |
[in] | xcen | the x center of the image |
[in] | ycen | the y center of the image |
[in] | min_r | the minimum radius of the region |
[in] | max_r | the maximum radius of the region |
[in] | min_q | the minimum angle of the region. |
[in] | max_q | the maximum angle of the region. |
Definition at line 268 of file imageMasks.hpp.
std::vector<size_t> mx::improc::annulusIndices | ( | const eigenT1 & | rIm, |
const eigenT2 & | qIm, | ||
typename angleT::realT | xcen, | ||
typename angleT::realT | ycen, | ||
typename angleT::realT | min_r, | ||
typename angleT::realT | max_r, | ||
typename angleT::realT | min_q, | ||
typename angleT::realT | max_q, | ||
eigenT3 * | mask = 0 |
||
) |
Get the vector indices of an annular region in an image.
angleT | is the angle type, either radiansT<realT> or degreesT<realT>. Note that realT sets the type for all arithmetic. |
eigenT1 | is an Eigen-like 2D array type. Should be resolved by compiler. |
eigenT2 | is an Eigen-like 2D array type. Should be resolved by compiler. |
eigenT3 | is an Eigen-like 2D array type. Should be resolved by compiler. |
[in] | rIm | a radius image of the type produced by radiusImage |
[in] | qIm | an angle image of the type produce by angleImage |
[in] | xcen | the x center of the image |
[in] | ycen | the y center of the image |
[in] | min_r | the minimum radius of the region |
[in] | max_r | the maximum radius of the region |
[in] | min_q | the minimum angle of the region. |
[in] | max_q | the maximum angle of the region. |
[in] | mask | [optional] pointer to a mask image, only pixels of value 1 are included in the indices. |
Definition at line 194 of file imageMasks.hpp.
void mx::improc::applyMask | ( | eigenT & | maskedIm, |
const std::vector< size_t > & | idx, | ||
typename eigenT::Scalar | maskval | ||
) |
Apply a mask to an image.
The pixels indicated by the indices are set to a value.
eigenT | is an Eigen-like 2D array type |
[out] | maskedIm | the image to mask (will be modified) |
[in] | idx | the indices of the pixels to mask |
[in] | maskval | the mask value. |
Definition at line 385 of file imageMasks.hpp.
int mx::improc::ccdBleedMask | ( | imT & | im, |
typename imT::Scalar | x0, | ||
typename imT::Scalar | y0, | ||
typename imT::Scalar | rad, | ||
typename imT::Scalar | height, | ||
typename imT::Scalar | lwidth, | ||
typename imT::Scalar | rwidth | ||
) |
Populate a mask based on a typical CCD bleeding pattern.
Masks a circle for saturated pixels, as well as a horizontal bar for bleeding (in both directions if needed).
imT | is an Eigen-like 2D array type. |
[out] | im | the mask, on output will be 1/0. Must be allocated prior to call. |
[in] | x0 | the x-coordinate of the center of the mask |
[in] | y0 | the y-coordinate of the center of the mask |
[in] | rad | the radius of the central circle. |
[in] | height | the half-height of the saturation bar. |
[in] | lwidth | the length of the saturation bar to the left. |
[in] | rwidth | the length of the saturation bar to the right. |
Definition at line 732 of file imageMasks.hpp.
void mx::improc::cutImageRegion | ( | imageTout & | imout, |
const imageTin & | imin, | ||
const std::vector< size_t > & | idx, | ||
bool | resize = true |
||
) |
Cut out a region of an image specified by an index-mask.
The output will be a row-image containing the pixel values.
imageTout | is the output image Eigen-like type. |
imageTin | is the input image Eigen-like type. |
[out] | imout | a row-image containing the pixel values specified by the indices. |
[in] | imin | a 2-D image |
[in] | idx | the linear indices of the pixel values |
[in] | resize | [optional] flag controls whether imout is resized. It is if true. |
Definition at line 777 of file imageMasks.hpp.
Referenced by mx::improc::KLIPreduction< _realT, _derotFunctObj, _evCalcT >::regions().
int mx::improc::drawLine | ( | eigenImage< realT > & | mask, |
realT | x0, | ||
realT | y0, | ||
realT | x1, | ||
realT | y1, | ||
realT | val | ||
) |
Draw a thin (1-pixel) line from one point to another.
Calculates the line connecting the two points and sets the pixels along that line to the supplied value.
realT | a real floating point type |
mask | [in.out] [pre-allocated] The array in which to draw the line. | |
[in] | x0 | The x coordinate of the first point |
[in] | y0 | The y coordinate of the first point |
[in] | x1 | The x coordinate of the second point |
[in] | y1 | The y coordinate of the second point |
[in] | val | The value to set on the pixels in the line |
Definition at line 517 of file imageMasks.hpp.
int mx::improc::drawLine | ( | eigenImage< realT > & | mask, |
realT | x0, | ||
realT | y0, | ||
realT | x1, | ||
realT | y1, | ||
realT | width, | ||
realT | val | ||
) |
Draw a thick line from one point to another.
Calculates the line connecting the two points and sets the pixels along that line to the supplied value. Makes the line thick by drawing lines perpindicular to each point with length equal to the specified width.
realT | a real floating point type |
mask | [in.out] [pre-allocated] The array in which to draw the line. | |
[in] | x0 | The x coordinate of the first point |
[in] | y0 | The y coordinate of the first point |
[in] | x1 | The x coordinate of the second point |
[in] | y1 | The y coordinate of the second point |
[in] | width | The desired full-width of the line |
[in] | val | The value to set on the pixels in the line |
Definition at line 611 of file imageMasks.hpp.
void mx::improc::insertImageRegion | ( | imageTout | imout, |
const imageTin & | imin, | ||
const std::vector< size_t > & | idx | ||
) |
Insert a region of an image specified by an index-mask.
Both the input and the output are row-images containing the pixel values.
imageTout | is the output image Eigen-like type. |
imageTin | is the input image Eigen-like type. |
[out] | imout | a row-image into which the pixel values specified by the indices are inserted. |
[in] | imin | a row-image containing the pixel values, same size as idx |
[in] | idx | the linear indices of the pixel values |
Definition at line 805 of file imageMasks.hpp.
Referenced by mx::improc::KLIPreduction< _realT, _derotFunctObj, _evCalcT >::worker().
void mx::improc::maskCircle | ( | arrayT & | m, |
typename arrayT::Scalar | rad, | ||
typename arrayT::Scalar | val, | ||
typename arrayT::Scalar | pixbuf = 0.5 |
||
) |
Mask a circle in an image at the standard center.
The circle is centered at 0.5*(rows-1) and 0.5*(cols-1), and described by its radius. Any value can be set for the mask.
Pixels outside the masked circle are not altered.
arrayT | is an Eigen-like type. |
m | [in.out] the image to be masked, is modified. | |
[in] | rad | the radius of the circle |
[in] | val | the mask value. |
[in] | pixbuf | [optional] buffer for radius comparison. Default is 0.5 pixels. |
Definition at line 440 of file imageMasks.hpp.
void mx::improc::maskCircle | ( | arrayT & | m, |
typename arrayT::Scalar | xcen, | ||
typename arrayT::Scalar | ycen, | ||
typename arrayT::Scalar | rad, | ||
typename arrayT::Scalar | val, | ||
typename arrayT::Scalar | pixbuf = 0.5 |
||
) |
Mask a circle in an image.
The circle is describe by its center coordinates and radius. Any value can be set for the mask. Pixels outside the masked circle are not altered.
arrayT | is an Eigen-like type. |
m | [in.out] the image to be masked, is modified. | |
[in] | xcen | the x coordinate of the center of the circle |
[in] | ycen | the y coordinate of the center of the circle |
[in] | rad | the radius of the circle |
[in] | val | the mask value. |
[in] | pixbuf | [optional] buffer for radius comparison. Default is 0.5 pixels. |
Definition at line 406 of file imageMasks.hpp.
References mx::astro::constants::c().
void mx::improc::maskEllipse | ( | arrayT & | m, |
typename arrayT::Scalar | xcen, | ||
typename arrayT::Scalar | ycen, | ||
typename arrayT::Scalar | xrad, | ||
typename arrayT::Scalar | yrad, | ||
typename arrayT::Scalar | ang, | ||
typename arrayT::Scalar | val = 0 , |
||
typename arrayT::Scalar | pixbuf = 0.5 |
||
) |
Mask an ellipse in an image.
The ellipse is describe by its center coordinates and x and y direction radii (the semi-major and -minor axes, in either order). Any value can be set for the mask, with 0 being the default.
arrayT | is an Eigen-like type. |
m | [in.out] the image to be masked, is modified. | |
[in] | xcen | the x coordinate of the center of the ellipse |
[in] | ycen | the y coordinate of the center of the ellipse |
[in] | xrad | the x radius of the ellipse |
[in] | yrad | the y radius of the ellipse |
[in] | ang | the c.c.w. angle to rotate the ellipse by |
[in] | val | [optional] the mask value. Default is 0. |
[in] | pixbuf | [optional] buffer for radius comparison. Default is 0.5 pixels. |
Definition at line 458 of file imageMasks.hpp.
void mx::improc::radAngImage | ( | eigenT1 & | rIm, |
eigenT2 & | qIm, | ||
typename angleT::realT | xc, | ||
typename angleT::realT | yc, | ||
typename angleT::realT | rscale = 1 |
||
) |
Fills in the cells of Eigen-like arrays with their radius amd angle relative to the center.
angleT | is the angle type, either radiansT<realT> or degreesT<realT>. Note that realT sets the type for all arithmetic. |
eigenT1 | is an Eigen-like 2D array type. Should be resolved by compiler. |
eigenT2 | is an Eigen-like 2D array type. Should be resolved by compiler. |
[out] | rIm | the allocated radius array, will be filled in with radius values. |
[out] | qIm | the angle array, will be re-sized to match rIm. Will be filled in with angle values. |
[in] | xc | the x center |
[in] | yc | the y center |
[in] | rscale | [optional] a scaling to apply to each radius value. Default is 1.0. |
Definition at line 155 of file imageMasks.hpp.
void mx::improc::radiusImage | ( | eigenT & | m, |
typename eigenT::Scalar | scale = 1 |
||
) |
Fills in the cells of Eigen-like 2D Array with their radius from the canonical center.
The center is \( (x_c, y_c) = (0.5*(dim_1-1), 0.5*(dim_2 -1)) \).
eigenT | is an Eigen-like 2D array type |
[out] | m | the allocated radius array, will be filled in with radius values. |
[in] | scale | [optional] a scaling to apply to each value (default = 1) |
Definition at line 84 of file imageMasks.hpp.
void mx::improc::radiusImage | ( | eigenT & | m, |
typename eigenT::Scalar | xc, | ||
typename eigenT::Scalar | yc, | ||
typename eigenT::Scalar | scale = 1 |
||
) |
Fills in the cells of an Eigen 2D Array with their radius from the center.
eigenT | is an Eigen-like 2D array type |
[out] | m | the allocated radius array, will be filled in with radius values. |
[in] | xc | the x center |
[in] | yc | the y center |
[in] | scale | [optional] a scaling to apply to each value (default = 1) |
Definition at line 49 of file imageMasks.hpp.
Referenced by mx::improc::radprof(), mx::improc::radprofim(), mx::improc::aperturePhotometer< realT >::resize(), mx::improc::stddevImage(), and mx::improc::stddevImageCube().