Core 1.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ScalarField2 Class Reference

A base two-dimensional field of real values. More...

#include <scalarfield.h>

Inheritance diagram for ScalarField2:
Array2 Box2

Public Member Functions

 ScalarField2 ()
 Empty.
 
 ScalarField2 (const Array2 &, const double &=0.0)
 Create the field structure. More...
 
 ScalarField2 (const Box2 &, int, int, const double &=0.0)
 Create the field structure. More...
 
 ScalarField2 (const Box2 &, int, int, const QVector< double > &)
 Create the field structure. More...
 
 ScalarField2 (const Box2 &, const QImage &, const double &=0.0, const double &=256.0 *256.0 - 1.0, bool=true)
 Create a field structure from an image. More...
 
 ScalarField2 (const QImage &, const double &=1.0, const double &=1.0, bool=true)
 Create a field structure from an image. More...
 
 ScalarField2 (const QString &, double=0.0, double=1.0)
 Create a field structure from an image. More...
 
 ~ScalarField2 ()
 Empty.
 
Array2 GetArray () const
 Return the array representing the grid domain.
 
void GetRange (double &, double &) const
 Get the range of the field. More...
 
double Integral () const
 Get the integral of the scalar field. More...
 
double Sum () const
 Compute the sum of the elements in the scalar field. More...
 
double Average () const
 Compute the average value of the elements in the scalar field. More...
 
double ScaledNorm () const
 Compute the norm of the scalar field. More...
 
Histogram GetHistogram (int) const
 Compute the histogram of the scalar field. More...
 
Histogram GetHistogram (int, double, double) const
 Compute the histogram of the scalar field. More...
 
QVector< std::pair< double, int > > OldHistogram (int) const
 Compute a histogram. More...
 
QVector< std::pair< double, int > > CumulativeHistogram (int) const
 Compute a cumulative histogram. More...
 
QVector< std::pair< double, double > > CumulativeNormedHistogram (int) const
 Compute a normalized cumulative histogram. More...
 
virtual Vector2 Gradient (int, int) const
 Compute the gradient at a given array vertex. More...
 
virtual Matrix2 Hessian (int, int) const
 Compute the hessian at a given array vertex. More...
 
virtual double Value (int, int) const
 Return the field gradient at a given array vertex. More...
 
virtual double K () const
 Compute the Lipschitz constant of the elevation function. More...
 
void CutEpsilon (const double &=1e-6)
 Set all values in the field that are lower than epsilon to true zero. More...
 
double at (int, int) const
 Return the field value at a given array vertex. More...
 
double at (const QPoint &) const
 Return the field value at a given array vertex. More...
 
double & operator() (int, int)
 Return the field value at a given array vertex. More...
 
double & operator() (const QPoint &)
 Return the field value at a given array vertex. More...
 
double at (int) const
 Return the data in the field. More...
 
double & operator[] (int)
 Return the data in the field. More...
 
double StandardDeviation () const
 Compute the standard deviation. More...
 
double StandardDeviation (const double &) const
 Compute the standard deviation. More...
 
ScalarField2operator+= (const ScalarField2 &)
 Sum two scalar fields. More...
 
ScalarField2operator*= (const double &)
 Scale the values of a scalar field. More...
 
QImage CreateImage (bool=true) const
 Create an image from the field. More...
 
QImage CreateImage (const AnalyticPalette &, bool=false, bool=false) const
 Create an image from the field using a palette. More...
 
QImage CreateImage (const double &, const double &, const AnalyticPalette &, bool=false) const
 Create an image from the field using a palette. More...
 
QImage CreateImage (const Palette &) const
 Create an image from the field using a palette. More...
 
QImage CreateImage (const double &, const double &, const GenericPalette &, bool=false) const
 Create an image from the field using a palette. More...
 
QImage CreateImage (const GenericPalette &) const
 Create an image from the field using a palette. More...
 
QImage CreateImage (const double &, const double &, bool=true) const
 Create an image from the field. More...
 
bool ExportPGM (const QString &) const
 Export the scalarfield as a PGM file in 16 bits. More...
 
bool ExportPGM (const QString &, const double &, const double &) const
 Export the scalarfield as a PGM file in 16 bits. More...
 
ScalarField2 SetResolution (int, int, bool=false) const
 Change the resolution of the scalar field. More...
 
ScalarField2 Sample (const Box2 &, int, int, bool=false) const
 Resample a rectangular region in the scalar field. More...
 
ScalarField2 Crop (const QPoint &, const QPoint &) const
 Crops a rectangular region in the scalar field. More...
 
ScalarField2 DownSample (int) const
 Lower the resolution of the scalarfield. More...
 
ScalarField2 UpSample (int, bool=false) const
 Upsampling of the scalarfield. More...
 
virtual double Value (const Vector2 &) const
 Get the field value with world coordinate system. More...
 
virtual double Triangular (const Vector2 &) const
 Get the field value with world coordinate system. More...
 
virtual double BiCubic (const Vector2 &) const
 Get the field value with world coordinate system. More...
 
virtual double BiCubicValue (const Vector2 &) const
 Compute the bicubic interpolation. More...
 
ScalarField2 SummedAreaTable () const
 Compute the summed area table of a scalar field.
 
void Fill (const double &)
 Sets the entire field with a constant value. More...
 
void Subdivide ()
 Subdivide the scalar field. More...
 
void Smooth (const Vector2 &, double)
 Smooth the scalar field within a given region. More...
 
void Flatten (const Vector2 &, const double &, const double &=0.25)
 Flatten the scalar field. More...
 
void Multiply (const Vector2 &, const double &, const double &=1.0)
 Multiply the scalar field by a scaling factor locally (not equivalent to Flatten()) More...
 
void Level (const Vector2 &, const double &, const double &)
 Level the scalar field. More...
 
void Gaussian (const Vector2 &, const double &, const double &)
 Add material with gaussian distribution. More...
 
void Add (const Vector2 &, const double &)
 Add a value to the scalar field with diffusion. More...
 
ScalarField2 MedianFilter () const
 Compute the median filtered scalar field. More...
 
void Smooth ()
 Smooth the scalar field using a discrete gaussian kernel. More...
 
void Smooth (int)
 Applies several smoothing steps to the scalar field. More...
 
void Blur ()
 Blurs the scalar field. More...
 
void Blur (int)
 Applies several blurring steps to the scalar field. More...
 
void SmoothSmall ()
 Small smoothing of the scalar field using a discrete gaussian kernel. More...
 
void MedianFilter ()
 Filter field with median filter.
 
ScalarField2 GaussianBlur (int) const
 Perform a Gaussian blur. More...
 
