Imaging classes¶

class
_2dcoordinate
¶ An (x, y) pair in a 2dimensional discrete surface
Comparison between these objects can be done with the <, <=, ==, !=, > and >= operators, but users should not that there is no way to order values based on these operators (that is, objects of this type are by themselves nonsortable).
Public Functions

bool
operator>=
(const _2dcoordinate &other) const¶ greater or equal comparison across both dimensions

bool
operator>
(const _2dcoordinate &other) const¶ greater than comparison across both dimensions

bool
operator<=
(const _2dcoordinate &other) const¶ less or equal comparison across both dimensions

bool
operator<
(const _2dcoordinate &other) const¶ less than comparison across both dimensions

bool

typedef _2dcoordinate
profit
::
Dimensions
¶

typedef _2dcoordinate
profit
::
Point
¶

template<typename
T
, typenameD
>
classsurface
: public profit::surface_base¶ Base class for 2Dorganized data
Public Functions

D
extend
(Dimensions dimensions, Point start = Point()) const¶ Creates a new surface that is an extension of this object. The new dimensions must be greater or equal to the current dimensions. The current contents of this surface are placed at
start
, relative to the new surface’s dimension. Return
 The new extended surface
 Parameters
dimensions
: The dimensions of the new extended surface.start
: The starting point of the original surface relative to the new one

void
extend
(D &extended, Point start = Point()) const¶ Extends this object into the given surface. The new surface’s dimensions must be greater or equal to the current dimensions. The current contents of this surface are placed at
start
, relative to the new surface’s dimension. Parameters
extended
: The new surface to hold the extended version of this image. Its dimensions mandate how much the current image should extend.start
: The starting point of the original surface relative to the new one

D
crop
(Dimensions dimensions, Point start = Point()) const¶ Creates a new image that is a crop of this image. The cropped image starts at
start
(relative to this image) and has new dimensionsdimensions
. Return
 The new cropped image
 Parameters
dimensions
: The dimensions of the cropped image. They should be less or equal than the dimensions of this image.start
: The start of the new image relative to this image.

D
reverse
() const¶ Returns a copy of this surface with its underlying values in the reversed order, such that the topright corner is now that bottomleft corner and viceversa.
 Return
 A new object with reversed values

Box
bounding_box
() const¶ Returns a “valueinteresting” bounding box for this surface; that is, the subset of this surface inside which all values are different from zero.
 Return
 The minimum bounding box within which all nonzero values of this surface are contained.

bool
operator==
(const surface &other) const¶ Comparison operator.

reference
operator[]
(const size_type idx)¶ subscript operator

const_reference
operator[]
(const size_type idx) const¶ subscript operator, const

iterator
begin
()¶ iterator to beginning of data

iterator
end
()¶ iterator to end of data

operator std::vector<T>
() const¶ type casting to std::vector<T>

D

class
Image
: public profit::surface<double, Image>¶ An image is a surface of doubles.
Public Types

enum
UpsamplingMode
¶ Available image upsampling modes
Values:

SCALE
= 0¶ Scales the value of the original pixel by
factor * factor
before copying it into each corresponding upsampled pixel. This has the effect of preserving the total flux of the original image

COPY
¶ Copies the value of the original pixel unmodified into each corresponding upsampled pixel


enum
DownsamplingMode
¶ Available image downsampling modes
Values:

AVERAGE
= 0¶ Pixel values on the resulting image are the average of the corresponding pixels on the original image.

SUM
¶ Pixel values on the resulting image are the sum of the corresponding pixels on the original image.

SAMPLE
¶ Pixel values on the resulting image are samples from the original image. Samples are taken from the lowest placed pixel, in both dimensions, of the corresponding pixels of the original image.

Public Functions

double
total
() const¶ Returns the sum of the image pixel’s values (or “total flux”).
 Return
 The sum of the image pixel’s values

Image
upsample
(unsigned int factor, UpsamplingMode mode = SCALE) const¶ Upsamples this image by the given factor.
The resulting image’s dimensions will be the original image’s times the upsampling factor. The particular upsampling method is determined by
mode
 Return
 An upsampled image, without interpolation.
 Parameters
factor
: The upsampling factor. Must be greater than 0. If equals to 1, the upsampled image is equals to the original image.mode
: The upsampling mode to use

Image
downsample
(unsigned int factor, DownsamplingMode mode = SUM) const¶ Downsamples this image by the given factor.
The resulting image’s dimensions will be the ceiling of this image’s divided by the downsampling factor. The particular downsampling method is determined by
mode
 Return
 A downsampled image, without interpolation.
 Parameters
factor
: The downsampling factor. Must be greater than 0. If equals to 1, the upsampled image is equals to the original image.mode
: The downsampling mode to use

void
normalize
()¶ Normalized this image; i.e., rescales its values so the sum of all its pixels’ values is 1. If all pixels are 0 the image is not changed.

Image
normalize
() const¶ Returns a normalized version of this image; i.e., one where the sum of all pixels’ values is 1. If all pixels are 0 the returned image is identical to this image.

value_type *
data
()¶ Exposes the underlying data pointer in case it becomes necessary to access it directly.
 Return
 The underlying data pointer

const value_type *
data
() const¶ Exposes the underlying data pointer in case it becomes necessary to access it directly
 Return
 The underlying data pointer

enum

class
Mask
: public profit::surface<bool, Mask>¶ A mask is surface of bools
Public Functions

Mask
expand_by
(Dimensions pad, int threads = 1) const¶ Returns a new Mask where the area covered by the new mask (i.e., where the new mask’s value is
true
) is an “expanded” version of this mask. This is similar in nature to a convolution, but simpler as it is a simpler boolean operation that requires no additions or further scaling. Parameters
pad
: the amount of cells to expand each input pixel on each dimension.threads
: threads to use to perform computation. Only valid if compiled with OpenMP support

Mask
upsample
(unsigned int factor) const¶ Upsamples this mask by the given factor.
The resulting mask’s dimensions will be the original mask’s times the upsampling factor. The original mask’s values are copied on the corresponding cells of the upsampled mask.
 Return
 The upsampled mask
 Parameters
factor
: The upsampling factor. Must be greater than 0. If equals to 1, the upsampled mask is equals to the original mask.

Mask