81 lines
2.2 KiB
C++
81 lines
2.2 KiB
C++
#ifndef _OTB_TRISKELE_I_IMAGE_HPP
|
|
#define _OTB_TRISKELE_I_IMAGE_HPP
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <boost/assert.hpp>
|
|
|
|
#include <gdal_priv.h>
|
|
|
|
#include "triskeleBase.hpp"
|
|
#include "triskeleDebug.hpp"
|
|
#include "triskeleGdalGetType.hpp"
|
|
|
|
namespace triskele {
|
|
using namespace std;
|
|
|
|
template<typename PixelT>
|
|
class Raster {
|
|
private:
|
|
Size size;
|
|
vector<PixelT> pixels;
|
|
public:
|
|
inline void setSize (const Size &size);
|
|
inline const Size &getSize () const;
|
|
inline const PixelT *getPixels () const;
|
|
inline PixelT *getPixels ();
|
|
inline DimNodeId pointIdx (const Point &p) const;
|
|
inline PixelT getValue (const DimImg &idx) const;
|
|
inline PixelT getValue (const Point &point) const;
|
|
|
|
inline Raster (const Size &size = NullSize);
|
|
inline ~Raster ();
|
|
};
|
|
|
|
// ========================================
|
|
/** Interface Image */
|
|
class IImage {
|
|
public:
|
|
void setFileName (string fileName);
|
|
inline const string &getFileName () const;
|
|
inline const Size &getSize () const;
|
|
inline const DimChanel &getBandCount () const;
|
|
inline GDALDataType getDataType () const;
|
|
inline const bool isRead () const;
|
|
inline const bool isEmpty () const;
|
|
|
|
IImage (const std::string &imageFileName = "");
|
|
~IImage ();
|
|
|
|
void readImage ();
|
|
void createImage (const Size &size, const GDALDataType &dataType, const DimChanel &nbOutputBands);
|
|
void close ();
|
|
|
|
template<typename PixelT>
|
|
inline void readBand (Raster<PixelT> &raster, const DimChanel &band) const;
|
|
template<typename PixelT>
|
|
inline void readBand (Raster<PixelT> &raster, DimChanel band, const Point &cropOrig, const Size &cropSize) const;
|
|
template<typename PixelT>
|
|
inline void writeBand (PixelT *pixels, DimChanel band) const;
|
|
|
|
private:
|
|
IImage (const IImage &o) = delete;
|
|
IImage &operator= (const IImage&) = delete;
|
|
|
|
private:
|
|
static size_t gdalCount;
|
|
string fileName;
|
|
Size size;
|
|
DimChanel bandCount;
|
|
GDALDataType dataType;
|
|
GDALDataset *gdalInputDataset;
|
|
GDALDataset *gdalOutputDataset;
|
|
bool read;
|
|
};
|
|
|
|
#include "IImage.tpp"
|
|
|
|
} // triskele
|
|
|
|
#endif // _OTB_TRISKELE_I_IMAGE_HPP
|