ScalarField2 GaussianBlur (const double &) const
 Perform a Gaussian blur. More...
 
void Translate (const Vector2 &)
 Translate the domain of the scalar field. More...
 
void Scale (const Vector2 &)
 Scale the domain of the scalar field. More...
 
void Scale (const double &)
 Scale the scalar field. More...
 
void Normalize ()
 Normalize the values of a scalar field to unit interval. More...
 
void Unitize ()
 Linearly scale the values of a scalar field to unit interval. More...
 
void Clamp (const double &, const double &)
 Clamp the values of a scalar field. More...
 
void Add (const double &)
 Add a constant to the values the scalar field. More...
 
void Mul (const double &)
 Multiplication. More...
 
void Mul (const ScalarField2 &)
 Multiplication. More...
 
void Sub (const ScalarField2 &)
 Subtraction. More...
 
void Add (const ScalarField2 &)
 Addition. More...
 
void Pow (const double &)
 Power. More...
 
void Atan ()
 Compute the arctangent of the values of a scalar field, may be usefull for converting slope to angles. More...
 
void Step (const double &, const double &)
 Perform a linear step over the values of a scalar field. More...
 
void SetRange (const double &, const double &)
 Scales the scalar field to a given range interval. More...
 
void Binarize (const double &)
 Transform the field into a binary (0, 1 values) field using a threshold. More...
 
void Invert ()
 Inversion (take the opposite of each field value)
 
void Negate ()
 Negate (invert 0 and 1 values of a binary field)
 
void SmoothStep (const double &, const double &, bool=false)
 Perform a smooth step over the values of a scalar field. More...
 
void Abs ()
 Compute the absolute value of a scalar field.
 
void Lerp (const ScalarField2 &, const ScalarField2 &, const double &)
 Linear interpolation between two scalar fields. More...
 
void AdaptiveBilateralFiltering (double, double)
 Adaptive bilateral filtering. More...
 
void AdaptiveBilateralFiltering (int, double)
 Adaptive bilateral filtering. More...
 
ScalarField2 Convolution (double[], int)
 Convolution of the field using a kernel. More...
 
void MorphDilate ()
 Dilate the binary field using a D4 structuring element.
 
void MorphErode ()
 Erode the binary field using a D4 structuring element.
 
void MorphRemoveEnds ()
 Remove the ends of lines by authorizing at least 3 pixels.
 
void MorphHitAndMiss (double[], int)
 Perform a hit and miss operation on the field. More...
 
void MorphThin (double[], int)
 Thinning by using a kernel. More...
 
ScalarField2 MorphSkeleton (int)
 Compute the skeleton using successive erosion/dilatations. More...
 
ScalarField2 MorphSkeletonConnected (int)
 Compute the skeleton using thinning. More...
 
VectorField2 Gradient () const
 Compute the gradient field.
 
ScalarField2 GradientNorm () const
 Compute the gradient norm scalar field.
 
ScalarField2 Ln () const
 Compute the logarithm of the scalar field.
 
ScalarField2 Sqrt () const
 Compute the square root of the scalar field. More...
 
ScalarField2 Cbrt () const
 Compute the quartic root of the scalar field. More...
 
ScalarField2 Qurt () const
 Compute the quartic root of the scalar field. More...
 
void Sqrted ()
 Compute the square root of the scalar field. More...
 
virtual ScalarField2 Laplacian () const
 Compute the Laplacian field. More...
 
virtual double Laplacian (int, int) const
 Compute the Laplacian at a given sample. More...
 
QVector< ScalarPoint2GetScalarPoints () const
 Create the set of scalar points.
 
FloatArray GetAsFloats () const
 Compute and return an array of 4 byte floats.
 
Vector2 Dichotomy (Vector2, Vector2, double, double, double, const double &, const double &) const
 Compute the intersection between a segment and the scalar field. More...
 
int Memory () const
 Compute the memory size of a scalarfield.
 
void MapInPlace (const std::function< double(double)> &)
 Applies a function to the scalar field. More...
 
ScalarField2 Map (const std::function< double(double)> &) const
 Applies a function to the scalar field. More...
 
ScalarField2 Map (const std::function< double(const ScalarField2 &, int, int)> &) const
 Applies a function to the scalar field. More...
 
void SignalError (const ScalarField2 &, double &, double &) const
 Compute PSNR and RMSE between two fields. More...
 
void SignalError (const ScalarField2 &, double &, double &, double &) const
 Compute PSNR, MSE and RMSE between two fields. More...
 
ScalarField2 MaxFilter (int) const
 Compute the max filtered scalar field. More...
 
ScalarField2 MinFilter (int) const
 Compute the min filtered scalar field. More...
 
Mesh2 Polygonize () const
 Polygonize the scalar field into a surface mesh using the marching square algorithm. More...
 
SegmentSet2 LineSegments (const double &, bool=false) const
 Compute the iso-contour of the scalar field. More...
 
- Public Member Functions inherited from Array2
 Array2 ()
 Empty array, with empty box.
 
 Array2 (const Box2 &, int, int)
 Create the array structure. More...
 
 Array2 (const Box2 &, int)
 Create the array structure. More...
 
Array2 DownSample (int) const
 Downsample the array. More...
 
Array2 UpSample (int) const
 Upsample the array. More...
 
 ~Array2 ()
 Empty.
 
int VertexSize () const
 Return the size of the vertex array.
 
int GetSizeX () const
 Get the vertex size of the array for x axis.
 
int GetSizeY () const
 Get the vertex size of the array for y axis.
 
int VertexBorderSize () const
 Return the size of the vertex array.
 
int CellSize () const
 Return the size of the cell array.
 
int CellSizeX () const
 Get the cell size of the array for x axis.
 
int CellSizeY () const
 Get the cell size of the array for y axis.
 
QSize GetQtSize () const
 Return the Qt size of the vertex array.
 
Box2 Cell (int) const
 Return the geometry of the cell. More...
 
Box2 Cell (int, int) const
 Return the geometry of the cell. More...
 
void HalfCell (int, int, bool, Triangle2 &, Triangle2 &) const
 Return the geometry of the cell. More...
 
Vector2 CellCenter (int, int) const
 Return the center of the cell. More...
 
void Scale (const Vector2 &)
 Scales the array structure. More...
 
void Scale (const double &)
 Scales the array structure. More...
 
Box2 GetBox () const
 Get the box of the array.
 
Box2 UnitCell () const
 Return the geometry of a generic cell. More...
 
Vector2 CellDiagonal () const
 Return the cell diagonal vector.
 
double CellArea () const
 Return the area of a cell. More...
 
