![]() |
|
Typedefs | |
typedef std::array< int, 2 > | Point2i |
typedef std::array< double, 2 > | Point2d |
typedef std::array< int, 2 > | Size2i |
typedef std::array< double, 2 > | Size2d |
typedef std::vector< double > | Scalar |
template<ecvl::DataType DT> | |
using | TypeInfo_t = typename TypeInfo< DT >::basetype |
template<typename T > | |
using | optional = std::experimental::optional< T > |
using | bad_optional_access = std::experimental::bad_optional_access |
template<typename T , typename U > | |
using | larger_arithmetic_type_t = typename larger_arithmetic_type< T, U >::type |
template<typename T , typename U > | |
using | arithmetic_superior_type_t = typename arithmetic_superior_type< T, U >::type |
template<typename T , typename U > | |
using | promote_superior_type_t = typename promote_superior_type< T, U >::type |
template<DataType DT, DataType DU> | |
using | promote_superior_type_dt = promote_superior_type_t< TypeInfo_t< DT >, TypeInfo_t< DU > > |
Functions | |
void | Add (const Image &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
Adds two source Images storing the result into a destination Image. More... | |
template<typename ST2 > | |
void | Add (const Image &src1, const ST2 &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
Adds a scalar value to an Images storing the result into a destination Image. More... | |
template<typename ST1 > | |
void | Add (const ST1 &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
Adds a scalar value to an Images storing the result into a destination Image. More... | |
void | Sub (const Image &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST2 > | |
void | Sub (const Image &src1, const ST2 &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST1 > | |
void | Sub (const ST1 &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
void | Mul (const Image &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST2 > | |
void | Mul (const Image &src1, const ST2 &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST1 > | |
void | Mul (const ST1 &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
void | Div (const Image &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST2 > | |
void | Div (const Image &src1, const ST2 &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
template<typename ST1 > | |
void | Div (const ST1 &src1, const Image &src2, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
void | Neg (const Image &src, Image &dst, DataType dst_type=DataType::none, bool saturate=true) |
Negation of an Image. More... | |
double | SqDist (const Point2i &a, const Point2i &b) |
Calculate the distance squared between two ecvl::Point2i. More... | |
uint8_t | DataTypeSize (DataType dt) |
Provides the size in bytes of a given DataType. More... | |
constexpr size_t | DataTypeSize () |
Function to get the number of existing DataType at compile time. More... | |
constexpr size_t | DataTypeSignedSize () |
Function to get the number of existing signed DataType at compile time. More... | |
constexpr std::array< DataType, DataTypeSize()> | DataTypeArray () |
Function to get a std::array with all the DataType values at compile time. More... | |
constexpr std::array< DataType, DataTypeSignedSize()> | DataTypeSignedArray () |
Function to get a std::array with all the signed DataType values at compile time. More... | |
template<typename T > | |
int | vsize (const std::vector< T > &v) |
void | RearrangeChannels (const Image &src, Image &dst, const std::string &channels) |
Changes the order of the Image dimensions. More... | |
void | RearrangeChannels (const Image &src, Image &dst, const std::string &channels, DataType new_type) |
Same as RearrangeChannels(), with the chance to specify the DataType of the output Image. More... | |
void | CopyImage (const Image &src, Image &dst, DataType new_type=DataType::none) |
Copies the source Image into the destination Image. More... | |
void | CopyImage (const Image &src, Image &dst, DataType new_type, const std::string &channels) |
Same as CopyImage(), with the chance to specify the channels order of the output Image. More... | |
void | ShallowCopyImage (const Image &src, Image &dst) |
Performs a shallow copy of the source Image into the destination. More... | |
void | ConvertTo (const Image &src, Image &dst, DataType dtype, bool saturate=true) |
Convert Image to another DataType. More... | |
bool | ImRead (const ecvl::filesystem::path &filename, Image &dst, ImReadMode flags=ImReadMode::ANYCOLOR) |
Loads an image from a file. More... | |
bool | ImReadMulti (const ecvl::filesystem::path &filename, Image &dst) |
Loads a multi-page image from a file. More... | |
bool | ImWrite (const ecvl::filesystem::path &filename, const Image &src) |
Saves an image into a specified file. More... | |
int | GetOpenCVInterpolation (InterpolationType interp) |
Given an InterpolationType, the GetOpenCVInterpolation function returns the associated OpenCV enum value. More... | |
void | ResizeDim (const ecvl::Image &src, ecvl::Image &dst, const std::vector< int > &newdims, InterpolationType interp=InterpolationType::linear) |
Resizes an Image to the specified dimensions. More... | |
void | ResizeScale (const ecvl::Image &src, ecvl::Image &dst, const std::vector< double > &scales, InterpolationType interp=InterpolationType::linear) |
Resizes an Image by scaling the dimensions to a given scale factor. More... | |
void | Flip2D (const ecvl::Image &src, ecvl::Image &dst) |
Flips an Image. More... | |
void | Mirror2D (const ecvl::Image &src, ecvl::Image &dst) |
Mirrors an Image. More... | |
void | Rotate2D (const ecvl::Image &src, ecvl::Image &dst, double angle, const std::vector< double > ¢er={}, double scale=1.0, InterpolationType interp=InterpolationType::linear) |
Rotates an Image. More... | |
void | RotateFullImage2D (const ecvl::Image &src, ecvl::Image &dst, double angle, double scale=1.0, InterpolationType interp=InterpolationType::linear) |
Rotates an Image resizing the output accordingly. More... | |
void | ChangeColorSpace (const Image &src, Image &dst, ColorType new_type) |
Copies the source Image into destination Image changing the color space. More... | |
void | Threshold (const Image &src, Image &dst, double thresh, double maxval, ThresholdingType thresh_type=ThresholdingType::BINARY) |
Applies a fixed threshold to an input Image. More... | |
void | MultiThreshold (const Image &src, Image &dst, const std::vector< int > &thresholds, int minval=0, int maxval=255) |
Applies multiple thresholds to the input Image. More... | |
int | OtsuThreshold (const Image &src) |
Calculates the Otsu thresholding value. More... | |
std::vector< int > | OtsuMultiThreshold (const Image &src, int n_thresholds=2) |
Calculates the Otsu thresholding values. More... | |
void | Filter2D (const Image &src, Image &dst, const Image &ker, DataType type=DataType::none) |
Convolves an Image with a kernel. More... | |
void | SeparableFilter2D (const Image &src, Image &dst, const std::vector< double > &kerX, const std::vector< double > &kerY, DataType type=DataType::none) |
Convolves an Image with a couple of 1-dimensional kernels. More... | |
void | GaussianBlur (const Image &src, Image &dst, int sizeX, int sizeY, double sigmaX, double sigmaY=0) |
Blurs an Image using a Gaussian kernel. More... | |
void | GaussianBlur (const Image &src, Image &dst, double sigma) |
void | AdditiveLaplaceNoise (const Image &src, Image &dst, double std_dev) |
Adds Laplace distributed noise to an Image. More... | |
void | AdditivePoissonNoise (const Image &src, Image &dst, double lambda) |
Adds Poisson distributed noise to an Image. More... | |
void | GammaContrast (const Image &src, Image &dst, double gamma) |
Adjust contrast by scaling each pixel value X to 255 * ((X/255) ** gamma). More... | |
void | CoarseDropout (const Image &src, Image &dst, double p, double drop_size, bool per_channel) |
Sets rectangular areas within an Image to zero. More... | |
void | IntegralImage (const Image &src, Image &dst, DataType dst_type=DataType::float64) |
Calculate the integral image of the source Image. More... | |
void | NonMaximaSuppression (const Image &src, Image &dst) |
Calculate the Non-Maxima suppression of the source Image. More... | |
std::vector< ecvl::Point2i > | GetMaxN (const Image &src, size_t n) |
Get the n maximum values that are in the source Image. More... | |
void | ConnectedComponentsLabeling (const Image &src, Image &dst) |
Labels connected components in a binary Image. More... | |
void | FindContours (const Image &src, std::vector< std::vector< Point2i >> &contours) |
Finds contours in a binary image. More... | |
void | Stack (const std::vector< Image > &src, Image &dst) |
Stack a sequence of Images along the depth dimension (images width and height must match) More... | |
void | HConcat (const std::vector< Image > &src, Image &dst) |
Horizontal concatenation of images (with the same number of rows) More... | |
void | VConcat (const std::vector< Image > &src, Image &dst) |
Vertical concatenation of images (with the same number of columns) More... | |
void | Morphology (const Image &src, Image &dst, MorphType op, Image &kernel, Point2i anchor={ -1, -1 }, int iterations=1, BorderType border_type=BorderType::BORDER_CONSTANT, const int &border_value=0) |
Performs advanced morphological transformations using an erosion and dilation as basic operations. More... | |
void | Inpaint (const Image &src, Image &dst, const Image &inpaintMask, double inpaintRadius, InpaintType flag=InpaintType::INPAINT_TELEA) |
Restores the selected region in an image using the region neighborhood. More... | |
void | MeanStdDev (const Image &src, std::vector< double > &mean, std::vector< double > &stddev) |
Calculates the mean and the standard deviation of an Image. More... | |
void | Transpose (const Image &src, Image &dst) |
Swap rows and columns of an Image. More... | |
void | GridDistortion (const Image &src, Image &dst, int num_steps=5, const std::array< float, 2 > &distort_limit={ -0.3f, 0.3f }, InterpolationType interp=InterpolationType::linear, BorderType border_type=BorderType::BORDER_REFLECT_101, const int &border_value=0, const unsigned seed=std::default_random_engine::default_seed) |
Randomly stretch or reduce each cell of the grid in which the input Image is divided into. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1175. More... | |
void | ElasticTransform (const Image &src, Image &dst, double alpha=34., double sigma=4., InterpolationType interp=InterpolationType::linear, BorderType border_type=BorderType::BORDER_REFLECT_101, const int &border_value=0, const unsigned seed=std::default_random_engine::default_seed) |
Elastic deformation of input Image. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1235. More... | |
void | OpticalDistortion (const Image &src, Image &dst, const std::array< float, 2 > &distort_limit={ -0.3f, 0.3f }, const std::array< float, 2 > &shift_limit={ -0.1f, 0.1f }, InterpolationType interp=InterpolationType::linear, BorderType border_type=BorderType::BORDER_REFLECT_101, const int &border_value=0, const unsigned seed=std::default_random_engine::default_seed) |
Barrel / pincushion distortion. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1114. More... | |
void | Salt (const Image &src, Image &dst, double p, bool per_channel=false, const unsigned seed=std::default_random_engine::default_seed) |
Adds salt noise (white pixels) to an Image. More... | |
void | Pepper (const Image &src, Image &dst, double p, bool per_channel=false, const unsigned seed=std::default_random_engine::default_seed) |
Adds pepper noise (black pixels) to an Image. More... | |
void | SaltAndPepper (const Image &src, Image &dst, double p, bool per_channel=false, const unsigned seed=std::default_random_engine::default_seed) |
Adds salt and pepper noise (white and black pixels) to an Image. White and black pixels are equally likely. More... | |
void | SliceTimingCorrection (const Image &src, Image &dst, bool odd=false, bool down=false) |
Corrects each voxel's time-series. Slice timing correction works by using (Hanning-windowed) sinc interpolation to shift each time-series by an appropriate fraction of a TR relative to the middle of the TR period. The default slice order acquisition is from the bottom of the brain to the top. More... | |
void | Moments (const Image &src, Image &moments, int order=3, DataType type=DataType::float64) |
Calculate all raw image moments of the source Image up to the specified order. More... | |
void | CentralMoments (const Image &src, Image &moments, std::vector< double > center, int order=3, DataType type=DataType::float64) |
Calculate all central image moments of the source Image up to the specified order. More... | |
void | DrawEllipse (Image &src, ecvl::Point2i center, ecvl::Size2i axes, double angle, const ecvl::Scalar &color, int thickness=1) |
Draw an ellipse over the specified Image. More... | |
void | DropColorChannel (Image &src) |
Remove color channel from the input Image. More... | |
void | Normalize (const Image &src, Image &dst, const double &mean, const double &std) |
Normalize Image image with mean and standard deviation. More... | |
void | Normalize (const Image &src, Image &dst, const std::vector< double > &mean, const std::vector< double > &std) |
Normalize xyc Image image with separate mean and standard deviation for each color channel. More... | |
void | CenterCrop (const ecvl::Image &src, ecvl::Image &dst, const std::vector< int > &size) |
Crops the given image at the center. More... | |
void | ScaleTo (const Image &src, Image &dst, const double &new_min, const double &new_max) |
Linearly scale an Image into a new range. More... | |
template<DataType ODT, typename IDT > | |
TypeInfo< ODT >::basetype | saturate_cast (IDT v) |
Saturate a value (of any type) to the specified type. More... | |
template<typename ODT , typename IDT > | |
ODT | saturate_cast (const IDT &v) |
Saturate a value (of any type) to the specified type. More... | |
bool | DicomRead (const ecvl::filesystem::path &filename, Image &dst) |
Loads an image from a DICOM file. More... | |
bool | DicomWrite (const ecvl::filesystem::path &filename, const Image &src) |
Saves an image into a specified DICOM file. More... | |
bool | NiftiRead (const ecvl::filesystem::path &filename, Image &dst) |
Loads a nifti image from a file. More... | |
bool | NiftiWrite (const ecvl::filesystem::path &filename, const Image &src) |
Saves an image into a specified nifti file. More... | |
ecvl::Image | MatToImage (const cv::Mat &m, ColorType ctype=ColorType::none) |
Convert a cv::Mat into an ecvl::Image. More... | |
ecvl::Image | MatVecToImage (const std::vector< cv::Mat > &v) |
Convert a std::vector<cv::Mat> into an ecvl::Image. More... | |
cv::Mat | ImageToMat (const Image &img) |
Convert an ECVL Image into OpenCV Mat. More... | |
bool | OpenSlideRead (const ecvl::filesystem::path &filename, Image &dst, const int level, const std::vector< int > &dims) |
Loads a region of a whole-slide image file. More... | |
bool | OpenSlideGetLevels (const ecvl::filesystem::path &filename, std::vector< std::array< int, 2 >> &levels) |
Get width and height for each level of a whole-slide image. More... | |
template<typename T , typename U > | |
promote_superior_type_t< T, U > | PromoteAdd (T lhs, U rhs) |
template<typename T , typename U > | |
promote_superior_type_t< T, U > | PromoteSub (T lhs, U rhs) |
template<typename T , typename U > | |
promote_superior_type_t< T, U > | PromoteMul (T lhs, U rhs) |
template<typename T , typename U > | |
promote_superior_type_t< T, U > | PromoteDiv (T lhs, U rhs) |
constexpr unsigned | operator+ (SplitType const val) |
InterpolationType | StrToInterpolationType (const std::string &interp, const std::string &aug_name) |
void | TensorToImage (Tensor *&t, Image &img) |
Convert an EDDL Tensor into an ECVL Image. More... | |
void | TensorToView (Tensor *&t, View< DataType::float32 > &v) |
Convert an EDDL Tensor into an ECVL View. More... | |
void | ImageToTensor (const Image &img, Tensor *&t) |
Convert an ECVL Image into an EDDL Tensor. More... | |
void | ImageToTensor (const Image &img, Tensor *&t, const int &offset) |
Insert an ECVL Image into an EDDL Tensor. More... | |
void | ImShow (const Image &img) |
Displays an Image. More... | |
wxImage | WxFromImg (Image &img) |
Convert an ECVL Image into a wxImage. More... | |
Image | ImgFromWx (const wxImage &wx) |
Convert a wxImage into an ECVL Image. More... | |
using ecvl::arithmetic_superior_type_t = typedef typename arithmetic_superior_type<T, U>::type |
Definition at line 45 of file type_promotion.h.
using ecvl::bad_optional_access = typedef std::experimental::bad_optional_access |
Definition at line 74 of file optional.h.
using ecvl::larger_arithmetic_type_t = typedef typename larger_arithmetic_type<T, U>::type |
Definition at line 32 of file type_promotion.h.
using ecvl::optional = typedef std::experimental::optional<T> |
Definition at line 72 of file optional.h.
typedef std::array<double, 2> ecvl::Point2d |
Definition at line 26 of file datatype.h.
typedef std::array<int, 2> ecvl::Point2i |
Definition at line 25 of file datatype.h.
using ecvl::promote_superior_type_dt = typedef promote_superior_type_t<TypeInfo_t<DT>, TypeInfo_t<DU> > |
Definition at line 64 of file type_promotion.h.
using ecvl::promote_superior_type_t = typedef typename promote_superior_type<T, U>::type |
Definition at line 61 of file type_promotion.h.
typedef std::vector<double> ecvl::Scalar |
Definition at line 29 of file datatype.h.
typedef std::array<double, 2> ecvl::Size2d |
Definition at line 28 of file datatype.h.
typedef std::array<int, 2> ecvl::Size2i |
Definition at line 27 of file datatype.h.
using ecvl::TypeInfo_t = typedef typename TypeInfo<DT>::basetype |
Definition at line 67 of file datatype.h.
|
strong |
Enum class representing the ECVL border types.
|
strong |
|
strong |
DataType is an enum class which defines data types allowed for images.
Enumerator | |
---|---|
ECVL_TUPLE | |
int8 | int8_t |
int16 | int16_t |
int32 | int32_t |
int64 | int64_t |
float32 | float |
float64 | double |
uint8 | uint8_t |
uint16 | uint16_t |
none | none type |
Definition at line 43 of file datatype.h.
|
strong |
Enum class representing the ECVL ImRead flags.
Definition at line 28 of file imgcodecs.h.
|
strong |
|
strong |
Enum class representing the ECVL interpolation types.
|
strong |
Enum class representing the ECVL morphology types.
Enumerator | |
---|---|
MORPH_ERODE | |
MORPH_DILATE | |
MORPH_OPEN | an opening operation \[\texttt{dst} = \mathrm{open} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \mathrm{erode} ( \texttt{src} , \texttt{element} ))\] |
MORPH_CLOSE | a closing operation \[\texttt{dst} = \mathrm{close} ( \texttt{src} , \texttt{element} )= \mathrm{erode} ( \mathrm{dilate} ( \texttt{src} , \texttt{element} ))\] |
MORPH_GRADIENT | a morphological gradient \[\texttt{dst} = \mathrm{morph\_grad} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \texttt{src} , \texttt{element} )- \mathrm{erode} ( \texttt{src} , \texttt{element} )\] |
MORPH_TOPHAT | "top hat" \[\texttt{dst} = \mathrm{tophat} ( \texttt{src} , \texttt{element} )= \texttt{src} - \mathrm{open} ( \texttt{src} , \texttt{element} )\] |
MORPH_BLACKHAT | "black hat" \[\texttt{dst} = \mathrm{blackhat} ( \texttt{src} , \texttt{element} )= \mathrm{close} ( \texttt{src} , \texttt{element} )- \texttt{src}\] |
MORPH_HITMISS | "hit or miss". Only supported for DataType::uint8 binary images. |
|
strong |
Enum class representing the Dataset supported splits.
Enumerator | |
---|---|
training | |
validation | |
test |
Definition at line 38 of file dataset_parser.h.
|
strong |
|
inline |
Adds two source Images storing the result into a destination Image.
The procedure takes two input Images (src1 and src2) and adds them together performing a pixel-wise addition and storing the result into the destination image. Saturation is applied by default. If it is not the desired behavior change the saturate parameter to false.
The operation performed is dst = src1 + src2.
If the DataType of the destination Image is not specified (DataType::none) the destination Image will preserve its own type, if any, or it will inherit the DataType of src1 otherwise.
[in] | src1 | Augend operand (an Image). |
[in] | src2 | Addend operand (an Image). |
[out] | dst | Destination Image. It will store the final result. |
[in] | dst_type | Desired type for the destination Image. If none (default) the destination Image will preserve its own type, if any, or it will inherit the DataType of src1 otherwise. |
[in] | saturate | Whether to apply saturation or not. Default is true. |
Definition at line 69 of file arithmetic.h.
void ecvl::Add | ( | const Image & | src1, |
const ST2 & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Adds a scalar value to an Images storing the result into a destination Image.
The procedure takes two input values, an Image (src1) and a scalar (src2) and adds them together: each pixel of the Image is increased by the scalar value and the result is stored in the destination Image. Saturation is applied by default. If it is not the desired behavior change the saturate parameter to false.
The operation performed is dst = src1 + src2.
If the DataType of the destination Image is not specified (DataType::none) the destination Image will preserve its own type, if any, or it will inherit the DataType of src1 otherwise.
[in] | src1 | Augend operand (an Image). |
[in] | src2 | Addend operand (a scalar value). |
[out] | dst | Destination Image. It will store the final result. |
[in] | dst_type | Desired type for the destination Image. If none (default) the destination Image will preserve its own type, if any, or it will inherit the DataType of src1 otherwise. |
[in] | saturate | Whether to apply saturation or not. Default is true. |
Definition at line 92 of file arithmetic.h.
void ecvl::Add | ( | const ST1 & | src1, |
const Image & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Adds a scalar value to an Images storing the result into a destination Image.
The procedure takes two input values, a scalar (src1) and an Image (src2) and adds them together: each pixel of the Image is increased by the scalar value and the result is stored in the destination Image. Saturation is applied by default. If it is not the desired behavior change the saturate parameter to false.
The operation performed is dst = src1 + src2.
If the DataType of the destination Image is not specified (DataType::none) the destination Image will preserve its own type, if any, or it will inherit the DataType of src1 otherwise.
[in] | src1 | Augend operand (a scalar value). |
[in] | src2 | Addend operand (an Image). |
[out] | dst | Destination Image. It will store the final result. |
[in] | dst_type | Desired type for the destination Image. If none (default) the destination Image will preserve its own type, if any, or it will inherit the DataType of src2 otherwise. |
[in] | saturate | Whether to apply saturation or not. Default is true. |
Definition at line 116 of file arithmetic.h.
Adds Laplace distributed noise to an Image.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | std_dev | Standard deviation of the noise generating distribution. Suggested values are around 255 * 0.05 for uint8 Images. |
void ecvl::CenterCrop | ( | const ecvl::Image & | src, |
ecvl::Image & | dst, | ||
const std::vector< int > & | size | ||
) |
Crops the given image at the center.
The function crops Image src at the center and outputs the result in dst.
[in] | src | The input Image. |
[out] | dst | The output resized Image. |
[in] | size | std::vector<int> specifies the desired output size of the crop. Must be in the order [w,h]. |
void ecvl::CentralMoments | ( | const Image & | src, |
Image & | moments, | ||
std::vector< double > | center, | ||
int | order = 3 , |
||
DataType | type = DataType::float64 |
||
) |
Calculate all central image moments of the source Image up to the specified order.
When working with a 2D image, naming \(\bar{x} = \frac{M_{10}}{M_{00}}\) and \(\bar{y} = \frac{M_{01}}{M_{00}}\) the components of the centroid (see documentation of Moments() for more details) and \(I(x,y)\) the pixel intensities, the central moments are calculated with the following formula:
\( \mu_{ij} = \sum_x{\sum_y{(x-\bar{x})^i(y-\bar{y})^jI(x,y)}} \)
The central moments up to order 3 are then:
\(\mu_{00} = M_{00}\),
\(\mu_{01} = 0\),
\(\mu_{10} = 0\),
\(\mu_{11} = M_{11} - \bar{x}M_{01} = M_{11} - \bar{y}M_{10}\),
\(\mu_{20} = M_{20} - \bar{x}M_{10}\),
\(\mu_{02} = M_{02} - \bar{y}M_{01}\),
\(\mu_{21} = M_{21} - 2\bar{x}M_{11} - \bar{y}M_{20} + 2\bar{x}^2M_{01}\),
\(\mu_{12} = M_{12} - 2\bar{y}M_{11} - \bar{x}M_{02} + 2\bar{y}^2M_{10}\),
\(\mu_{30} = M_{30} - 3\bar{x}M_{20} + 2\bar{x}^2M_{10}\),
\(\mu_{03} = M_{03} - 3\bar{y}M_{02} + 2\bar{y}^2M_{01}\)
The formula above can be accordingly extended when working with higher dimensions. Note that central moments are translational invariant. Moments are stored in the output moments Image in the same order as for source channels. The output moments Image will be on the same device of the source Image.
Information about image orientation can be derived from the covariance matrix of the image \(I(x,y)\), constructed with the second order central moments:
\(cov[I(x,y)] = \begin{bmatrix}\mu_{20}' & \mu_{11}'\\ \mu_{11}' & \mu_{02}'\end{bmatrix}\)
where
\(\mu_{20}' = \frac{\mu_{20}}{\mu_{00}} = \frac{M_{20}}{M_{00}} − \bar{x}^2\)
\(\mu_{02}' = \frac{\mu_{02}}{\mu_{00}} = \frac{M_{02}}{M_{00}} − \bar{y}^2\)
\(\mu_{11}' = \frac{\mu_{11}}{\mu_{00}} = \frac{M_{11}}{M_{00}} − \bar{x}\bar{y}\)
The eigenvectors of the \(cov[I(x,y)]\) matrix correspond to the major and minor axes of the image intensity. The orientation can be extracted as:
\(\theta = \frac{1}{2}arctan(\frac{2\mu_{11}'}{\mu_{20}' - \mu_{02}'})\)
On the other hand, the eigenvalues of the \(cov[I(x,y)]\) matrix are given by:
\(\lambda_i = \frac{\mu_{20}' + \mu_{02}'}{2} \pm \frac{\sqrt{4\mu_{11}'^2 + (\mu_{20}' - \mu_{02}')^2}}{2} \)
Eigenvalues are proportional to the square length of the eigenvector axes. The half-axes of the ellipse generated by the eigenvectors are given by \(\frac{d}{\sqrt{\lambda_1}}\) and \(\frac{d}{\sqrt{\lambda_2}}\) where \(d\) is the proportional factor. Considering that the moment \(\mu_{00} = M_{00}\) is the area (when the image is binary) of the image objects we can easily calculate \(d\) using the following equation:
\(\mu_{00} = \pi \frac{d^2}{\sqrt{\lambda_1 \lambda_2}}\)
Additionally, the eccentricity of the image can be calculates as:
\(e = \sqrt{1 - \frac{\lambda_2}{\lambda_1}}\)
[in] | src | Input Image on which calculating row moments up to the specified order. It must be a grayscale (ColorType::GRAY) or a data (ColorType::none) Image. |
[out] | moments | Output data (ColorType:none) Image containing the computed raw image moments. The moments DataType is specified by the type parameter. The size of the Image will be (order + 1, order + 1) |
[in] | center | Vector (std::vector<double>) representing the center coordinates: they can be calculated from raw moments. As an example, for a 2d image center coordinates are given by \((\frac{M_{10}}{M_{00}}, \frac{M_{01}}{M_{00}})\). See Moments() documentation for more details. center.size() and src.dims_ must match in size (except for the 'c' channel). The source axes order must be the same used to specify center coordinates. |
[in] | order | Raw image moments will be calculated up to the specified order. Default is 3. |
[in] | type | Specify the ecvl::DataType to be used for the moments Image. It could be either DataType::float32 or DataType::float64. Default is DataType::float64. |
Copies the source Image into destination Image changing the color space.
The ChangeColorSpace procedure converts the color space of the source Image into the specified color space. New data are copied into destination Image. Source and destination can be contiguous or not and can also be the same Image.
void ecvl::CoarseDropout | ( | const Image & | src, |
Image & | dst, | ||
double | p, | ||
double | drop_size, | ||
bool | per_channel | ||
) |
Sets rectangular areas within an Image to zero.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | p | Probability of any rectangle being set to zero. |
[in] | drop_size | Size of rectangles in percentage of the input Image. |
[in] | per_channel | Whether to use the same value for all channels of a pixel or not. |
Labels connected components in a binary Image.
The ConnectedComponentsLabeling() procedure implement the Spaghetti algorithm described in [1], an extremely efficient algorithm to label connected components inside binary images using 8-way connectivity.
[in] | src | Input Image. It must be with channels "xyc", only one color channel and DataType::uint8. |
[out] | dst | Output Image. |
Convert Image to another DataType.
void ecvl::CopyImage | ( | const Image & | src, |
Image & | dst, | ||
DataType | new_type = DataType::none |
||
) |
Copies the source Image into the destination Image.
The CopyImage() procedure takes an Image and copies its data into the destination Image. Source and destination cannot be the same Image. Source cannot be a Image with DataType::none. The optional new_type parameter can be used to change the DataType of the destination Image. This function is mainly designed to change the DataType of an Image, copying its data into a new Image or to copy an Image into a View as a patch. So if you just want to copy an Image as it is, use the copy constructor or = instead. Anyway, the procedure will handle all the possible situations that may happen trying to avoid unnecessary allocations. When the DataType is not specified the function will have the following behaviors:
[in] | src | Source Image to be copied into destination Image. |
[out] | dst | Destination Image that will hold a copy of the source Image. Cannot be the source Image. |
[in] | new_type | Desired type for the destination Image after the copy. If none (default) the destination Image will preserve its type if it is not empty, otherwise it will have the same type of the source Image. |
void ecvl::CopyImage | ( | const Image & | src, |
Image & | dst, | ||
DataType | new_type, | ||
const std::string & | channels | ||
) |
Same as CopyImage(), with the chance to specify the channels order of the output Image.
[in] | src | Source Image to be copied into destination Image. |
[out] | dst | Destination Image that will hold a copy of the source Image. Cannot be the source Image. |
[in] | new_type | Desired type for the destination Image after the copy. If none (default) the destination Image will preserve its type if it is not empty, otherwise it will have the same type of the source Image. |
[in] | channels | Desired order of Image channels. |
constexpr std::array<DataType, DataTypeSize()> ecvl::DataTypeArray | ( | ) |
Function to get a std::array with all the DataType values at compile time.
Definition at line 100 of file datatype.h.
constexpr std::array<DataType, DataTypeSignedSize()> ecvl::DataTypeSignedArray | ( | ) |
Function to get a std::array with all the signed DataType values at compile time.
Definition at line 115 of file datatype.h.
constexpr size_t ecvl::DataTypeSignedSize | ( | ) |
Function to get the number of existing signed DataType at compile time.
Definition at line 86 of file datatype.h.
uint8_t ecvl::DataTypeSize | ( | DataType | dt | ) |
Provides the size in bytes of a given DataType.
Given one of the DataType, the function returns its size in bytes.
[in] | dt | A DataType. |
constexpr size_t ecvl::DataTypeSize | ( | ) |
Function to get the number of existing DataType at compile time.
Definition at line 73 of file datatype.h.
bool ecvl::DicomRead | ( | const ecvl::filesystem::path & | filename, |
Image & | dst | ||
) |
Loads an image from a DICOM file.
Loads an image from the specified DICOM file. If the image cannot be read for any reason, the function creates an empty Image and returns false.
[in] | filename | A filesystem::path identifying the file name. |
[out] | dst | Image in which data will be stored. |
bool ecvl::DicomWrite | ( | const ecvl::filesystem::path & | filename, |
const Image & | src | ||
) |
Saves an image into a specified DICOM file.
The function DicomWrite saves the input image into a specified file, with the DICOM format.
[in] | filename | A filesystem::path identifying the output file name. |
[in] | src | Image to be saved. |
|
inline |
Definition at line 126 of file arithmetic.h.
void ecvl::Div | ( | const Image & | src1, |
const ST2 & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 127 of file arithmetic.h.
void ecvl::Div | ( | const ST1 & | src1, |
const Image & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 128 of file arithmetic.h.
void ecvl::DrawEllipse | ( | Image & | src, |
ecvl::Point2i | center, | ||
ecvl::Size2i | axes, | ||
double | angle, | ||
const ecvl::Scalar & | color, | ||
int | thickness = 1 |
||
) |
Draw an ellipse over the specified Image.
[in,out] | src | Image on which draw the ellipse. |
[in] | center | Center of the ellipse to be drawn. |
[in] | axes | Half of the size of the ellipse axes. |
[in] | angle | Ellipse rotation angle. It must be in degrees. |
[in] | color | Ellipse color. It can be either a number (e.g. {255}) or an RGB value (e.g. {40, 40, 40}) |
[in] | thickness | Thickness of the ellipse border. If negative all the pixell of the ellipse will be filled with the specified color value. Default is 1. |
void ecvl::DropColorChannel | ( | Image & | src | ) |
Remove color channel from the input Image.
The DropColorChannel() procedure remove the color channel ("c") from the specified input Image, modifying all the other attribute accordingly. This function can be only applied on Images with ColorType::GRAY, i.e. images having the color channel dimension equal to 1.
[in,out] | src | Image from which to drop the color channel. |
void ecvl::ElasticTransform | ( | const Image & | src, |
Image & | dst, | ||
double | alpha = 34. , |
||
double | sigma = 4. , |
||
InterpolationType | interp = InterpolationType::linear , |
||
BorderType | border_type = BorderType::BORDER_REFLECT_101 , |
||
const int & | border_value = 0 , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Elastic deformation of input Image. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1235.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | alpha | Scaling factor that controls the intensity of the deformation. |
[in] | sigma | Gaussian kernel standard deviation |
[in] | interp | Interpolation type used. If src is DataType::int8 or DataType::int32, Interpolation::nearest is used. Default is InterpolationType::linear. |
[in] | border_type | Flag used to specify the pixel extrapolation method. Default is BorderType::BORDER_REFLECT_101. |
[in] | border_value | Padding value if border_type is BorderType::BORDER_CONSTANT. |
[in] | seed | Seed to use for this function's random number generator. |
void ecvl::Filter2D | ( | const Image & | src, |
Image & | dst, | ||
const Image & | ker, | ||
DataType | type = DataType::none |
||
) |
Convolves an Image with a kernel.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | ker | Convolution kernel. |
[in] | type | Destination ecvl::DataType. If DataType::none, the same of src is used. |
Finds contours in a binary image.
[in] | src | Input Image. It must be with channels "xyc", only one color channel and DataType::uint8. |
[out] | contours | Output contours. |
void ecvl::Flip2D | ( | const ecvl::Image & | src, |
ecvl::Image & | dst | ||
) |
Adjust contrast by scaling each pixel value X to 255 * ((X/255) ** gamma).
void ecvl::GaussianBlur | ( | const Image & | src, |
Image & | dst, | ||
int | sizeX, | ||
int | sizeY, | ||
double | sigmaX, | ||
double | sigmaY = 0 |
||
) |
Blurs an Image using a Gaussian kernel.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | sizeX | Horizontal size of the kernel. Must be positive and odd. |
[in] | sizeY | Vertical size of the kernel. Must be positive and odd. |
[in] | sigmaX | Gaussian kernel standard deviation in X direction. |
[in] | sigmaY | Gaussian kernel standard deviation in Y direction. If zero, sigmaX is used. If both are zero, they are calculated from sizeX and sizeY. |
std::vector<ecvl::Point2i> ecvl::GetMaxN | ( | const Image & | src, |
size_t | n | ||
) |
Get the n
maximum values that are in the source Image.
[in] | src | Input Image. It must be with ColorType::GRAY, "xyc" and DataType::int32. |
[in] | n | How many values must be returned. |
int ecvl::GetOpenCVInterpolation | ( | InterpolationType | interp | ) |
Given an InterpolationType, the GetOpenCVInterpolation function returns the associated OpenCV enum value.
[in] | interp | Interpolation type, see InterpolationType. |
void ecvl::GridDistortion | ( | const Image & | src, |
Image & | dst, | ||
int | num_steps = 5 , |
||
const std::array< float, 2 > & | distort_limit = { -0.3f, 0.3f } , |
||
InterpolationType | interp = InterpolationType::linear , |
||
BorderType | border_type = BorderType::BORDER_REFLECT_101 , |
||
const int & | border_value = 0 , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Randomly stretch or reduce each cell of the grid in which the input Image is divided into. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1175.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | num_steps | Count of grid cells on each side. |
[in] | distort_limit | Range of distortion steps. |
[in] | interp | Interpolation type used. Default is InterpolationType::linear. |
[in] | border_type | Flag used to specify the pixel extrapolation method. Default is BorderType::BORDER_REFLECT_101. |
[in] | border_value | Padding value if border_type is BorderType::BORDER_CONSTANT. |
[in] | seed | Seed to use for this function's random number generator. |
Horizontal concatenation of images (with the same number of rows)
[in] | src | vector of input Images. |
[out] | dst | Output Image. |
cv::Mat ecvl::ImageToMat | ( | const Image & | img | ) |
void ecvl::ImageToTensor | ( | const Image & | img, |
Tensor *& | t | ||
) |
Convert an ECVL Image into an EDDL Tensor.
Image must have 3 dimensions "xy[czo]" (in any order).
Output Tensor will be created with shape \(C\) x \(H\) x \(W\).
[in] | img | Input ECVL Image. |
[out] | t | Output EDDL Tensor. It is created inside the function. |
void ecvl::ImageToTensor | ( | const Image & | img, |
Tensor *& | t, | ||
const int & | offset | ||
) |
Insert an ECVL Image into an EDDL Tensor.
This function is useful to insert into an EDDL Tensor more than one image, specifying how many images are already stored in the Tensor. Image must have 3 dimensions "xy[czo]" (in any order).
[in] | img | Input ECVL Image. |
[out] | t | Output EDDL Tensor. It must be created with the right dimensions before calling this function. |
[in] | offset | How many images are already stored in the Tensor. |
Image ecvl::ImgFromWx | ( | const wxImage & | wx | ) |
Convert a wxImage into an ECVL Image.
[in] | wx | Input wxImage. |
bool ecvl::ImRead | ( | const ecvl::filesystem::path & | filename, |
Image & | dst, | ||
ImReadMode | flags = ImReadMode::ANYCOLOR |
||
) |
Loads an image from a file.
The function ImRead loads an image from the specified file (jpg, png, dicom or nifti). If the image cannot be read for any reason, the function creates an empty Image and returns false.
[in] | filename | A std::filesystem::path identifying the file name. |
[out] | dst | Image in which data will be stored. |
[in] | flags | An ImReadMode indicating how to read the image. |
bool ecvl::ImReadMulti | ( | const ecvl::filesystem::path & | filename, |
Image & | dst | ||
) |
Loads a multi-page image from a file.
The function ImReadMulti loads a multi-page image from the specified file. If the image cannot be read for any reason, the function creates an empty Image and returns false.
[in] | filename | A std::string identifying the file name. |
[out] | dst | Image in which data will be stored. |
void ecvl::ImShow | ( | const Image & | img | ) |
Displays an Image.
The ImShow function instantiates a ShowApp and starts it with a wxEntry() call. The image is shown with its original size.
[in] | img | Image to be shown. |
bool ecvl::ImWrite | ( | const ecvl::filesystem::path & | filename, |
const Image & | src | ||
) |
Saves an image into a specified file.
The function ImWrite saves the input image into a specified file. The image format is chosen based on the filename extension. The following sample shows how to create a BGR image and save it to the PNG file "test.png":
[in] | filename | A std::filesystem::path identifying the output file name. |
[in] | src | Image to be saved. |
void ecvl::Inpaint | ( | const Image & | src, |
Image & | dst, | ||
const Image & | inpaintMask, | ||
double | inpaintRadius, | ||
InpaintType | flag = InpaintType::INPAINT_TELEA |
||
) |
Restores the selected region in an image using the region neighborhood.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | inpaintMask | Inpainting mask, an Image with 1-channel and DataType::uint8. Non-zero pixels indicate the area that needs to be inpainted. |
[in] | inpaintRadius | Radius of a circular neighborhood of each point inpainted that is considered by the algorithm. |
[in] | flag | Inpainting method that could be InpaintType::INPAINT_NS or InpaintType::INPAINT_TELEA. |
void ecvl::IntegralImage | ( | const Image & | src, |
Image & | dst, | ||
DataType | dst_type = DataType::float64 |
||
) |
Calculate the integral image of the source Image.
[in] | src | Input Image. It must be with ColorType::GRAY, "xyc" and DataType::uint8. |
[out] | dst | Output Image. |
[in] | dst_type | DataType of the destination Image. |
ecvl::Image ecvl::MatToImage | ( | const cv::Mat & | m, |
ColorType | ctype = ColorType::none |
||
) |
Convert a cv::Mat into an ecvl::Image.
[in] | m | Input OpenCV Mat. |
[in] | ctype | Input ColorType of the returned ecvl::Image. If not provided the ColorType is guessed from OpenCV Mat. |
ecvl::Image ecvl::MatVecToImage | ( | const std::vector< cv::Mat > & | v | ) |
Convert a std::vector<cv::Mat> into an ecvl::Image.
[in] | v | Input std::vector of OpenCV Mat. |
void ecvl::MeanStdDev | ( | const Image & | src, |
std::vector< double > & | mean, | ||
std::vector< double > & | stddev | ||
) |
void ecvl::Mirror2D | ( | const ecvl::Image & | src, |
ecvl::Image & | dst | ||
) |
Mirrors an Image.
The Mirror2D procedure horizontally flips an Image.
void ecvl::Moments | ( | const Image & | src, |
Image & | moments, | ||
int | order = 3 , |
||
DataType | type = DataType::float64 |
||
) |
Calculate all raw image moments of the source Image up to the specified order.
When working with a 2D image, naming the pixel intensities as \(I(x,y)\), raw image moments \(M_{ij}\) are calculated with the following formula:
\( M_{ij} = \sum_x{\sum_y{x^iy^jI(x,y)}} \)
The following properties can be derived from raw image moments:
The formula above can be accordingly extended when working with higher dimensions. Note that raw moments are neither translation, scale nor rotation invariant. Moments are stored in the output moments Image in the same order as for source channels. The output moments Image will be on the same device of the source Image.
[in] | src | Input Image on which calculating row moments up to the specified order. It must be a grayscale (ColorType::GRAY) or a data (ColorType::none) Image. |
[out] | moments | Output data (ColorType:none) Image containing the computed raw image moments. The moments DataType is specified by the type parameter. The size of the Image will be (order + 1, order + 1) |
[in] | order | Raw image moments will be calculated up to the specified order. Default is 3. |
[in] | type | Specify the ecvl::DataType to be used for the moments Image. It could be either DataType::float32 or DataType::float64. Default is DataType::float64. |
void ecvl::Morphology | ( | const Image & | src, |
Image & | dst, | ||
MorphType | op, | ||
Image & | kernel, | ||
Point2i | anchor = { -1, -1 } , |
||
int | iterations = 1 , |
||
BorderType | border_type = BorderType::BORDER_CONSTANT , |
||
const int & | border_value = 0 |
||
) |
Performs advanced morphological transformations using an erosion and dilation as basic operations.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | op | Type of a morphological operation, see MorphType. |
[in] | kernel | Structuring element. |
[in] | anchor | Anchor position with the kernel. Negative values mean that the anchor is at the kernel center. |
[in] | iterations | Number of times erosion and dilation are applied. |
[in] | border_type | Pixel extrapolation method, see BorderType. BorderType::BORDER_WRAP is not supported. |
[in] | border_value | Border value in case of a constant border. |
|
inline |
Definition at line 122 of file arithmetic.h.
void ecvl::Mul | ( | const Image & | src1, |
const ST2 & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 123 of file arithmetic.h.
void ecvl::Mul | ( | const ST1 & | src1, |
const Image & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 124 of file arithmetic.h.
void ecvl::MultiThreshold | ( | const Image & | src, |
Image & | dst, | ||
const std::vector< int > & | thresholds, | ||
int | minval = 0 , |
||
int | maxval = 255 |
||
) |
Applies multiple thresholds to the input Image.
The Threshold() function applies multiple thresholding to the input Image. The resulting Image is quantized based on the provided thresholds values. Output values will range uniformly from minval to maxval.
[in] | src | Input Image on which to apply the threshold. |
[out] | dst | The output thresholded Image. |
[in] | thresholds | Threshold values. |
[in] | minval | The minimum value in the output Image. Default is 0. |
[in] | maxval | The maximum value in the output Image. Default is 255. |
|
inline |
Negation of an Image.
The Neg() function negates every value of an Image, and stores the the result in a destination Image with the specified type.
[in] | src | Image to be negated. |
[out] | dst | Destination Image. It will store the final result. |
[in] | dst_type | Desired type for the destination Image. If none (default) the destination Image will preserve its own type, if any, or it will inherit the DataType of src otherwise. |
[in] | saturate | Whether to apply saturation or not. Default is true. |
Definition at line 146 of file arithmetic.h.
bool ecvl::NiftiRead | ( | const ecvl::filesystem::path & | filename, |
Image & | dst | ||
) |
Loads a nifti image from a file.
The function NiftiRead loads an image from the specified nifti file. If the image cannot be read for any reason, the function creates an empty Image and returns false.
[in] | filename | A std::filesystem::path identifying the file name. |
[out] | dst | Image in which data will be stored. |
bool ecvl::NiftiWrite | ( | const ecvl::filesystem::path & | filename, |
const Image & | src | ||
) |
Saves an image into a specified nifti file.
The function NiftiWrite saves the input image into a specified file, with the NIfTI-1 format.
[in] | filename | A std::filesystem::path identifying the output file name. |
[in] | src | Image to be saved. |
Calculate the Non-Maxima suppression of the source Image.
[in] | src | Input Image. It must be with ColorType::GRAY, "xyc" and DataType::int32. |
[out] | dst | Output Image. |
Normalize Image image with mean and standard deviation.
The Normalize creates an Image in which each pixel of the Image is subtracted by mean and divide by std. Useful to normalize a dataset, in fact normalization helps to get the data within a range and which helps in making training of neural networks a lot faster.
void ecvl::Normalize | ( | const Image & | src, |
Image & | dst, | ||
const std::vector< double > & | mean, | ||
const std::vector< double > & | std | ||
) |
Normalize xyc Image image with separate mean and standard deviation for each color channel.
The Normalize creates an Image in which each pixel of the input xyc Image is subtracted by the mean and divide by the std for its channel. Useful to normalize a dataset, in fact normalization helps to get the data within a range and which helps in making training of neural networks a lot faster.
bool ecvl::OpenSlideGetLevels | ( | const ecvl::filesystem::path & | filename, |
std::vector< std::array< int, 2 >> & | levels | ||
) |
Get width and height for each level of a whole-slide image.
[in] | filename | A filesystem::path identifying the file name. |
[out] | levels | A std::vector of array containing two elements, width and height respectively. levels[k] are the dimensions of level k. |
bool ecvl::OpenSlideRead | ( | const ecvl::filesystem::path & | filename, |
Image & | dst, | ||
const int | level, | ||
const std::vector< int > & | dims | ||
) |
Loads a region of a whole-slide image file.
Loads a region from the specified whole-slide image file. Supported formats are those supported by OpenSlide library. If the region cannot be read for any reason, the function creates an empty Image and returns false.
[in] | filename | A filesystem::path identifying the file name. |
[out] | dst | Image in which data will be stored. |
[in] | level | Image level to be extracted. |
[in] | dims | std::vector containing { x, y, w, h }. x and y are the top left x-coordinate and y-coordinate, in the level 0 reference frame. w and h are the width and height of the region. |
|
inline |
Definition at line 38 of file dataset_parser.h.
void ecvl::OpticalDistortion | ( | const Image & | src, |
Image & | dst, | ||
const std::array< float, 2 > & | distort_limit = { -0.3f, 0.3f } , |
||
const std::array< float, 2 > & | shift_limit = { -0.1f, 0.1f } , |
||
InterpolationType | interp = InterpolationType::linear , |
||
BorderType | border_type = BorderType::BORDER_REFLECT_101 , |
||
const int & | border_value = 0 , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Barrel / pincushion distortion. Based on https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/transforms.py#L1114.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | distort_limit | Range to randomly select the intensity of the distortion. |
[in] | shift_limit | Range of image shifting. |
[in] | interp | Interpolation type used. Default is InterpolationType::linear. |
[in] | border_type | Flag used to specify the pixel extrapolation method. Default is BorderType::BORDER_REFLECT_101. |
[in] | border_value | Padding value if border_type is BorderType::BORDER_CONSTANT. |
[in] | seed | Seed to use for this function's random number generator. |
std::vector<int> ecvl::OtsuMultiThreshold | ( | const Image & | src, |
int | n_thresholds = 2 |
||
) |
Calculates the Otsu thresholding values.
The OtsuThreshold() function calculates the Otsu threshold values over a given input Image. The source Image must be of ColorType::GRAY. The number of thresholds to be found is defined by the n_thresholds parameter (default is 2). This function implement the algorithm described in [2].
[in] | src | Input Image on which to calculate the Otsu threshold value. |
[in] | n_thresholds | Number of thresholds to be found using the Otsu multi threshold algorithm variation. |
int ecvl::OtsuThreshold | ( | const Image & | src | ) |
Calculates the Otsu thresholding value.
The OtsuThreshold() function calculates the Otsu threshold value over a given input Image. The Image must be of ColorType::GRAY. This function implements the algorithm described in [3].
[in] | src | Input Image on which to calculate the Otsu threshold value. |
void ecvl::Pepper | ( | const Image & | src, |
Image & | dst, | ||
double | p, | ||
bool | per_channel = false , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Adds pepper noise (black pixels) to an Image.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | p | Probability of replacing a pixel with pepper noise. |
[in] | per_channel | If true, noise is not considered pixel-wise but channel-wise. |
[in] | seed | Seed to use for this function's random number generator. |
promote_superior_type_t<T, U> ecvl::PromoteAdd | ( | T | lhs, |
U | rhs | ||
) |
Definition at line 73 of file type_promotion.h.
promote_superior_type_t<T, U> ecvl::PromoteDiv | ( | T | lhs, |
U | rhs | ||
) |
Definition at line 76 of file type_promotion.h.
promote_superior_type_t<T, U> ecvl::PromoteMul | ( | T | lhs, |
U | rhs | ||
) |
Definition at line 75 of file type_promotion.h.
promote_superior_type_t<T, U> ecvl::PromoteSub | ( | T | lhs, |
U | rhs | ||
) |
Definition at line 74 of file type_promotion.h.
Changes the order of the Image dimensions.
The RearrangeChannels procedure changes the order of the input Image dimensions saving the result into the output Image. The new order of dimensions can be specified as a string through the "channels" parameter. Input and output Images can be the same. The number of channels of the input Image must be the same of required channels.
[in] | src | Input Image on which to rearrange dimensions. |
[out] | dst | The output rearranged Image. Can be the src Image. |
[in] | channels | Desired order of Image channels. |
void ecvl::RearrangeChannels | ( | const Image & | src, |
Image & | dst, | ||
const std::string & | channels, | ||
DataType | new_type | ||
) |
Same as RearrangeChannels(), with the chance to specify the DataType of the output Image.
[in] | src | Input Image on which to rearrange dimensions. |
[out] | dst | The output rearranged Image. Can be the src Image. |
[in] | channels | Desired order of Image channels. |
[in] | new_type | Desired type for the destination Image after the copy. If none the destination Image will preserve its type if it is not empty, otherwise it will have the same type of the source Image. |
void ecvl::ResizeDim | ( | const ecvl::Image & | src, |
ecvl::Image & | dst, | ||
const std::vector< int > & | newdims, | ||
InterpolationType | interp = InterpolationType::linear |
||
) |
Resizes an Image to the specified dimensions.
The function resizes Image src and outputs the result in dst.
[in] | src | The input Image. |
[out] | dst | The output resized Image. |
[in] | newdims | std::vector<int> that specifies the new size of each dimension. The vector size must match the src Image dimensions, excluding the color channel. |
[in] | interp | InterpolationType to be used. Default is InterpolationType::linear. |
void ecvl::ResizeScale | ( | const ecvl::Image & | src, |
ecvl::Image & | dst, | ||
const std::vector< double > & | scales, | ||
InterpolationType | interp = InterpolationType::linear |
||
) |
Resizes an Image by scaling the dimensions to a given scale factor.
The function resizes Image src and outputs the result in dst.
[in] | src | The input Image. |
[out] | dst | The output rescaled Image. |
[in] | scales | std::vector<double> that specifies the scale to apply to each dimension. The vector size must match the src Image dimensions, excluding the color channel. |
[in] | interp | InterpolationType to be used. Default is InterpolationType::linear. |
void ecvl::Rotate2D | ( | const ecvl::Image & | src, |
ecvl::Image & | dst, | ||
double | angle, | ||
const std::vector< double > & | center = {} , |
||
double | scale = 1.0 , |
||
InterpolationType | interp = InterpolationType::linear |
||
) |
Rotates an Image.
The Rotate2D procedure rotates an Image of a given angle (expressed in degrees) in a clockwise manner, with respect to a given center. The value of unknown pixels in the output Image are set to 0. The output Image is guaranteed to have the same dimensions as the input one. An optional scale parameter can be provided: this won't change the output Image size, but the image is scaled during rotation. Different interpolation types are available, see InterpolationType.
[in] | src | The input Image. |
[out] | dst | The output rotated Image. |
[in] | angle | The rotation angle in degrees. |
[in] | center | A std::vector<double> representing the coordinates of the rotation center. If empty, the center of the image is used. |
[in] | scale | Optional scaling factor. |
[in] | interp | Interpolation type used. Default is InterpolationType::linear. |
void ecvl::RotateFullImage2D | ( | const ecvl::Image & | src, |
ecvl::Image & | dst, | ||
double | angle, | ||
double | scale = 1.0 , |
||
InterpolationType | interp = InterpolationType::linear |
||
) |
Rotates an Image resizing the output accordingly.
The RotateFullImage2D procedure rotates an Image of a given angle (expressed in degrees) in a clockwise manner. The value of unknown pixels in the output Image are set to 0. The output Image is guaranteed to contain all the pixels of the rotated image. Thus, its dimensions can be different from those of the input. An optional scale parameter can be provided. Different interpolation types are available, see InterpolationType.
[in] | src | The input Image. |
[out] | dst | The rotated output Image. |
[in] | angle | The rotation angle in degrees. |
[in] | scale | Optional scaling factor. |
[in] | interp | Interpolation type used. Default is InterpolationType::linear. |
void ecvl::Salt | ( | const Image & | src, |
Image & | dst, | ||
double | p, | ||
bool | per_channel = false , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Adds salt noise (white pixels) to an Image.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | p | Probability of replacing a pixel with salt noise. |
[in] | per_channel | If true, noise is not considered pixel-wise but channel-wise. |
[in] | seed | Seed to use for this function's random number generator. |
void ecvl::SaltAndPepper | ( | const Image & | src, |
Image & | dst, | ||
double | p, | ||
bool | per_channel = false , |
||
const unsigned | seed = std::default_random_engine::default_seed |
||
) |
Adds salt and pepper noise (white and black pixels) to an Image. White and black pixels are equally likely.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | p | Probability of replacing a pixel with salt and pepper noise. |
[in] | per_channel | If true, noise is not considered pixel-wise but channel-wise. |
[in] | seed | Seed to use for this function's random number generator. |
TypeInfo<ODT>::basetype ecvl::saturate_cast | ( | IDT | v | ) |
Saturate a value (of any type) to the specified type.
Given an input of any type the saturate_cast function provide an output return value of the specified type applying saturation. When the input value in greater than the maximum possible value (max) for the output type, the max value is returned. When the input value in lower than the minimum possible value (min) for the output type, the min value is returned.
[in] | v | Input value (of any type). |
Definition at line 36 of file saturate_cast.h.
ODT ecvl::saturate_cast | ( | const IDT & | v | ) |
Saturate a value (of any type) to the specified type.
Given an input of any type the saturate_cast function provide an output return value of the specified type applying saturation. When the input value in greater than the maximum possible value (max) for the output type, the max value is returned. When the input value in lower than the minimum possible value (min) for the output type, the min value is returned.
[in] | v | Input value (of any type). |
Definition at line 64 of file saturate_cast.h.
void ecvl::ScaleTo | ( | const Image & | src, |
Image & | dst, | ||
const double & | new_min, | ||
const double & | new_max | ||
) |
void ecvl::SeparableFilter2D | ( | const Image & | src, |
Image & | dst, | ||
const std::vector< double > & | kerX, | ||
const std::vector< double > & | kerY, | ||
DataType | type = DataType::none |
||
) |
Convolves an Image with a couple of 1-dimensional kernels.
[in] | src | Input Image. |
[out] | dst | Output Image. |
[in] | kerX | Convolution kernel for the X-axis. |
[in] | kerY | Convolution kernel for the Y-axis. |
[in] | type | Destination ecvl::DataType. If DataType::none, the same of src is used. |
Performs a shallow copy of the source Image into the destination.
The ShallowCopyImage() procedure takes an Image and copies the fields values into destination Image. This means that source and destination Image(s) will point to the same Image data in memory. The data ownership of the source Image will be preserved, i.e. the result of the IsOwner() method on the source Image will be the same before and after the execution of the ShallowCopyImage(). Destination Image will never be the owner of the data. Source and destination Image(s) cannot be the same.
void ecvl::SliceTimingCorrection | ( | const Image & | src, |
Image & | dst, | ||
bool | odd = false , |
||
bool | down = false |
||
) |
Corrects each voxel's time-series. Slice timing correction works by using (Hanning-windowed) sinc interpolation to shift each time-series by an appropriate fraction of a TR relative to the middle of the TR period. The default slice order acquisition is from the bottom of the brain to the top.
[in] | src | Input Image. It must be with channels "xyzt" and with spacings (distance between consecutive voxels on each dimensions). |
[out] | dst | Output Image. It will be with DataType::float32. |
[in] | odd | Slices were acquired with interleaved order (0, 2, 4... 1, 3, 5...) |
[in] | down | Slices were acquired from the top of the brain to the bottom |
Calculate the distance squared between two ecvl::Point2i.
[in] | a | First point integer coordinates. |
[in] | b | Second point integer coordinates. |
Stack a sequence of Images along the depth dimension (images width and height must match)
[in] | src | vector of input Images. It must be with channels "xyc". |
[out] | dst | Output Image. |
InterpolationType ecvl::StrToInterpolationType | ( | const std::string & | interp, |
const std::string & | aug_name | ||
) |
|
inline |
Definition at line 118 of file arithmetic.h.
void ecvl::Sub | ( | const Image & | src1, |
const ST2 & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 119 of file arithmetic.h.
void ecvl::Sub | ( | const ST1 & | src1, |
const Image & | src2, | ||
Image & | dst, | ||
DataType | dst_type = DataType::none , |
||
bool | saturate = true |
||
) |
Definition at line 120 of file arithmetic.h.
void ecvl::TensorToImage | ( | Tensor *& | t, |
Image & | img | ||
) |
Convert an EDDL Tensor into an ECVL Image.
Tensor dimensions must be \(C\) x \(H\) x \(W\) or \(N\) x \(C\) x \(H\) x \(W\), where:
\(N\) = batch size
\(C\) = channels
\(H\) = height
\(W\) = width
[in] | t | Input EDDL Tensor. |
[out] | img | Output ECVL Image. It is a "xyo" with DataType::float32 and ColorType::none Image. |
void ecvl::TensorToView | ( | Tensor *& | t, |
View< DataType::float32 > & | v | ||
) |
Convert an EDDL Tensor into an ECVL View.
Tensor dimensions must be \(C\) x \(H\) x \(W\) or \(N\) x \(C\) x \(H\) x \(W\), where:
\(N\) = batch size
\(C\) = channels
\(H\) = height
\(W\) = width
[in] | t | Input EDDL Tensor. |
[out] | v | Output ECVL View. It is a "xyo" with ColorType::none View. |
void ecvl::Threshold | ( | const Image & | src, |
Image & | dst, | ||
double | thresh, | ||
double | maxval, | ||
ThresholdingType | thresh_type = ThresholdingType::BINARY |
||
) |
Applies a fixed threshold to an input Image.
The Threshold() function applies a fixed thresholding to an input Image. The function is useful to get a binary image out of a grayscale (ColorType::GRAY) Image or to remove noise filtering out pixels with too small or too large values. Anyway, the function can be applied to any input Image. The pixels up to "thresh" value will be set to 0, the pixels above this value will be set to "maxvalue" if "thresh_type" is ThresholdingType::BINARY (default). The opposite will happen if "thresh_type" is ThresholdingType::BINARY_INV.
[in] | src | Input Image on which to apply the threshold. |
[out] | dst | The output thresholded Image. |
[in] | thresh | Threshold value. |
[in] | maxval | The maximum values in the thresholded Image. |
[in] | thresh_type | Type of threshold to be applied, see ThresholdingType. The default value is ThresholdingType::BINARY. |
Swap rows and columns of an Image.
Vertical concatenation of images (with the same number of columns)
[in] | src | vector of input Images. |
[out] | dst | Output Image. |
int ecvl::vsize | ( | const std::vector< T > & | v | ) |
wxImage ecvl::WxFromImg | ( | Image & | img | ) |
Convert an ECVL Image into a wxImage.
[in] | img | Input ECVL Image. |