Imaging classes
-
class _2dcoordinate
An (x, y) pair in a 2-dimensional 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 non-sortable).
Public Functions
-
inline bool operator>=(const _2dcoordinate &other) const
greater or equal comparison across both dimensions
-
inline bool operator>(const _2dcoordinate &other) const
greater than comparison across both dimensions
-
inline bool operator<=(const _2dcoordinate &other) const
less or equal comparison across both dimensions
-
inline bool operator<(const _2dcoordinate &other) const
less than comparison across both dimensions
-
inline bool operator>=(const _2dcoordinate &other) const
-
typedef _2dcoordinate profit::Dimensions
-
typedef _2dcoordinate profit::Point
-
template<typename T, typename D>
class surface : public profit::surface_base Base class for 2D-organized data
Public Functions
-
inline void zero()
Assigns zero to all elements of this surface.
-
inline 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.- Parameters:
dimensions – The dimensions of the new extended surface.
start – The starting point of the original surface relative to the new one
- Returns:
The new extended surface
-
inline 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
-
inline 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.- 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.
- Returns:
The new cropped image
-
inline D reverse() const
Returns a copy of this surface with its underlying values in the reversed order, such that the top-right corner is now that bottom-left corner and vice-versa.
- Returns:
A new object with reversed values
-
inline Box bounding_box() const
Returns a “value-interesting” bounding box for this surface; that is, the subset of this surface inside which all values are different from zero.
- Returns:
The minimum bounding box within which all non-zero values of this surface are contained.
-
inline reference operator[](const size_type idx)
subscript operator
-
inline const_reference operator[](const size_type idx) const
subscript operator, const
-
inline iterator begin()
iterator to beginning of data
-
inline iterator end()
iterator to end of data
-
inline void zero()
-
class Image : public profit::surface<double, Image>
An image is a surface of doubles.
Public Types
-
enum UpsamplingMode
Available image upsampling modes
Values:
-
enumerator SCALE
Scales the value of the original pixel by
factor * factorbefore copying it into each corresponding upsampled pixel. This has the effect of preserving the total flux of the original image
-
enumerator COPY
Copies the value of the original pixel unmodified into each corresponding upsampled pixel
-
enumerator SCALE
-
enum DownsamplingMode
Available image downsampling modes
Values:
-
enumerator AVERAGE
Pixel values on the resulting image are the average of the corresponding pixels on the original image.
-
enumerator SUM
Pixel values on the resulting image are the sum of the corresponding pixels on the original image.
-
enumerator 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.
-
enumerator AVERAGE
Public Functions
-
double total() const
Returns the sum of the image pixel’s values (or “total flux”).
- Returns:
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- 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
- Returns:
An upsampled image, without interpolation.
-
Image downsample(unsigned int factor, DownsamplingMode = 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- 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
- Returns:
A downsampled image, without interpolation.
-
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.
-
inline value_type *data()
Exposes the underlying data pointer in case it becomes necessary to access it directly.
- Returns:
The underlying data pointer
-
inline const value_type *data() const
Exposes the underlying data pointer in case it becomes necessary to access it directly
- Returns:
The underlying data pointer
-
enum UpsamplingMode
-
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.
- Parameters:
factor – The upsampling factor. Must be greater than 0. If equals to 1, the upsampled mask is equals to the original mask.
- Returns:
The upsampled mask
-
Mask expand_by(Dimensions pad, int threads = 1) const