Vector2 ArrayVertex (int, int) const
 Compute the coordinates of a point on the grid. More...
 
Vector2 ArrayVertex (const QPoint &) const
 Compute the coordinates of a point on the grid. More...
 
QVector< Vector2ArrayVertexes (const QVector< QPoint > &) const
 Compute the coordinates of a set of points on the grid. More...
 
Vector2 Size () const
 Return the size of the array.
 
QRect AreaInteger () const
 Return the range of integer values for the domain.
 
QImage ImageGrid (const Box2 &, const double &) const
 Create a texture with a regular grid. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw the cells of the grid. More...
 
void Subdivide ()
 Change the resolution. More...
 
bool IsEmpty () const
 Detect if the array is empty, i.e., any dimension equal to zero.
 
QPoint VertexBorder (int) const
 Compute the k-th point on the boundary of the domain. More...
 
int VertexBorderIndex (int, int) const
 Compute the index of a point on the boundary of the domain. More...
 
void VertexInteger (const Vector2 &, int &, int &) const
 Compute the coordinates of a vertex inside a cell. More...
 
QPoint VertexInteger (const Vector2 &) const
 Compute the coordinates of a vertex inside a cell. More...
 
QPoint VertexInteger (const Vector2 &, double &, double &) const
 Compute the point on the grid given an input point. More...
 
QRect VertexIntegerArea (const Box2 &) const
 Compute the integer coordinates of the vertices embedding a box. More...
 
QRect VertexIntegerArea (const Circle2 &) const
 Compute the integer coordinates of the vertices embedding a circle. More...
 
QRect VertexIntegerArea (const QRect &) const
 Compute the integer coordinates span of the vertices embedding a rectangle. More...
 
void CellInteger (const Vector2 &, int &, int &) const
 Compute the coordinates of a vertex inside a cell. More...
 
void CellInteger (const Vector2 &, int &, int &, double &, double &) const
 Compute the point on the grid given an input point. More...
 
QPoint CellInteger (const Vector2 &) const
 Compute the coordinates of a vertex inside a cell. More...
 
QPoint CellInteger (const Vector2 &, double &, double &) const
 Compute the point on the grid given an input point. More...
 
QRect CellIntegerArea (const Box2 &) const
 Compute the integer coordinates of the cells of the array embedding an input box. More...
 
QRect CellIntegerArea (const Circle2 &) const
 Compute the integer coordinates of the cells of the array embedding an input circle. More...
 
void Translate (const Vector2 &)
 Translate the array. More...
 
Vector2 Center () const
 Return the center of the array.
 
constexpr bool InsideVertexIndex (int, int) const
 Check if the indexes are within range. More...
 
constexpr bool OutsideVertexIndex (int, int) const
 Check if the indexes are outside or on the border. More...
 
constexpr bool InsideVertexIndex (const QPoint &) const
 Check if the indexes are within range. More...
 
constexpr bool InsideVertexIndex (int, int, int) const
 Check if the indexes are within k-range. More...
 
bool Inside (const Vector2 &) const
 Check if a point is in the rectangular domain. More...
 
constexpr bool BorderVertexIndex (int, int) const
 Check if the indexes are on the border. More...
 
constexpr bool BorderVertexIndex (const QPoint &) const
 Check if the indexes are on the border. More...
 
constexpr int VertexIndex (int, int) const
 Compute the index of a given cell. More...
 
constexpr int VertexIndex (const QPoint &) const
 Compute the index of a given cell. More...
 
QPoint Next (const QPoint &, int) const
 Compute the point next to another one. More...
 
QImage CreateEmptyImage () const
 Create an image with the same size as the array. More...
 
QString Statistics () const
 Get statistics.
 
void ClampVertexIndex (int &, int &) const
 Clamp vertex indexes to the size of the array. More...
 

Static Public Member Functions

static ScalarField2 LoadFromR32 (const Box2 &, const QString &)
 Import FAW Float 32 bits format that comes from World Machine. More...
 
static ScalarField2 Load (Box2, const QString &, double=0.0, double=1.0)
 Loads a scalar field from an image. More...
 
- Static Public Member Functions inherited from Array2
static int NeighborCode (int, int)
 Convert a direction to an 8 bit integer code. More...
 
static QPoint codeToDir (int)
 Convert an 8 bit integer code direction into a direction vector. More...
 

Protected Member Functions

Matrix Local (int, int) const
 Compute the local neighborhood in the one-ring aroung a point. More...
 
void CopyEdges (ScalarField2 &) const
 Copy the values of the edges to a new field. More...
 
- Protected Member Functions inherited from Array2
constexpr void InverseVertexIndex (int, int &, int &) const
 Compute the coordinates of a given cell. More...
 
constexpr QPoint InverseVertexIndex (int) const
 Compute the coordinates of a given cell. More...
 
constexpr int CellIndex (int, int) const
 Compute the index of a given cell. More...
 
constexpr int CellIndex (const QPoint &) const
 Compute the index of a given cell. More...
 
constexpr bool InsideCellIndex (int, int) const
 Check if the indexes are within range. More...
 
constexpr bool InsideCellIndex (const QPoint &) const
 Check if the indexes are within range. More...
 
void InverseCellIndex (int, int &, int &) const
 Compute the coordinates of a given cell. More...
 
- Protected Member Functions inherited from Box2
 Box2 ()
 Empty.
 
 Box2 (const double &)
 Create a square box centered at the origin and of given half side length. More...
 
 Box2 (const double &, const double &)
 Create a box centered at the origin and of given dimensions. More...
 
 Box2 (const Vector2 &)
 Create a box from a single vertex. More...
 
 Box2 (const Vector2 &, const Vector2 &)
 Create a box. More...
 
 Box2 (const Vector2 &, const double &)
 Creates a box. More...
 
 Box2 (const Box &)
 Create a box in the plane given a box. More...
 
 Box2 (const Box2 &, const Box2 &)
 Create a box embedding two boxes. More...
 
 Box2 (const Box2 &, const Matrix2 &)
 Creates an axis aligned bounding box from a box and a transformation matrix. More...
 
 Box2 (const Box2 &, const Frame2 &)
 Creates an axis aligned bounding box from a box and a frame. More...
 
 Box2 (const QVector< Vector2 > &)
 Compute the bounding box of a set of points. More...
 
 Box2 (const QSize &)
 Create a box from a Qt size. More...
 
Vector2operator[] (int)
 Returns either end vertex of the box.
 
Vector2 operator[] (int) const
 Overloaded.
 
Vector2 Size () const
 Compute the size (width and height) of a box.
 
