#ifndef ICL_PIXEL_REF_H #define ICL_PIXEL_REF_H #include #include #include #include #include #include namespace icl{ /// Pixel-Type class for copying image pixles to image pixels /** PixelRef instances are returned by an images operator()(int x, int y) It allows to write: Img8u a = ...; Img8u b = ...; a(5,6) = b(3,2); Furthermore it provides a list of setter functions, which allow to set up image pixels form other data types like vectors, ranges (iterator based) and even icl::FixedMatrix. Most of the functions are channel count save, i.e. they throw an ICLException if source channel count is not compatible. */ template class PixelRef{ /// Internal data std::vector m_data; public: /// Empty constructor, create a null pixel ref with 0 length inline PixelRef(){} /// returs whether this instance is null (created with the empty constructor) inline bool isNull() const { return !m_data->size(); } /// single constructor to create a pixelref instance /** This should not be used manually. Rather you should use Img's operator()(int x, int y) */ inline PixelRef(int x, int y, int width, std::vector > &data):m_data(data.size()){ int offs = x+width*y; for(unsigned int i=0;im_data[i] = data[i].get()+offs; } } /// PixelRef copy constructor (copies the reference, not the values) inline PixelRef(const PixelRef &other):m_data(other.m_data){} /// assignment operator which copies the values (most common) /** This operator allows to write imageA(x,y) = imageB(a,b); */ inline PixelRef &operator=(const PixelRef &other)throw (ICLException){ ICLASSERT_THROW(other.m_data.size() == m_data.size(),ICLException("incompatible channel count")); for(unsigned int i=0;i &vec)throw (ICLException){ ICLASSERT_THROW(vec.size() == m_data.size(),ICLException("incompatible channel count")); for(unsigned int i=0;i imageA(x,y) = Color(2,3,4); */ template inline PixelRef &operator=(const FixedMatrix &mat)throw (ICLException){ ICLASSERT_THROW((m_data.size() == FixedMatrix::DIM), ICLException("channel count and matrix dim are incompatible")); for(unsigned int i=0;i(mat[i]); } return *this; } /// copies image data into a std::vector inline std::vector asVec() const{ std::vector v(m_data.size()); for(unsigned int i=0;i inline void setFromRange(ForwardIterator begin, ForwardIterator end) throw (ICLException){ for(unsigned int i=0;i