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

Utilities for modeling image formation. More...

Utilities for modeling image formation.

Author
Jared R. Males (jared.nosp@m.male.nosp@m.s@gma.nosp@m.il.c.nosp@m.om)

Definition in file imagingUtils.hpp.

#include <cmath>
#include "../mxlib.hpp"
#include "../improc/eigenImage.hpp"
#include "../math/constants.hpp"
#include "imagingArray.hpp"

Go to the source code of this file.

Namespaces

namespace  mx
 The mxlib c++ namespace.

Functions

template<typename realT>
realT mx::wfp::fftPlateScale (size_t pixels, realT metersPerPixel, realT lambda)
 Calculate the angular plate scale (radians per pixel) of an image after propagation by FFT.
template<class arrayT>
int mx::wfp::circularPupil (arrayT &m, typename arrayT::Scalar eps=0, typename arrayT::Scalar rad=0, typename arrayT::Scalar overscan=0)
 Fill in an Eigen-like array with a circular pupil mask.
template<class arrayT>
void mx::wfp::drawLine (arrayT &im, typename arrayT::Scalar x0, typename arrayT::Scalar y0, typename arrayT::Scalar x1, typename arrayT::Scalar y1, typename arrayT::Scalar halfWidth)
 Draw a line in an image.
template<typename arrayOutT, typename arrayInT>
void mx::wfp::makeComplexPupil (arrayOutT &complexPupil, const arrayInT &realPupil, int wavefrontSizePixels)
 Create a complex pupil plane wavefront from a real amplitude mask.
template<typename arrayOutT, typename arrayInT>
void mx::wfp::makeComplexPupil (arrayOutT &complexWavefront, const arrayInT &realAmplitude, const arrayInT &realPhase, int wavefrontSizePixels)
 Create a complex wavefront from a real amplitude and a real phase.
template<typename wavefrontT>
void mx::wfp::tiltWavefront (wavefrontT &complexWavefront, typename wavefrontT::Scalar::value_type xTilt, typename wavefrontT::Scalar::value_type yTilt)
 Apply a tilt to a wavefront.
template<typename imageT1, typename imageT2>
void mx::wfp::extractBlock (imageT1 &dest, int imX0, int imXsz, int imY0, int imYsz, imageT2 &src, int wfX0, int wfY0)
 Extract a block from one image and insert it into a second.
template<typename imageT1, typename imageT2, typename imageT3>
void mx::wfp::extractMaskedPixels (imageT1 &dest, const imageT2 &src, const imageT3 &mask)
 Extract a pixels from one image and insert them into a second based on a mask.
template<typename realImageT, typename complexImageT, int cudaGPU = 0>
void mx::wfp::extractIntensityImageAccum (realImageT &im, int imX0, int imXsz, int imY0, int imYsz, complexImageT &wf, int wfX0, int wfY0)
 Extract the intensity image from a complex wavefront and accumulate the result.

Function Documentation

◆ drawLine()

template<class arrayT>
void mx::wfp::drawLine ( arrayT & im,
typename arrayT::Scalar x0,
typename arrayT::Scalar y0,
typename arrayT::Scalar x1,
typename arrayT::Scalar y1,
typename arrayT::Scalar halfWidth )

Draw a line in an image.

Todo
should handle width much more intelligently, this only works for ~45 degree lines.
Template Parameters
arrayTis an Eigen-like array with public typedef Scalar
Parameters
im[in.out] The input image, modified.
[in]x0the x value, relative to image center, of the starting point
[in]y0the y value, relative to image center, of the starting point
[in]x1the x value, relative to image center, of the end point
[in]y1the y value, relative to image center, of the end point
[in]halfWidththe half-width of the line.

Definition at line 125 of file imagingUtils.hpp.

◆ extractBlock()

template<typename imageT1, typename imageT2>
void mx::wfp::extractBlock ( imageT1 & dest,
int imX0,
int imXsz,
int imY0,
int imYsz,
imageT2 & src,
int wfX0,
int wfY0 )

Extract a block from one image and insert it into a second.

Parameters
dest[in/out] the image in which to place the extracted block. Must be pre-allocated.
[in]imX0the x/row-coord of the lower left pixel of the destination region.
[in]imXszthe x size (number of rows) of the block
[in]imY0the y/col-coord of the lower left pixel of the desination region
[in]imYszthe y=size (number of cols) ov the block
[in]srcthe source of the block. Must be large enough.
[in]wfX0the x/row-coord of the lower left pixel of the source region
[in]wfY0the y/col-coord of the lower left pixel of the source region

Definition at line 281 of file imagingUtils.hpp.

◆ extractIntensityImageAccum()

template<typename realImageT, typename complexImageT, int cudaGPU = 0>
void mx::wfp::extractIntensityImageAccum ( realImageT & im,
int imX0,
int imXsz,
int imY0,
int imYsz,
complexImageT & wf,
int wfX0,
int wfY0 )

Extract the intensity image from a complex wavefront and accumulate the result.

Can work on a subset of either or both of the image and the wavefront. This way only a small part of the image can be extracted for an oversampled wavefront.

Parameters
[out]imThe real image to populate with intensity
[in]imX0The x-coord of the starting image pixel
[in]imXszThe number of x image pixels
[in]imY0The y-coord of the starting image pixel
[in]imYszThe number of y image pixels
[in]wfThe complex wavefront
[in]wfX0The x-coord of the starting wavefront pixel
[in]wfY0The y-coord of the starting wavefront pixel

◆ extractMaskedPixels()

template<typename imageT1, typename imageT2, typename imageT3>
void mx::wfp::extractMaskedPixels ( imageT1 & dest,
const imageT2 & src,
const imageT3 & mask )

Extract a pixels from one image and insert them into a second based on a mask.

Only pixels with a non-zero value in mask are changed in dest to have the value in src. Other pixels are not modified.

Parameters
dest[in/out] the image in which to place the extracted pixels. Must be the same size as src and mask.
[in]srcthe source of the pixels. Must be the same size as mask.
[in]maskthe mask image, where any value other than 0 indicates a pixel to extract. Must be the same size as src.

Definition at line 315 of file imagingUtils.hpp.

References mx::exception, and mx::sizeerr.