mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
Image Utilities

Useful functions for working with images

Classes

class  mx::improc::sourceFinder< _realT >
 Find stars in an image by SNR thresholding. More...

Functions

template<typename realT>
int mx::improc::circleOuterpix (realT &x0, realT &y0, realT &avgr0, realT &avgx, realT &avgy, realT &avgr, eigenImage< realT > &circ, const eigenImage< realT > &masked)
 Find the center and the outermost pixels of a circular mask, giving an estimate of the radius.
template<typename realT>
constexpr realT mx::improc::invalidNumber ()
 Return the configured invalid image-pixel value.
template<typename realT>
bool mx::improc::isInvalidPixel (realT value)
 Check whether a value represents an invalid image pixel.
template<typename realT>
int mx::improc::reflectImageCoords (int &x1, int &y1, int x0, int y0, realT xc, realT yc)
 Reflect pixel coordinates across the given center pixel.
void * mx::improc::imcpy (void *dest, void *src, size_t width, size_t height, size_t szof)
 Copy one image to another, with no transformation.
void * mx::improc::imcpy_flipUD (void *dest, void *src, size_t width, size_t height, size_t szof)
 Copy one image to another, flipping up-down.
void * mx::improc::imcpy_flipLR (void *dest, void *src, size_t width, size_t height, size_t szof)
 Copy one image to another, flipping left-right.
void * mx::improc::imcpy_flipUDLR (void *dest, void *src, size_t width, size_t height, size_t szof)
 Copy one image to another, flipping up-down and left-right.

Function Documentation

◆ circleOuterpix()

template<typename realT>
int mx::improc::circleOuterpix ( realT & x0,
realT & y0,
realT & avgr0,
realT & avgx,
realT & avgy,
realT & avgr,
eigenImage< realT > & circ,
const eigenImage< realT > & masked )

Find the center and the outermost pixels of a circular mask, giving an estimate of the radius.

Takes a 1/0 mask of a filled circle or annulus, and calculates the center coordinate by center-of-light, then finds the outermost 1 pixel in each row and column. Calculates the average radius of these pixels w.r.t. to the c.o.l. coords, as well as w.r.t. the average coords of the outer pixels themselves.

Also produces an image containing the outer pixels.

Returns
0 on success
Template Parameters
realTthe real floating-point type for calculations
Parameters
y0< [out] x coord of center of the mask by center-of-light
avgr0< [out] y coord of center of the mask by center-of-light
avgx< [out] average radius of edge pixels w.r.t. center-of-light
avgy< [out] x coord of center of the mask by average edge pixel
avgr< [out] y coord of center of the mask by average edge pixel
circ< [out] average radius of edge pixels w.r.t. to average edge pixel
masked< [out] image showing the edge pixels with value 1, all other pixels 0. Resized. < [in] an image with a (roughly) circular mask of 1s

Definition at line 55 of file circleOuterpix.hpp.

References imageCenterOfLight().

◆ imcpy()

void * mx::improc::imcpy ( void * dest,
void * src,
size_t width,
size_t height,
size_t szof )

Copy one image to another, with no transformation.

This is merely memcpy

Returns
dest
Parameters
[out]destthe address of the first pixel in the destination image
[in]srcthe address of the first pixel in the source image
[in]widththe width in pixels of size szof
[in]heightthe height in pixels of size szof
[in]szofthe size in bytes of a one pixel

Definition at line 35 of file imageUtils.cpp.

◆ imcpy_flipLR()

void * mx::improc::imcpy_flipLR ( void * dest,
void * src,
size_t width,
size_t height,
size_t szof )

Copy one image to another, flipping left-right.

Returns
dest
Parameters
[out]destthe address of the first pixel in the destination image
[in]srcthe address of the first pixel in the source image
[in]widththe width in pixels of size szof
[in]heightthe height in pixels of size szof
[in]szofthe size in bytes of a one pixel

Definition at line 50 of file imageUtils.cpp.

◆ imcpy_flipUD()

void * mx::improc::imcpy_flipUD ( void * dest,
void * src,
size_t width,
size_t height,
size_t szof )

Copy one image to another, flipping up-down.

This is a reversed row-by-row memcpy

Returns
dest
Parameters
[out]destthe address of the first pixel in the destination image
[in]srcthe address of the first pixel in the source image
[in]widththe width in pixels of size szof
[in]heightthe height in pixels of size szof
[in]szofthe size in bytes of a one pixel

Definition at line 40 of file imageUtils.cpp.

◆ imcpy_flipUDLR()

void * mx::improc::imcpy_flipUDLR ( void * dest,
void * src,
size_t width,
size_t height,
size_t szof )

Copy one image to another, flipping up-down and left-right.

Returns
dest
Parameters
[out]destthe address of the first pixel in the destination image
[in]srcthe address of the first pixel in the source image
[in]widththe width in pixels of size szof
[in]heightthe height in pixels of size szof
[in]szofthe size in bytes of a one pixel

Definition at line 118 of file imageUtils.cpp.

◆ invalidNumber()

template<typename realT>
realT mx::improc::invalidNumber ( )
constexpr

Return the configured invalid image-pixel value.

The default is a quiet NaN so FITS and image-display tools recognize invalid pixels. Defining MXLIB_INVALID_NUMBER_VALUE at compile time selects that finite value instead. CMake propagates its MXLIB_INVALID_NUMBER_VALUE cache setting through the installed pkg-config metadata.

Returns
the invalid-pixel value for realT

Definition at line 85 of file imageUtils.hpp.

Referenced by isInvalidPixel(), mx::improc::eigenCube< dataT >::mean(), mx::improc::eigenCube< dataT >::mean(), mx::improc::eigenCube< dataT >::median(), mx::improc::eigenCube< dataT >::sigmaMean(), mx::improc::eigenCube< dataT >::sigmaMean(), and TEST_CASE().

◆ isInvalidPixel()

template<typename realT>
bool mx::improc::isInvalidPixel ( realT value)

Check whether a value represents an invalid image pixel.

Detects the configured mxlib invalid-number value as well as NaN and positive or negative infinity. The non-finite classification remains reliable under finite-math-only optimization.

Returns
true if value is invalid, otherwise false.
Parameters
[in]valuevalue to test

Definition at line 103 of file imageUtils.hpp.

References invalidNumber(), and mx::math::isFinite().

Referenced by TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), unitTest::improcTest::eigenCubeTest::TEST_CASE(), zeroNaNCube(), and zeroNaNs().

◆ reflectImageCoords()

template<typename realT>
int mx::improc::reflectImageCoords ( int & x1,
int & y1,
int x0,
int y0,
realT xc,
realT yc )

Reflect pixel coordinates across the given center pixel.

Parameters
[out]x1the reflected x coordinate
[out]y1the reflected y coordinate
[in]x0the input x coordinate
[in]y0the input y coordinate
[in]xcthe center pixel x coordinate
[in]ycthe center pixel y coordinate

Definition at line 118 of file imageUtils.hpp.

Referenced by reflectImageIndices().