double Width () const
 Compute the width of a box. More...
 
double Height () const
 Compute the height of a box. More...
 
Vector2 Diagonal () const
 Returns the diagonal of the box.
 
double Radius () const
 Returns the radius of the box, i.e. the length of the half diagonal of the box.
 
double Area () const
 Compute the surface area of a box.
 
double Perimeter () const
 Compute the perimeter of the box.
 
Vector2 Center () const
 Returns the center of the box.
 
Vector2 Vertex (int) const
 Returns the k-th vertex of the box. More...
 
Vector2 Vertex (int, int, int, int) const
 Compute the coordinates of a grid aligned point. More...
 
Box2 Sub (int) const
 Computes the sub-box in the n-th quadrant. More...
 
double R (const Vector2 &) const
 Compute the squared distance between the box and a point. More...
 
double Signed (const Vector2 &) const
 Computes the signed distance between the box and a point. More...
 
double R (const Box2 &) const
 Compute the squared Euclidean distance between two boxes. More...
 
void Translate (const Vector2 &)
 Translates a box. More...
 
void Scale (const Vector2 &)
 Scales a box. More...
 
void Scale (const double &)
 Scales a box. More...
 
Box2 Translated (const Vector2 &) const
 Translated box. More...
 
Box2 Scaled (const double &) const
 Scales a box and return the scaled box. More...
 
Box2 Scaled (const Vector2 &) const
 Scales a box and return the scaled box. More...
 
Box2 Scaled (const QSize &) const
 Scales a box according to a Qt size. More...
 
Box2 ScaledTo (const double &) const
 Scale the box so that the largest side should equal the argument value. More...
 
Box2 Rotated (const double &) const
 Compute the box embedding the rotated box. More...
 
Box2 Rotated (const Matrix2 &) const
 Compute the box embedding the rotated box. More...
 
Box2 Centered () const
 Compute the box translated to origin. More...
 
void SetCubic ()
 Creates the tightest embedding cube from an arbitrarilly shaped box. More...
 
void SetInscribedCubic ()
 Creates the biggest cube inscribed in the box. More...
 
Box2 Cube () const
 Return the tightest embedding cube from an arbitrarilly shaped box. More...
 
void Extend (const double &)
 Extend the limits of the box by a given distance. More...
 
void Extend (const Vector2 &)
 Extend the limits of the box given a point. More...
 
Box2 Extended (const double &) const
 Extend the limits of the box by a given distance. More...
 
void SetParallelepipedic (int, int &, int &)
 Inflates a box so that its dimensions should be a fraction of its maximum side length. More...
 
void SetParallelepipedic (const double &, int &, int &)
 Creates a parallelepipedic box whose dimensions are integer multiples of a given input reference size. More...
 
bool Inside (const Vector2 &) const
 Test if a point is inside the box. More...
 
bool Inside (const Vector2 &, const double &) const
 Test if a point lies withing a given range of the box. More...
 
bool Intersect (const Box2 &) const
 Check if the box intersects another box. More...
 
double OverlapArea (const Box2 &) const
 Computes the overlapping area of two boxes. More...
 
Box2 Intersection (const Box2 &) const
 Computes the intersection between two boxes. More...
 
Box ToBox (const double &, const double &) const
 Convert a planar Box2 to a Box. More...
 
int Quadrant (const Vector2 &) const
 Computes quadrant index of a vertex with respect to the box center. More...
 
bool Intersect (const Ray2 &, double &, double &) const
 Computes the intersection between a box and a ray. More...
 
bool Intersect (const Ray2 &) const
 Computes the intersection between a box and a ray. More...
 
bool Intersect (const Line2 &, double &, double &) const
 Computes the intersection between a box and a line. More...
 
bool Intersect (const Segment2 &, double &, double &) const
 Compute the intersection between a box and a segment. More...
 
bool Intersect (const Line2 &) const
 Check the intersection between a box and a line. More...
 
bool Intersect (const Segment2 &) const
 Check the intersection between a box and a segment. More...
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a rectangle. More...
 
Vector2 RandomInside (Random &=Random::R239) const
 Generate a random vector inside the box. More...
 
Vector2 RandomOn (Random &=Random::R239) const
 Generate a random vector on the perimeter of the box. More...
 
QRectF GetQtRect () const
 Create the Qt rectangle.
 
QRect TileRange (const Box2 &) const
 Compute the range of index for tiling the argument box so that it covers the box. More...
 
Box2 Tile (int, int) const
 Return the tiled the box using integer coordinates. More...
 
Box2 Tile (const QRect &) const
 Return the tiled the box using integer coordinates. More...
 
QVector< Vector2Poisson (const double &, int, Random &=Random::R239) const
 Compute a Poisson disc distribution inside a box. More...
 

Protected Attributes

QVector< double > field
 Field samples.
 
- Protected Attributes inherited from Array2
int ny = 0
 Sizes.
 
Vector2 celldiagonal = Vector2::Null
 Cell diagonal.
 
Vector2 inversecelldiagonal = Vector2::Null
 Inverse cell diagonal.
 
- Protected Attributes inherited from Box2
Vector2 b
 Lower and upper vertices of the box.
 

Friends

std::ostream & operator<< (std::ostream &, const ScalarField2 &)
 Overloaded. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Box2
static Box2 MinMax (const Vector2 &, const Vector2 &)
 Create a box from any two points. More...
 
- Static Protected Attributes inherited from Array2
static const QPoint next [8] = { QPoint(1, 0), QPoint(1, 1), QPoint(0, 1), QPoint(-1, 1), QPoint(-1, 0), QPoint(-1, -1), QPoint(0, -1), QPoint(1, -1) }
 Array of points in the 1-ring neighborhood.
 
static const double length [8] = { 1.0, sqrt(2.0), 1.0, sqrt(2.0), 1.0, sqrt(2.0), 1.0, sqrt(2.0) }
 Length to the i-th neighbor.
 
static const double inverselength [8] = { 1.0, 1.0 / sqrt(2.0), 1.0, 1.0 / sqrt(2.0), 1.0, 1.0 / sqrt(2.0), 1.0, 1.0 / sqrt(2.0) }
 Inverse length.
 
- Static Protected Attributes inherited from Box2
static const double epsilon = 1.0e-5
 Epsilon value used to check intersections and some round off errors.
 
static const Box2 Infinity
 Huge bounding box, which should enclose any other.
 
static const Box2 Null
 Null box, equivalent to. More...
 
static const Box2 Unit
 Unit box, defined as. More...
 

Detailed Description

A base two-dimensional field of real values.

Constructor & Destructor Documentation

