SpatiumLib
Public Member Functions | List of all members
spatium::imgproc::Grayscale< T > Class Template Reference

Color image to grayscale. More...

#include <Grayscale.h>

Inheritance diagram for spatium::imgproc::Grayscale< T >:
Inheritance graph
[legend]
Collaboration diagram for spatium::imgproc::Grayscale< T >:
Collaboration graph
[legend]

Public Member Functions

 Grayscale (double redCoeff=0.2125, double greenCoeff=0.7154, double blueCoff=0.0721)
 Constructor. More...
 
bool apply (const Image< T, 3 > &input, Image< T, 1 > &output)
 Apply filter. More...
 
void setCoefficients (double redCoeff, double greenCoeff, double blueCoeff)
 Set RGB coefficients. More...
 
std::array< double, 3 > coefficients () const
 Get RGB coefficients. More...
 
- Public Member Functions inherited from spatium::imgproc::IImageFilter
virtual ~IImageFilter ()=default
 

Detailed Description

template<typename T = unsigned char>
class spatium::imgproc::Grayscale< T >

Color image to grayscale.

Convert color image as RGB format to grayscale.

Constructor & Destructor Documentation

◆ Grayscale()

template<typename T = unsigned char>
spatium::imgproc::Grayscale< T >::Grayscale ( double  redCoeff = 0.2125,
double  greenCoeff = 0.7154,
double  blueCoff = 0.0721 
)
inline

Constructor.

Coefficients are used to convert 3 RGB values to 1 grayscale value. Each coefficient is a weight for a partical channel: red, green and blue. The sum of the coefficients should be 1.

Parameters
[in]redCoeffRed coefficient (default = 0.2125)
[in]greenCoeffGreen coefficient (default = 0.7154)
[in]blueCoffBlue coefficient (default = 0.0721)

Member Function Documentation

◆ apply()

template<typename T = unsigned char>
bool spatium::imgproc::Grayscale< T >::apply ( const Image< T, 3 > &  input,
Image< T, 1 > &  output 
)
inline

Apply filter.

Parameters
[in]inputRGB image with 3 channels
[out]outputGrayscale image with 1 channel
Returns
True on success, false on image dimensions mismatch

◆ coefficients()

template<typename T = unsigned char>
std::array<double, 3> spatium::imgproc::Grayscale< T >::coefficients ( ) const
inline

Get RGB coefficients.

These coefficients are used to convert 3 RGB values to 1 grayscale value. Each coefficient is a weight for a partical channel: red, green and blue. The sum of the coefficients should be 1.

Returns
RGB coefficients

◆ setCoefficients()

template<typename T = unsigned char>
void spatium::imgproc::Grayscale< T >::setCoefficients ( double  redCoeff,
double  greenCoeff,
double  blueCoeff 
)
inline

Set RGB coefficients.

These coefficients are used to convert 3 RGB values to 1 grayscale value. Each coefficient is a weight for a partical channel: red, green and blue. The sum of the coefficients should be 1.

Parameters
[in]redCoeffRed coefficient (default = 0.2125)
[in]greenCoeffGreen coefficient (default = 0.7154)
[in]blueCoffBlue coefficient (default = 0.0721)

The documentation for this class was generated from the following file: