/* * NICE-Core - efficient algebra and computer vision methods * - libimage - An image/template for new NICE libraries * See file License for license information. */ #include "core/image/Pixel.h" #ifdef NICE_USELIB_FBASICS #include "core/basics/Exception.h" #else #include #endif namespace NICE { // Constructors: // ------------- template Pixel::Pixel():VectorT() { } template Pixel::Pixel(T gray):VectorT(1, gray) { } template Pixel::Pixel(T *color,size_t nochannels, const VectorBase::Mode mode):VectorT(color,nochannels, mode) { } template Pixel::Pixel(T r, T g, T b):VectorT(3) { this->data[0] = r; this->data[1] = g; this->data[2] = b; } template Pixel::operator T() const { if(this->size()==0) return 0; else return this->constData[0]; } template T Pixel::gray() const { if(this->size()==1) { return this->constData[0]; } else if(this->size()==0) { throw std::range_error("invalid channel number"); } else if(this->size()==3) { throw std::range_error("not implemented yet"); } else { throw std::range_error("invalid channel number"); } } template const T* Pixel::color() const { return this->constData; } template void Pixel::getColor(T *buffer) const { ippsCopy(this->constData, buffer, this->size()); } }; // namespace NICE