◆ ScalarField2() [1/6]

ScalarField2::ScalarField2 ( const Array2 a,
const double &  v = 0.0 
)

Create the field structure.

Parameters
aArray representing the grid domain.
vConstant value of field.

◆ ScalarField2() [2/6]

ScalarField2::ScalarField2 ( const Box2 box,
int  x,
int  y,
const double &  v = 0.0 
)
explicit

Create the field structure.

Parameters
boxThe box.
x,ySize of the array.
vConstant value of field.

◆ ScalarField2() [3/6]

ScalarField2::ScalarField2 ( const Box2 box,
int  x,
int  y,
const QVector< double > &  v 
)
explicit

Create the field structure.

Parameters
boxThe box.
x,ySize of the array.
vArray of scalar values.

◆ ScalarField2() [4/6]

ScalarField2::ScalarField2 ( const Box2 box,
const QImage &  image,
const double &  a = 0.0,
const double &  b = 256.0 * 256.0 - 1.0,
bool  grayscale = true 
)
explicit

Create a field structure from an image.

Parameters
boxThe box.
imageThe image.
a,bRange of values to scale the image.
grayscaleRead image as grayscale if set to true, otherwize use color for a better accuracy.

◆ ScalarField2() [5/6]

ScalarField2::ScalarField2 ( const QImage &  image,
const double &  v = 1.0,
const double &  d = 1.0,
bool  grayscale = true 
)
explicit

Create a field structure from an image.

Parameters
imageThe image.
vRange of values to scale the image, values will vary between 0.0 and v.
dDistance between samples.
grayscaleRead image as grayscale if set to true, otherwize use color for a better accuracy.

◆ ScalarField2() [6/6]

ScalarField2::ScalarField2 ( const QString &  name,
double  a = 0.0,
double  b = 1.0 
)
explicit

Create a field structure from an image.

This is a convenience constructor which is the same as:

ScalarField2 s(Box2(0.5), QImage(name),0.0,1.0,true);
Box2()
Empty.
Definition: box.h:376
A base two-dimensional field of real values.
Definition: scalarfield.h:283
Parameters
nameName of the image.
a,bRange of values to scale the image.

Member Function Documentation

◆ AdaptiveBilateralFiltering() [1/2]

void ScalarField2::AdaptiveBilateralFiltering ( double  spatial_sigma,
double  range_sigma 
)

Adaptive bilateral filtering.

Parameters
spatial_sigmaWidth of spatial gaussian kernal.
range_sigmaIntensity gaussian kernal.
Author
Hugo Schott

◆ AdaptiveBilateralFiltering() [2/2]

void ScalarField2::AdaptiveBilateralFiltering ( int  spatial_sigma,
double  range_sigma 
)

Adaptive bilateral filtering.

Parameters
spatial_sigmaWidth (in number of cells) of spatial gaussian kernal.
range_sigmaIntensity gaussian kernal.
Author
Hugo Schott

◆ Add() [1/3]

void ScalarField2::Add ( const double &  c)

Add a constant to the values the scalar field.

Parameters
cConstant.

◆ Add() [2/3]

void ScalarField2::Add ( const ScalarField2 s)

Addition.

Parameters
sScalar field. Optimized with AVX

◆ Add() [3/3]

void ScalarField2::Add ( const Vector2 p,
const double &  x 
)

Add a value to the scalar field with diffusion.

The value is distributed among the neighboring vertices.

Parameters
pPoint.
xValue.

◆ at() [1/3]

double ScalarField2::at ( const QPoint &  q) const
inline

Return the field value at a given array vertex.

Parameters
qPoint.

◆ at() [2/3]

double ScalarField2::at ( int  c) const
inline

Return the data in the field.

Parameters
cIndex.

◆ at() [3/3]

double ScalarField2::at ( int  i,
int  j 
) const
inline

Return the field value at a given array vertex.

Parameters
i,jInteger coordinates of the vertex.

◆ Atan()

void ScalarField2::Atan ( )

Compute the arctangent of the values of a scalar field, may be usefull for converting slope to angles.

Optimized with AVX

◆ Average()

double ScalarField2::Average ( ) const

Compute the average value of the elements in the scalar field.

Optimized with AVX

See also
Integral()

◆ BiCubic()

double ScalarField2::BiCubic ( const Vector2 p) const
virtual

Get the field value with world coordinate system.

This function computes a bicubic interpolation of the values, with null derivatives.

See also
Math::BiCubic
Parameters
pPoint (should be strictly within bounding box of the domain).

◆ BiCubicValue()

double ScalarField2::BiCubicValue ( const Vector2 p) const
virtual

Compute the bicubic interpolation.

Author
Lois Paulin.
Parameters
pPoint.

◆ Binarize()

void ScalarField2::Binarize ( const double &  t)

Transform the field into a binary (0, 1 values) field using a threshold.

Parameters
tThreshold.

◆ Blur() [1/2]

void ScalarField2::Blur ( )

Blurs the scalar field.

The function uses a 32 blur kernel.

◆ Blur() [2/2]

void ScalarField2::Blur ( int  n)

Applies several blurring steps to the scalar field.

See also
Blur()
Parameters
nNumber of blurring steps.

◆ Cbrt()

ScalarField2 ScalarField2::Cbrt ( ) const

Compute the quartic root of the scalar field.

Direct quartic root computation is more efficicent that calling ScalarField2::Sqrt() twice.

Optimized with AVX

◆ Clamp()

void ScalarField2::Clamp ( const double &  a,
const double &  b 
)

Clamp the values of a scalar field.

Parameters
a,bInterval.

◆ Convolution()

ScalarField2 ScalarField2::Convolution ( double  t[],
int  s 
)

Convolution of the field using a kernel.

Parameters
tArray of scalar values.
sSize (odd number) of the square kernel.

◆ CopyEdges()

void ScalarField2::CopyEdges ( ScalarField2 s) const
protected

Copy the values of the edges to a new field.

Parameters
sNew scalar field.

◆ CreateImage() [1/7]

QImage ScalarField2::CreateImage ( bool  grayscale = true) const

Create an image from the field.

Parameters
grayscaleExport as grayscale if set to true, and to color otherwise (provides a better precision).

◆ CreateImage() [2/7]

QImage ScalarField2::CreateImage ( const AnalyticPalette palette,
bool  symmetric = false,
bool  transparent = false 
) const

Create an image from the field using a palette.

Parameters
paletteThe palette.
symmetricIf set to true, adapt the range interval so that shading should be performed with median alignment.
transparentIf set to true, the lowest values of the scalar field will be transparent.

◆ CreateImage() [3/7]

