modifié : CMakeListsOTB.txt modifié : LICENSE modifié : MakefileNoOTB modifié : Readme.html modifié : Readme.txt modifié : include/Appli/Option.hpp modifié : include/Appli/Selected.hpp modifié : include/Appli/Selected.tpp modifié : include/ArrayTree/ArrayTreeBuilder.hpp modifié : include/ArrayTree/ArrayTreeBuilder.tpp modifié : include/ArrayTree/Border.hpp modifié : include/ArrayTree/Border.tpp modifié : include/ArrayTree/GraphWalker.hpp modifié : include/ArrayTree/GraphWalker.tpp modifié : include/ArrayTree/Leader.hpp modifié : include/ArrayTree/Leader.tpp modifié : include/ArrayTree/Weight.hpp modifié : include/ArrayTree/Weight.tpp modifié : include/ArrayTree/triskeleArrayTreeBase.hpp modifié : include/ArrayTree/triskeleArrayTreeBase.tpp modifié : include/ArrayTree/triskeleSort.hpp modifié : include/ArrayTree/triskeleSort.tpp modifié : include/AttributeProfiles.hpp modifié : include/AttributeProfiles.tpp modifié : include/Attributes/AreaAttributes.hpp modifié : include/Attributes/AreaAttributes.tpp modifié : include/Attributes/AverageAttributes.hpp modifié : include/Attributes/AverageAttributes.tpp modifié : include/Attributes/MoIAttributes.hpp modifié : include/Attributes/MoIAttributes.tpp modifié : include/Attributes/SDAttributes.hpp modifié : include/Attributes/SDAttributes.tpp modifié : include/Attributes/WeightAttributes.hpp modifié : include/Attributes/WeightAttributes.tpp modifié : include/Attributes/XYAttributes.hpp modifié : include/Attributes/XYAttributes.tpp modifié : include/CompAttribute.hpp modifié : include/CompAttribute.tpp modifié : include/IImage.hpp modifié : include/IImage.tpp modifié : include/QuadTree/QuadTreeBuilder.hpp modifié : include/Tree.hpp modifié : include/Tree.tpp modifié : include/TreeBuilder.hpp modifié : include/TreeBuilder.tpp modifié : include/TreeStats.hpp modifié : include/TreeStats.tpp modifié : include/XMLTree/XMLTreeBuilder.hpp modifié : include/triskeleBase.hpp modifié : include/triskeleBase.tpp modifié : include/triskeleDealThreads.hpp modifié : include/triskeleDealThreads.tpp modifié : include/triskeleDebug.hpp modifié : include/triskeleGdalGetType.hpp modifié : otb-module.cmake modifié : src/Appli/Option.cpp modifié : src/Appli/Selected.cpp modifié : src/ArrayTree/triskeleArrayTreeBase.cpp modifié : src/CMakeLists.txt modifié : src/IImage.cpp modifié : src/PerfArrayTreeBuilder.cpp modifié : src/QuadTree/QuadTreeBuilder.cpp modifié : src/TestArrayTreeBuilder.cpp modifié : src/Tree.cpp modifié : src/TreeStats.cpp modifié : src/XMLTree/XMLTreeBuilder.cpp modifié : src/apGenerator.cpp modifié : src/triskeleBase.cpp modifié : src/triskeleDebug.cpp
154 lines
3.6 KiB
C++
154 lines
3.6 KiB
C++
#ifndef _OTB_TRISKELE_I_IMAGE_TPP
|
|
#define _OTB_TRISKELE_I_IMAGE_TPP
|
|
|
|
// ========================================
|
|
template<typename PixelT>
|
|
inline void
|
|
Raster<PixelT>::setSize (const Size &size) {
|
|
DEF_LOG ("Raster::setSize", "size: " << size);
|
|
if (this->size == size)
|
|
return;
|
|
pixels.resize (DimImg (size.width)*DimImg (size.height));
|
|
this->size = size;
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline const Size &
|
|
Raster<PixelT>::getSize () const {
|
|
return size;
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline const PixelT *
|
|
Raster<PixelT>::getPixels () const {
|
|
return &pixels[0];
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline PixelT *
|
|
Raster<PixelT>::getPixels () {
|
|
return &pixels[0];
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline vector<PixelT> &
|
|
Raster<PixelT>::getPixelsVector () {
|
|
return pixels;
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline DimNodeId
|
|
Raster<PixelT>::pointIdx (const Point &p) const {
|
|
return point2idx (size, p);
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline PixelT
|
|
Raster<PixelT>::getValue (const DimImg &idx) const {
|
|
return pixels[idx];
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline PixelT
|
|
Raster<PixelT>::getValue (const Point &point) const {
|
|
return pixels [pointIdx (point)];
|
|
}
|
|
|
|
|
|
template<typename PixelT>
|
|
inline
|
|
Raster<PixelT>::Raster (const Size &size)
|
|
: size (NullSize),
|
|
pixels () {
|
|
setSize (size);
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline
|
|
Raster<PixelT>::Raster (const Raster &raster, const Rect &tile)
|
|
: size (tile.width, tile.height),
|
|
pixels () {
|
|
tile.cpToTile (raster.size, &raster.pixels[0], pixels);
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline
|
|
Raster<PixelT>::~Raster () {
|
|
}
|
|
|
|
// ========================================
|
|
inline void
|
|
IImage::setFileName (string fileName) {
|
|
if (this->fileName == fileName)
|
|
return;
|
|
this->fileName = fileName;
|
|
if (read)
|
|
close ();
|
|
}
|
|
|
|
inline const string &
|
|
IImage::getFileName () const {
|
|
return fileName;
|
|
}
|
|
|
|
inline const Size &
|
|
IImage::getSize () const {
|
|
return size;
|
|
}
|
|
|
|
inline const DimChanel &
|
|
IImage::getBandCount () const {
|
|
return bandCount;
|
|
}
|
|
|
|
inline GDALDataType
|
|
IImage::getDataType () const {
|
|
return dataType;
|
|
}
|
|
|
|
inline const bool
|
|
IImage::isRead () const {
|
|
return read;
|
|
}
|
|
|
|
inline const bool
|
|
IImage::isEmpty () const {
|
|
return size == NullSize;
|
|
}
|
|
|
|
// ========================================
|
|
template<typename PixelT>
|
|
inline void
|
|
IImage::readBand (Raster<PixelT> &raster, const DimChanel &band) const {
|
|
readBand (raster, band, NullPoint, size);
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline void
|
|
IImage::readBand (Raster<PixelT> &raster, DimChanel band, const Point &cropOrig, const Size &cropSize) const {
|
|
DEF_LOG ("IImage::readBand", "band: " << band << " crop: " << cropOrig << " - " << cropSize);
|
|
BOOST_ASSERT (gdalInputDataset);
|
|
raster.setSize (cropSize);
|
|
band++; // !!! GDAL bands start at 1 (not 0 :-( )
|
|
GDALRasterBand &poBand = *gdalInputDataset->GetRasterBand (band);
|
|
GDALDataType bandType = poBand.GetRasterDataType ();
|
|
CPLErr err = poBand.RasterIO (GF_Read, cropOrig.x, cropOrig.y, cropSize.width, cropSize.height,
|
|
raster.getPixels (), cropSize.width, cropSize.height, bandType, 0, 0);
|
|
if (err != CE_None)
|
|
cerr << "IImage::readBand: can't acces " << fileName << endl;
|
|
}
|
|
|
|
template<typename PixelT>
|
|
inline void
|
|
IImage::writeBand (PixelT *pixels, DimChanel band) const {
|
|
DEF_LOG ("IImage::writeBand", "band: " << band);
|
|
BOOST_ASSERT (gdalOutputDataset);
|
|
band++; // !!! GDAL layers starts at 1 (not 0 :-( )
|
|
GDALRasterBand &poBand = *gdalOutputDataset->GetRasterBand (band);
|
|
CPLErr err = poBand.RasterIO (GF_Write, 0, 0, size.width, size.height, pixels, size.width, size.height, dataType, 0, 0);
|
|
if (err != CE_None)
|
|
cerr << "IImage::writeBand: can't acces " << fileName << endl;
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_I_IMAGE_TPP
|