#ifndef _OTB_TRISKELE_I_IMAGE_HPP #define _OTB_TRISKELE_I_IMAGE_HPP #include #include #include #include "triskeleBase.hpp" #include "triskeleGdalGetType.hpp" namespace otb { namespace triskele { /** Interface Image */ template class IImage { public: IImage (const std::string &imageFilename) : filename (imageFilename), read (false) {} ~IImage () { close(); if (pixels) delete[] pixels; pixels = nullptr; } PixelT *getPixels () { return pixels; } PixelT getValue (const DimImg &id) const { return pixels[id]; } PixelT getValue (const Point &point) const { return pixels[pointToId (size, point)]; } const std::string &getFilename () const { return filename; } DimImg getPixelsCount () const { return (DimImg)size.width * (DimImg)size.height; } const Size &getSize () const { return size; } GDALDataType getDataType () const { return dataType; } void readImage (const Point &cropOrig, const Size &cropSize); void readImage () { readImage (Point(), size); } void close (); const bool &isRead () const { return read; } bool isEmpty () const { return getPixelsCount () == 0; } private: IImage (const IImage &o) = delete; IImage &operator= (const IImage&) = delete; private: static uint32_t gdalCount; std::string filename; Size size; GDALDataType dataType; GDALDataset *gdalInputDataset; PixelT *pixels; bool read; }; #include "IImage.tpp" } // triskele } // otb #endif // _OTB_TRISKELE_I_IMAGE_HPP