QImage ScalarField2::CreateImage ( const double &  a,
const double &  b,
bool  grayscale = true 
) const

Create an image from the field.

Parameters
a,bRange of elevation that will be mapped to image scale.
grayscaleExport as grayscale if set to true, color otherwise.

◆ CreateImage() [4/7]

QImage ScalarField2::CreateImage ( const double &  a,
const double &  b,
const AnalyticPalette palette,
bool  transparent = false 
) const

Create an image from the field using a palette.

Parameters
a,bRange of elevation that will be mapped to image scale.
paletteThe palette.
transparentIf set to true, the lowest values of the scalar field will be transparent.

◆ CreateImage() [5/7]

QImage ScalarField2::CreateImage ( const double &  a,
const double &  b,
const GenericPalette palette,
bool  transparent = false 
) const

Create an image from the field using a palette.

Parameters
a,bRange of elevation that will be mapped to image scale.
paletteThe palette.
transparentIf set to true, the lowest values of the scalar field will be transparent.

◆ CreateImage() [6/7]

QImage ScalarField2::CreateImage ( const GenericPalette palette) const

Create an image from the field using a palette.

Parameters
paletteThe palette.

◆ CreateImage() [7/7]

QImage ScalarField2::CreateImage ( const Palette palette) const

Create an image from the field using a palette.

Parameters
paletteThe palette.

◆ Crop()

ScalarField2 ScalarField2::Crop ( const QPoint &  a,
const QPoint &  b 
) const

Crops a rectangular region in the scalar field.

Note that the corners of the region of the scalar field are (0,0) and (nx-1,ny-1).

Parameters
a,bRectangular region.

◆ CumulativeHistogram()

QVector< std::pair< double, int > > ScalarField2::CumulativeHistogram ( int  n) const

Compute a cumulative histogram.

See also
Histogram
Parameters
nDiscretization.

◆ CumulativeNormedHistogram()

QVector< std::pair< double, double > > ScalarField2::CumulativeNormedHistogram ( int  n) const

Compute a normalized cumulative histogram.

See also
Histogram
Parameters
nDiscretization.

◆ CutEpsilon()

void ScalarField2::CutEpsilon ( const double &  e = 1e-6)

Set all values in the field that are lower than epsilon to true zero.

Parameters
eEpsilon coefficient.

◆ Dichotomy()

Vector2 ScalarField2::Dichotomy ( Vector2  a,
Vector2  b,
double  va,
double  vb,
double  length,
const double &  T,
const double &  epsilon 
) const

Compute the intersection between a segment and the scalar field.

Parameters
a,bEnd vertices of the segment straddling the surface.
va,vbField function value at those end vertices.
lengthDistance between vertices.
epsilonPrecision.
TThreshold value.
Returns
Point.

◆ DownSample()

ScalarField2 ScalarField2::DownSample ( int  f) const

Lower the resolution of the scalarfield.

Parameters
fLowering factor.

◆ ExportPGM() [1/2]

bool ScalarField2::ExportPGM ( const QString &  url) const

Export the scalarfield as a PGM file in 16 bits.

Parameters
urlFile name.

◆ ExportPGM() [2/2]

bool ScalarField2::ExportPGM ( const QString &  url,
const double &  a,
const double &  b 
) const

Export the scalarfield as a PGM file in 16 bits.

Parameters
urlFile name.
a,bInterval range, values in the field will be clamped to [a,b] and rescaled 16 bits range.

◆ Fill()

void ScalarField2::Fill ( const double &  s)

Sets the entire field with a constant value.

Parameters
sScalar.

◆ Flatten()

void ScalarField2::Flatten ( const Vector2 center,
const double &  radius,
const double &  scaling = 0.25 
)

Flatten the scalar field.

Parameters
centerCenter.
radiusRadius.
scalingScaling of the effect.

◆ Gaussian()

void ScalarField2::Gaussian ( const Vector2 center,
const double &  radius,
const double &  height 
)

Add material with gaussian distribution.

Parameters
centerCenter of the distribution.
radiusRadius
heightMaximum height of the distribution.

◆ GaussianBlur() [1/2]

ScalarField2 ScalarField2::GaussianBlur ( const double &  r) const

Perform a Gaussian blur.

Parameters
rRadius of blur.
See also
ScalarField2::GaussianBlur(int)

◆ GaussianBlur() [2/2]

ScalarField2 ScalarField2::GaussianBlur ( int  r) const

Perform a Gaussian blur.

Parameters
rRadius (in cells) of blur.

◆ GetHistogram() [1/2]

Histogram ScalarField2::GetHistogram ( int  n) const

Compute the histogram of the scalar field.

Parameters
nDiscretization.

◆ GetHistogram() [2/2]

Histogram ScalarField2::GetHistogram ( int  n,
double  a,
double  b 
) const

Compute the histogram of the scalar field.

Parameters
nDiscretization.

◆ GetRange()

void ScalarField2::GetRange ( double &  a,
double &  b 
) const

Get the range of the field.

Optimized with AVX

Parameters
a,bReturned minimum and maximum.

◆ Gradient()

Vector2 ScalarField2::Gradient ( int  i,
int  j 
) const
virtual

Compute the gradient at a given array vertex.

Parameters
i,jInteger coordinates of the array vertex.

◆ Hessian()

Matrix2 ScalarField2::Hessian ( int  i,
int  j 
) const
virtual

Compute the hessian at a given array vertex.

Parameters
i,jInteger coordinates of the array vertex.

◆ Integral()

double ScalarField2::Integral ( ) const

Get the integral of the scalar field.

Compute the sum of all the elements and make the product by the area of small cell element.

See also
Average()

◆ K()

double ScalarField2::K ( ) const
virtual

Compute the Lipschitz constant of the elevation function.

Note that this is equivalent to the following code, with the difference that this function does not store the norm of the gradient in memory.

double k=0.0;
for (int i=0;i<f.VertexSize();i++)
{
k=Math::Max(k,f.at(i));
}
static double Max(const double &, const double &)
Maximum of two reals.
Definition: mathematics.h:630
ScalarField2 GradientNorm() const
Compute the gradient norm scalar field.
Definition: scalarfield2.cpp:1340

◆ Laplacian() [1/2]

ScalarField2 ScalarField2::Laplacian ( ) const
virtual

Compute the Laplacian field.

Returns a discrete approximation of Laplace’s differential operator applied to the field. The implementation is equivalent to the 4*del2(U) Matlab function, except on the edges of the field.

See also
Laplacian(int, int)
Author
Mathieu Gaillard

◆ Laplacian() [2/2]

double ScalarField2::Laplacian ( int  i,
int  j 
) const
virtual

Compute the Laplacian at a given sample.

Returns a discrete approximation of Laplace’s differential operator applied to the field. The implementation is equivalent to the 4*del2(U) Matlab function, except on the edges of the field.

See also
Laplacian()
Author
Mathieu Gaillard
Parameters
i,jInteger coordinates of the sample.

◆ Lerp()

void ScalarField2::Lerp ( const ScalarField2 a,
const ScalarField2 b,
const double &  t 
)

Linear interpolation between two scalar fields.

Parameters
a,bScalar fields, should have the same resolution.
tInterpolant. Optimized with AVX

◆ Level()

void ScalarField2::Level ( const Vector2 center,
const double &  radius,
const double &  z 
)

Level the scalar field.

Parameters
centerCenter.
radiusRadius.
zElevation.

◆ LineSegments()

SegmentSet2 ScalarField2::LineSegments ( const double &  T,
bool  closed = false 
) const

Compute the iso-contour of the scalar field.

Parameters
closedSet to true if polylines should be closed at the border of the domain.

◆ Load()

ScalarField2 ScalarField2::Load ( Box2  box,
const QString &  path,
double  a = 0.0,
double  b = 1.0 
)
static

Loads a scalar field from an image.

The function uses a specific image reader with unlimited allocation limit.

Parameters
boxThe box.
pathName of the image.
a,bRange of values to scale the image.

◆ LoadFromR32()

ScalarField2 ScalarField2::LoadFromR32 ( const Box2 box,
const QString &  filename 
)
static

Import FAW Float 32 bits format that comes from World Machine.

Suppose that the domain is a square.

◆ Local()

Matrix ScalarField2::Local ( int  i,
int  j 
) const
protected

Compute the local neighborhood in the one-ring aroung a point.

Parameters
i,jPoint.

◆ Map() [1/2]

ScalarField2 ScalarField2::Map ( const std::function< double(const ScalarField2 &, int, int)> &  fun) const

Applies a function to the scalar field.

Parameters
funFunction.

◆ Map() [2/2]

ScalarField2 ScalarField2::Map ( const std::function< double(double)> &  fun) const

Applies a function to the scalar field.

Parameters
funFunction.

◆ MapInPlace()

void ScalarField2::MapInPlace ( const std::function< double(double)> &  fun)

Applies a function to the scalar field.

Parameters
funFunction.

◆ MaxFilter()

ScalarField2 ScalarField2::MaxFilter ( int  w) const

Compute the max filtered scalar field.

Parameters
wWindow size

◆ MedianFilter()

ScalarField2 ScalarField2::MedianFilter ( ) const

Compute the median filtered scalar field.

Edges are not processed.

◆ MinFilter()

ScalarField2 ScalarField2::MinFilter ( int  w) const

Compute the min filtered scalar field.

Parameters
wWindow size

◆ MorphHitAndMiss()

void ScalarField2::MorphHitAndMiss ( double  k[],
int  s 
)

Perform a hit and miss operation on the field.

Parameters
kis the kernel, containing 1 and -1 for hit and miss resp. and 0 for "don't care"
sSize of the kernel (should be odd)

◆ MorphSkeleton()

ScalarField2 ScalarField2::MorphSkeleton ( int  n)

Compute the skeleton using successive erosion/dilatations.

Parameters
nMaximum number of iterations, which is related to the maximum thickness of the shape.

◆ MorphSkeletonConnected()

ScalarField2 ScalarField2::MorphSkeletonConnected ( int  n)

Compute the skeleton using thinning.

Parameters
nMaximum number of iterations, which is related to the maximum thickness of the shape.

◆ MorphThin()

void ScalarField2::MorphThin ( double  k[],
int  s 
)

Thinning by using a kernel.

Parameters
kKernel, containing 1 and -1 for hit and miss respectively, and 0 for don't care.
sSize of the kernel (should be odd).

◆ Mul() [1/2]

void ScalarField2::Mul ( const double &  s)

Multiplication.

Parameters
sReal.

◆ Mul() [2/2]

void ScalarField2::Mul ( const ScalarField2 s)

Multiplication.

Parameters
sScalar field.

◆ Multiply()

void ScalarField2::Multiply ( const Vector2 center,
const double &  radius,
const double &  scaling = 1.0 
)

Multiply the scalar field by a scaling factor locally (not equivalent to Flatten())

Parameters
centerCenter.
radiusRadius.
scalingScaling of the effect.

◆ Normalize()

void ScalarField2::Normalize ( )

Normalize the values of a scalar field to unit interval.

Compute range using GetRange() and apply the affine transformation to map values to [0,1].

See also
Unitize() Optimized with AVX

◆ OldHistogram()

QVector< std::pair< double, int > > ScalarField2::OldHistogram ( int  n) const

Compute a histogram.

Compute the range of values taken by the scalar field, and compute the histogram.

Parameters
nDiscretization.

◆ operator()() [1/2]

double & ScalarField2::operator() ( const QPoint &  q)
inline

Return the field value at a given array vertex.

Parameters
qPoint.

◆ operator()() [2/2]

double & ScalarField2::operator() ( int  i,
int  j 
)
inline

Return the field value at a given array vertex.

Parameters
i,jInteger coordinates of the vertex.

◆ operator*=()

ScalarField2 & ScalarField2::operator*= ( const double &  s)

Scale the values of a scalar field.

Parameters
sScaling factor.

◆ operator+=()

ScalarField2 & ScalarField2::operator+= ( const ScalarField2 s)

Sum two scalar fields.

Scalar fields should have the same size.

Parameters
sArgument scalar field.

◆ operator[]()

double & ScalarField2::operator[] ( int  c)
inline

Return the data in the field.

Parameters
cIndex.

◆ Polygonize()

Mesh2 ScalarField2::Polygonize ( ) const

Polygonize the scalar field into a surface mesh using the marching square algorithm.

Returns
The mesh.

◆ Pow()

void ScalarField2::Pow ( const double &  s)

Power.

Parameters
sReal.

◆ Qurt()

ScalarField2 ScalarField2::Qurt ( ) const

Compute the quartic root of the scalar field.

Direct quartic root computation is more efficicent that calling ScalarField2::Sqrt() twice.

Optimized with AVX

◆ Sample()

ScalarField2 ScalarField2::Sample ( const Box2 box,
int  x,
int  y,
bool  bicubic = false 
) const

Resample a rectangular region in the scalar field.

Parameters
boxRectangular region, should be strictly inside the domain.
x,ySampling size.
bicubicBicubic flag, set to true to use bicubic interpolation.

◆ Scale() [1/2]

void ScalarField2::Scale ( const double &  s)

Scale the scalar field.

This function also scales the values, it is different from ScalarField2::Scale(const Vector2&);

Parameters
sScaling factor.

◆ Scale() [2/2]

void ScalarField2::Scale ( const Vector2 s)

Scale the domain of the scalar field.

Parameters
sScaling factor.

◆ ScaledNorm()

double ScalarField2::ScaledNorm ( ) const

Compute the norm of the scalar field.

Optimized with AVX

See also
Average()

◆ SetRange()

void ScalarField2::SetRange ( const double &  a,
const double &  b 
)

Scales the scalar field to a given range interval.

Parameters
a,bInterval.

◆ SetResolution()

ScalarField2 ScalarField2::SetResolution ( int  x,
int  y,
bool  bicubic = false 
) const

Change the resolution of the scalar field.

Note that because the box should be strictly inside the original domain, this function is not the same as:

ScalarField field(Box2(Vector2(-2.0),Vector(3.0),5,5); // Original field
ScalarField s=Sample(field.GetBox(),12,12);
ScalarField2 Sample(const Box2 &, int, int, bool=false) const
Resample a rectangular region in the scalar field.
Definition: scalarfield2.cpp:1062
QVector< double > field
Field samples.
Definition: scalarfield.h:285
A base three-dimensional field of real values.
Definition: scalarfield.h:542
Vectors in two dimensions.
Definition: evector.h:617
Vectors in three dimensions.
Definition: evector.h:21
Parameters
x,ySampling size.
bicubicBicubic flag, set to true to use bicubic interpolation.

◆ SignalError() [1/2]

void ScalarField2::SignalError ( const ScalarField2 s,
double &  psnr,
double &  rmse 
) const

Compute PSNR and RMSE between two fields.

PSNR is computed assuming the data has a normalized [0,1] range.

Parameters
sSecond scalar field.
psnrReturned PSNR.
rmseReturned RMSE.

◆ SignalError() [2/2]

void ScalarField2::SignalError ( const ScalarField2 s,
double &  psnr,
double &  mse,
double &  rmse 
) const

Compute PSNR, MSE and RMSE between two fields.

Parameters
sSecond scalar field.
psnrReturned PSNR.
mseReturned MSE.
rmseReturned RMSE.

◆ Smooth() [1/3]

void ScalarField2::Smooth ( )

Smooth the scalar field using a discrete gaussian kernel.

The function uses a 32 approximation of the Gaussian kernel.

◆ Smooth() [2/3]

void ScalarField2::Smooth ( const Vector2 center,
double  r 
)

Smooth the scalar field within a given region.

The smoothing will be applied using the cubic falloff function Cubic::Smooth(const double&,const double&)

Parameters
centerCenter.
rRadius.

◆ Smooth() [3/3]

void ScalarField2::Smooth ( int  n)

Applies several smoothing steps to the scalar field.

See also
Smooth()
Parameters
nNumber of smoothing steps.

◆ SmoothSmall()

void ScalarField2::SmoothSmall ( )

Small smoothing of the scalar field using a discrete gaussian kernel.

The function uses a 32 approximation of the Gaussian kernel.

◆ SmoothStep()

void ScalarField2::SmoothStep ( const double &  a,
const double &  b,
bool  s = false 
)

Perform a smooth step over the values of a scalar field.

Either the function Cubic::Step() or Quintic::Step() is applied to all the values of the field.

See also
Cubic::Step(), Quintic::Step()
Parameters
a,bInterval.
sSmoothing Boolean value, apply a quintic smoothing kernel if set to true.

◆ Sqrt()

ScalarField2 ScalarField2::Sqrt ( ) const

Compute the square root of the scalar field.

Optimized with AVX

◆ Sqrted()

void ScalarField2::Sqrted ( )

Compute the square root of the scalar field.

This function changes the values of the field.

See also
ScalarField2::Sqrt() const Optimized with AVX

◆ StandardDeviation() [1/2]

double ScalarField2::StandardDeviation ( ) const

Compute the standard deviation.

Optimized with AVX

◆ StandardDeviation() [2/2]

double ScalarField2::StandardDeviation ( const double &  m) const

Compute the standard deviation.

Parameters
mMean.

◆ Step()

void ScalarField2::Step ( const double &  a,
const double &  b 
)

Perform a linear step over the values of a scalar field.

The function Linear::Step() is applied to all the values of the field.

See also
Linear::Step()
ScalarField2::Normalize()
Parameters
a,bInterval.

◆ Sub()

void ScalarField2::Sub ( const ScalarField2 s)

Subtraction.

Parameters
sScalar field.

Optimized with AVX

◆ Subdivide()

void ScalarField2::Subdivide ( )

Subdivide the scalar field.

Simply doubles the resolution and interpolate the values from the existing ones.

◆ Sum()

double ScalarField2::Sum ( ) const

Compute the sum of the elements in the scalar field.

Optimized with AVX

See also
Integral(), Average()

◆ Translate()

void ScalarField2::Translate ( const Vector2 t)

Translate the domain of the scalar field.

Parameters
tTranslation vector.

◆ Triangular()

double ScalarField2::Triangular ( const Vector2 p) const
virtual

Get the field value with world coordinate system.

This function computes a triangular interpolation of the values.

Parameters
pPoint (should be strictly within bounding box of the domain).

◆ Unitize()

void ScalarField2::Unitize ( )

Linearly scale the values of a scalar field to unit interval.

This function differs from ScalarField2::Normalize() which maps values to [0,1]. Instead, we divide scalard field values by the maximum of the absolute value of the scalar field, which maps values to [-1,1] and preserves 0.

See also
Normalize()

Optimized with AVX

◆ UpSample()

ScalarField2 ScalarField2::UpSample ( int  f,
bool  bicubic = false 
) const

Upsampling of the scalarfield.

Parameters
fUpsampling factor.
bicubicBicubic flag, set to true to use bicubic interpolation.
See also
ScalarField2::SetResolution

◆ Value() [1/2]

double ScalarField2::Value ( const Vector2 p) const
virtual

Get the field value with world coordinate system.

This function computes a bi-linear interpolation of the values.

See also
Math::Bilinear
Parameters
pPoint position (should be strictly inside the box domain).

◆ Value() [2/2]

double ScalarField2::Value ( int  i,
int  j 
) const
virtual

Return the field gradient at a given array vertex.

Parameters
i,jInteger coordinates of the array vertex.
See also
at(int,int)

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const ScalarField2 scalar 
)
friend

Overloaded.

Parameters
sStream.
scalarThe scalar field.