WSL/SLF GitLab Repository

Commit 3933137d authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Even more size_t fixes...

parent 0b611cd1
......@@ -51,13 +51,13 @@ DEMObject::DEMObject(const slope_type& i_algorithm)
/**
* @brief Constructor that sets variables.
* @param i_ncols (unsigned int) number of colums in the grid2D
* @param i_nrows (unsigned int) number of rows in the grid2D
* @param i_cellsize (double) value for cellsize in grid2D
* @param i_ncols number of colums in the grid2D
* @param i_nrows number of rows in the grid2D
* @param i_cellsize value for cellsize in grid2D
* @param i_llcorner lower lower corner point
* @param i_algorithm specify the default algorithm to use for slope computation (default=DFLT)
*/
DEMObject::DEMObject(const unsigned int& i_ncols, const unsigned int& i_nrows,
DEMObject::DEMObject(const size_t& i_ncols, const size_t& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const slope_type& i_algorithm)
: Grid2DObject(i_ncols, i_nrows, i_cellsize, i_llcorner),
slope(), azi(), curvature(), Nx(), Ny(), Nz(),
......@@ -72,15 +72,15 @@ DEMObject::DEMObject(const unsigned int& i_ncols, const unsigned int& i_nrows,
/**
* @brief Constructor that sets variables.
* @param i_ncols (unsigned int) number of colums in the grid2D
* @param i_nrows (unsigned int) number of rows in the grid2D
* @param i_cellsize (double) value for cellsize in grid2D
* @param i_ncols number of colums in the grid2D
* @param i_nrows number of rows in the grid2D
* @param i_cellsize value for cellsize in grid2D
* @param i_llcorner lower lower corner point
* @param i_altitude (Array2D\<double\>&) grid2D of elevations
* @param i_update (bool) also update slope/normals/curvatures and their min/max? (default=true)
* @param i_altitude grid2D of elevations
* @param i_update also update slope/normals/curvatures and their min/max? (default=true)
* @param i_algorithm specify the default algorithm to use for slope computation (default=DFLT)
*/
DEMObject::DEMObject(const unsigned int& i_ncols, const unsigned int& i_nrows,
DEMObject::DEMObject(const size_t& i_ncols, const size_t& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const Array2D<double>& i_altitude,
const bool& i_update, const slope_type& i_algorithm)
: Grid2DObject(i_ncols, i_nrows, i_cellsize, i_llcorner, i_altitude),
......@@ -101,8 +101,8 @@ DEMObject::DEMObject(const unsigned int& i_ncols, const unsigned int& i_nrows,
/**
* @brief Constructor that sets variables from a Grid2DObject
* @param i_dem (Grid2DObject&) grid contained in a Grid2DObject
* @param i_update (bool) also update slope/normals/curvatures and their min/max? (default=true)
* @param i_dem grid contained in a Grid2DObject
* @param i_update also update slope/normals/curvatures and their min/max? (default=true)
* @param i_algorithm specify the default algorithm to use for slope computation (default=DFLT)
*/
DEMObject::DEMObject(const Grid2DObject& i_dem, const bool& i_update, const slope_type& i_algorithm)
......@@ -125,16 +125,16 @@ DEMObject::DEMObject(const Grid2DObject& i_dem, const bool& i_update, const slop
/**
* @brief Constructor that sets variables from a subset of another DEMObject,
* given an origin (X,Y) (first index being 0) and a number of columns and rows
* @param i_dem (DEMObject&) dem contained in a DEMDObject
* @param i_nx (unsigned int&) X coordinate of the new origin
* @param i_ny (unsigned int&) Y coordinate of the new origin
* @param i_ncols (unsigned int&) number of columns for the subset dem
* @param i_nrows (unsigned int&) number of rows for the subset dem
* @param i_update (bool) also update slope/normals/curvatures and their min/max? (default=true)
* @param i_dem dem contained in a DEMDObject
* @param i_nx X coordinate of the new origin
* @param i_ny Y coordinate of the new origin
* @param i_ncols number of columns for the subset dem
* @param i_nrows number of rows for the subset dem
* @param i_update also update slope/normals/curvatures and their min/max? (default=true)
* @param i_algorithm specify the default algorithm to use for slope computation (default=DFLT)
*/
DEMObject::DEMObject(const DEMObject& i_dem, const unsigned int& i_nx, const unsigned int& i_ny,
const unsigned int& i_ncols, const unsigned int& i_nrows,
DEMObject::DEMObject(const DEMObject& i_dem, const size_t& i_nx, const size_t& i_ny,
const size_t& i_ncols, const size_t& i_nrows,
const bool& i_update, const slope_type& i_algorithm)
: Grid2DObject(i_dem, i_nx,i_ny, i_ncols,i_nrows),
slope(), azi(), curvature(), Nx(), Ny(), Nz(),
......@@ -157,7 +157,7 @@ DEMObject::DEMObject(const DEMObject& i_dem, const unsigned int& i_nx, const uns
} else {
//if the object is NOT in automatic update, we manually copy all non-empty arrays
//from the original set
unsigned int nx, ny;
size_t nx, ny;
i_dem.slope.size(nx, ny);
if(nx>0 && ny>0) {
......@@ -210,7 +210,7 @@ int DEMObject::getUpdatePpt() const {
* @brief Force the computation of the local slope, azimuth, normal vector and curvature.
* It has to be called manually since it can require some time to compute. Without this call,
* the above mentionned parameters are NOT up to date.
* @param algorithm (slope_type&) algorithm to use for computing slope, azimuth and normals
* @param algorithm algorithm to use for computing slope, azimuth and normals
*/
void DEMObject::update(const slope_type& algorithm) {
//This method recomputes the attributes that are not read as parameters
......@@ -238,7 +238,7 @@ void DEMObject::update(const slope_type& algorithm) {
* @brief Force the computation of the local slope, azimuth, normal vector and curvature.
* It has to be called manually since it can require some time to compute. Without this call,
* the above mentionned parameters are NOT up to date.
* @param algorithm (const string&) algorithm to use for computing slope, azimuth and normals
* @param algorithm algorithm to use for computing slope, azimuth and normals
* it is either:
* - HICK that uses the maximum downhill slope method (Dunn and Hickey, 1998)
* - FLEMING uses a 4 neighbors algorithm (Fleming and Hoffer, 1979)
......@@ -320,8 +320,8 @@ void DEMObject::printFailures() {
bool header=true;
if(update_flag&SLOPE) {
for ( unsigned int j = 0; j < nrows; j++ ) {
for ( unsigned int i = 0; i < ncols; i++ ) {
for ( size_t j = 0; j < nrows; j++ ) {
for ( size_t i = 0; i < ncols; i++ ) {
if((slope(i,j)==IOUtils::nodata) && (grid2D(i,j)!=IOUtils::nodata)) {
if(header==true) {
cerr << "[i] DEM slope could not be computed at the following points \n";
......@@ -335,8 +335,8 @@ void DEMObject::printFailures() {
}
if(update_flag&CURVATURE) {
for ( unsigned int j = 0; j < nrows; j++ ) {
for ( unsigned int i = 0; i < ncols; i++ ) {
for ( size_t j = 0; j < nrows; j++ ) {
for ( size_t i = 0; i < ncols; i++ ) {
if((curvature(i,j)==IOUtils::nodata) && (grid2D(i,j)!=IOUtils::nodata)) {
if(header==true) {
cerr << "[i] DEM curvature could not be computed at the following points \n";
......@@ -364,8 +364,8 @@ void DEMObject::printFailures() {
*/
void DEMObject::sanitize() {
if(slope_failures>0 || curvature_failures>0) {
for ( unsigned int j = 0; j < nrows; j++ ) {
for ( unsigned int i = 0; i < ncols; i++ ) {
for ( size_t j = 0; j < nrows; j++ ) {
for ( size_t i = 0; i < ncols; i++ ) {
if(update_flag&SLOPE) {
if((slope(i,j)==IOUtils::nodata) && (grid2D(i,j)!=IOUtils::nodata)) {
grid2D(i,j) = IOUtils::nodata;
......@@ -422,7 +422,7 @@ double DEMObject::horizontalDistance(Coords point1, const Coords& point2)
double DEMObject::terrainDistance(Coords point1, const Coords& point2) {
std::vector<GRID_POINT_2D> vec_points;
double distance=0.;
unsigned int last_point=0; //point 0 is always the starting point
size_t last_point=0; //point 0 is always the starting point
//Checking that both points use the same projection is done in getPointsBetween()
getPointsBetween(point1, point2, vec_points);
......@@ -430,11 +430,11 @@ double DEMObject::terrainDistance(Coords point1, const Coords& point2) {
return 0.;
}
for(unsigned int ii=1; ii<vec_points.size(); ii++) {
const unsigned int ix1=vec_points[last_point].ix;
const unsigned int iy1=vec_points[last_point].iy;
const unsigned int ix2=vec_points[ii].ix;
const unsigned int iy2=vec_points[ii].iy;
for(size_t ii=1; ii<vec_points.size(); ii++) {
const size_t ix1=vec_points[last_point].ix;
const size_t iy1=vec_points[last_point].iy;
const size_t ix2=vec_points[ii].ix;
const size_t iy2=vec_points[ii].iy;
if(grid2D(ix2,iy2)!=IOUtils::nodata) {
if(grid2D(ix1,iy1)!=IOUtils::nodata) {
......@@ -603,7 +603,7 @@ double DEMObject::getHorizon(const Coords& point, const double& bearing) {
//going through every point and looking for the highest tangent (which is also the highest angle)
double max_tangent = 0.;
for (unsigned int ii=0; ii < vec_points.size(); ii++) {
for (size_t ii=0; ii < vec_points.size(); ii++) {
const int ix = (int)vec_points[ii].ix;
const int iy = (int)vec_points[ii].iy;
const double delta_height = grid2D(ix, iy) - height0;
......@@ -658,8 +658,8 @@ void DEMObject::CalculateAziSlopeCurve(slope_type algorithm) {
}
//Now, calculate the parameters using the previously defined function pointer
for ( unsigned int j = 0; j < nrows; j++ ) {
for ( unsigned int i = 0; i < ncols; i++ ) {
for ( size_t j = 0; j < nrows; j++ ) {
for ( size_t i = 0; i < ncols; i++ ) {
if( grid2D(i,j) == IOUtils::nodata ) {
if(update_flag&SLOPE) {
slope(i,j) = azi(i,j) = IOUtils::nodata;
......@@ -693,8 +693,8 @@ void DEMObject::CalculateAziSlopeCurve(slope_type algorithm) {
}
if((update_flag&SLOPE) && (algorithm==D8)) { //extra processing required: discretization
for ( unsigned int j = 0; j < nrows; j++ ) {
for ( unsigned int i = 0; i < ncols; i++ ) {
for ( size_t j = 0; j < nrows; j++ ) {
for ( size_t i = 0; i < ncols; i++ ) {
//TODO: process flats by an extra algorithm
if(azi(i,j)!=IOUtils::nodata)
azi(i,j) = fmod(floor( (azi(i,j)+22.5)/45. )*45., 360.);
......@@ -837,7 +837,7 @@ double DEMObject::getCurvature(double A[4][4]) {
const double sqrt2 = sqrt(2.);
double sum=0.;
unsigned int count=0;
size_t count=0;
if(Zwe!=IOUtils::nodata) {
sum += 0.5*(A[2][2]-Zwe);
......@@ -965,7 +965,7 @@ double DEMObject::avgHeight(const double& z1, const double &z2, const double& z3
return IOUtils::nodata;
}
void DEMObject::getNeighbours(const unsigned int i, const unsigned int j, double A[4][4]) {
void DEMObject::getNeighbours(const size_t i, const size_t j, double A[4][4]) {
//this fills a 3x3 table containing the neighboring values
A[1][1] = safeGet(i-1, j+1);
A[1][2] = safeGet(i, j+1);
......
......@@ -76,18 +76,18 @@ class DEMObject : public Grid2DObject {
DEMObject(const slope_type& i_algorithm=DFLT);
DEMObject(const unsigned int& ncols_in, const unsigned int& nrows_in,
DEMObject(const size_t& ncols_in, const size_t& nrows_in,
const double& cellsize_in, const Coords& llcorner_in, const slope_type& i_algorithm=DFLT);
DEMObject(const unsigned int& ncols_in, const unsigned int& nrows_in,
DEMObject(const size_t& ncols_in, const size_t& nrows_in,
const double& cellsize_in, const Coords& llcorner_in, const Array2D<double>& altitude_in,
const bool& i_update=true, const slope_type& i_algorithm=DFLT);
DEMObject(const Grid2DObject& dem_in, const bool& i_update=true, const slope_type& i_algorithm=DFLT);
DEMObject (const DEMObject& i_dem,
const unsigned int& i_nx, const unsigned int& i_ny, //Point in the plane
const unsigned int& i_ncols, const unsigned int& i_nrows, //dimensions of the sub-plane
const size_t& i_nx, const size_t& i_ny, //Point in the plane
const size_t& i_ncols, const size_t& i_nrows, //dimensions of the sub-plane
const bool& i_update=true, const slope_type& i_algorithm=DFLT);
void setDefaultAlgorithm(const slope_type& i_algorithm);
......@@ -126,13 +126,13 @@ class DEMObject : public Grid2DObject {
double fillMissingGradient(const double& delta1, const double& delta2);
void surfaceGradient(double& dx_sum, double& dy_sum, double A[4][4]);
double avgHeight(const double& z1, const double &z2, const double& z3);
void getNeighbours(const unsigned int i, const unsigned int j, double A[4][4]);
void getNeighbours(const size_t i, const size_t j, double A[4][4]);
double safeGet(const int i, const int j);
int update_flag;
slope_type dflt_algorithm;
unsigned int slope_failures; ///<contains the number of points that have an elevation but no slope
unsigned int curvature_failures; ///<contains the number of points that have an elevation but no curvature
size_t slope_failures; ///<contains the number of points that have an elevation but no slope
size_t curvature_failures; ///<contains the number of points that have an elevation but no curvature
};
} //end namespace
......
......@@ -25,8 +25,8 @@ namespace mio {
Grid2DObject& Grid2DObject::operator=(const Grid2DObject& source) {
if(this != &source) {
grid2D = source.grid2D;
//ncols = source.ncols;
//nrows = source.nrows;
ncols = source.ncols;
nrows = source.nrows;
cellsize = source.cellsize;
llcorner = source.llcorner;
}
......@@ -37,29 +37,16 @@ Grid2DObject& Grid2DObject::operator=(const Grid2DObject& source) {
* Default constructor.
* grid2D attribute is initialized by Array2D default constructor.
*/
Grid2DObject::Grid2DObject() : grid2D(), ncols(0), nrows(0), cellsize(0), llcorner()
{
}
Grid2DObject::Grid2DObject() : grid2D(), ncols(0), nrows(0), cellsize(0), llcorner() {}
Grid2DObject::Grid2DObject(const size_t& i_ncols, const size_t& i_nrows,
const double& i_cellsize, const Coords& i_llcorner) : grid2D(i_ncols, i_nrows, IOUtils::nodata), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner)
{
//set metadata, grid2D already successfully created
//setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
}
const double& i_cellsize, const Coords& i_llcorner) : grid2D(i_ncols, i_nrows, IOUtils::nodata), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner) {}
Grid2DObject::Grid2DObject(const size_t& i_ncols, const size_t& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const Array2D<double>& i_grid2D) : grid2D(i_grid2D), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner)
{
//set(i_ncols, i_nrows, i_cellsize, i_llcorner, i_grid2D);
}
const double& i_cellsize, const Coords& i_llcorner, const Array2D<double>& i_grid2D) : grid2D(i_grid2D), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner) {}
Grid2DObject::Grid2DObject(const size_t& i_ncols, const size_t& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const double& init) : grid2D(i_ncols, i_nrows, init), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner)
{
//set metadata, grid2D already successfully created
//setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
}
const double& i_cellsize, const Coords& i_llcorner, const double& init) : grid2D(i_ncols, i_nrows, init), ncols(i_ncols), nrows(i_nrows), cellsize(i_cellsize), llcorner(i_llcorner) {}
Grid2DObject::Grid2DObject(const Grid2DObject& i_grid2Dobj, const size_t& i_nx, const size_t& i_ny,
const size_t& i_ncols, const size_t& i_nrows)
......@@ -71,8 +58,8 @@ Grid2DObject::Grid2DObject(const Grid2DObject& i_grid2Dobj, const size_t& i_nx,
//and we shift it by the correct X and Y distance
//llcorner = i_grid2Dobj.llcorner;
if( (llcorner.getEasting()!=IOUtils::nodata) && (llcorner.getNorthing()!=IOUtils::nodata) ) {
llcorner.setXY( llcorner.getEasting()+i_nx*i_grid2Dobj.cellsize,
llcorner.getNorthing()+i_ny*i_grid2Dobj.cellsize, IOUtils::nodata);
llcorner.setXY( llcorner.getEasting()+static_cast<double>(i_nx)*i_grid2Dobj.cellsize,
llcorner.getNorthing()+static_cast<double>(i_ny)*i_grid2Dobj.cellsize, IOUtils::nodata);
}
}
......
......@@ -52,9 +52,9 @@ Grid3DObject::Grid3DObject(const Grid3DObject& i_grid3Dobj,
//we take the previous corner (so we use the same projection parameters)
//and we shift it by the correct X and Y distance
if( (llcorner.getEasting()!=IOUtils::nodata) && (llcorner.getNorthing()!=IOUtils::nodata) ) {
llcorner.setXY( llcorner.getEasting()+i_nx*i_grid3Dobj.cellsize,
llcorner.getNorthing()+i_ny*i_grid3Dobj.cellsize,
llcorner.getAltitude()+i_nz*i_grid3Dobj.cellsize );
llcorner.setXY( llcorner.getEasting()+static_cast<double>(i_nx)*i_grid3Dobj.cellsize,
llcorner.getNorthing()+static_cast<double>(i_ny)*i_grid3Dobj.cellsize,
llcorner.getAltitude()+static_cast<double>(i_nz)*i_grid3Dobj.cellsize );
}
}
......
......@@ -193,9 +193,9 @@ size_t Meteo2DInterpolator::getArgumentsForAlgorithm(const std::string& param,
void Meteo2DInterpolator::checkMinMax(const double& minval, const double& maxval, Grid2DObject& gridobj)
{
const unsigned int nxy = gridobj.getNx() * gridobj.getNy();
const size_t nxy = gridobj.getNx() * gridobj.getNy();
for (unsigned int ii=0; ii<nxy; ii++){
for (size_t ii=0; ii<nxy; ii++){
double& value = gridobj.grid2D(ii);
if (value == IOUtils::nodata){
continue;
......
......@@ -30,8 +30,8 @@ namespace mio {
const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
Bilinear(o_grid, i_grid); //GridObjects always keep nodata
......@@ -41,8 +41,8 @@ const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject
const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
cubicBSpline(o_grid, i_grid); //GridObjects always keep nodata
......@@ -52,8 +52,8 @@ const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DOb
const Grid2DObject ResamplingAlgorithms2D::NearestNeighbour(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
NearestNeighbour(o_grid, i_grid); //GridObjects always keep nodata
......@@ -65,24 +65,24 @@ const Grid2DObject ResamplingAlgorithms2D::NearestNeighbour(const Grid2DObject &
///////////////////////////////////////////////////////////////////////
void ResamplingAlgorithms2D::NearestNeighbour(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{
const unsigned int org_ncols = i_grid.ncols;
const unsigned int org_nrows = i_grid.nrows;
const size_t org_ncols = i_grid.ncols;
const size_t org_nrows = i_grid.nrows;
const double scale_x = (double)o_grid.ncols / (double)org_ncols;
const double scale_y = (double)o_grid.nrows / (double)org_nrows;
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
unsigned int org_jj = (unsigned int) Optim::round( (double)jj/scale_y );
for (size_t jj=0; jj<o_grid.nrows; jj++) {
size_t org_jj = (size_t) Optim::round( (double)jj/scale_y );
if(org_jj>=org_nrows) org_jj=org_nrows-1;
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
unsigned int org_ii = (unsigned int) Optim::round( (double)ii/scale_x );
for (size_t ii=0; ii<o_grid.ncols; ii++) {
size_t org_ii = (size_t) Optim::round( (double)ii/scale_x );
if(org_ii>=org_ncols) org_ii=org_ncols-1;
o_grid(ii,jj) = i_grid(org_ii, org_jj);
}
}
}
double ResamplingAlgorithms2D::bilinear_pixel(const Grid2DObject &i_grid, const unsigned int &org_ii, const unsigned int &org_jj, const unsigned int &org_ncols, const unsigned int &org_nrows, const double &x, const double &y)
double ResamplingAlgorithms2D::bilinear_pixel(const Grid2DObject &i_grid, const size_t &org_ii, const size_t &org_jj, const size_t &org_ncols, const size_t &org_nrows, const double &x, const double &y)
{
if(org_jj>=(org_nrows-1) || org_ii>=(org_ncols-1)) return i_grid(org_ii, org_jj);
......@@ -131,19 +131,19 @@ double ResamplingAlgorithms2D::bilinear_pixel(const Grid2DObject &i_grid, const
void ResamplingAlgorithms2D::Bilinear(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{
const unsigned int org_ncols = i_grid.ncols;
const unsigned int org_nrows = i_grid.nrows;
const size_t org_ncols = i_grid.ncols;
const size_t org_nrows = i_grid.nrows;
const double scale_x = (double)o_grid.ncols / (double)org_ncols;
const double scale_y = (double)o_grid.nrows / (double)org_nrows;
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
for (size_t jj=0; jj<o_grid.nrows; jj++) {
const double org_y = (double)jj/scale_y;
const unsigned int org_jj = static_cast<unsigned int>( org_y );
const size_t org_jj = static_cast<size_t>( org_y );
const double y = org_y - (double)org_jj; //normalized y, between 0 and 1
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
for (size_t ii=0; ii<o_grid.ncols; ii++) {
const double org_x = (double)ii/scale_x;
const unsigned int org_ii = static_cast<unsigned int>( org_x );
const size_t org_ii = static_cast<size_t>( org_x );
const double x = org_x - (double)org_ii; //normalized x, between 0 and 1
o_grid(ii,jj) = bilinear_pixel(i_grid, org_ii, org_jj, org_ncols, org_nrows, x, y);
......@@ -163,19 +163,19 @@ double ResamplingAlgorithms2D::BSpline_weight(const double &x) {
void ResamplingAlgorithms2D::cubicBSpline(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{//see http://paulbourke.net/texture_colour/imageprocess/
const unsigned int org_ncols = i_grid.ncols;
const unsigned int org_nrows = i_grid.nrows;
const size_t org_ncols = i_grid.ncols;
const size_t org_nrows = i_grid.nrows;
const double scale_x = (double)o_grid.ncols / (double)org_ncols;
const double scale_y = (double)o_grid.nrows / (double)org_nrows;
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
for (size_t jj=0; jj<o_grid.nrows; jj++) {
const double org_y = (double)jj/scale_y;
const unsigned int org_jj = static_cast<unsigned int>( org_y );
const size_t org_jj = static_cast<size_t>( org_y );
const double dy = org_y - (double)org_jj; //normalized y, between 0 and 1
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
for (size_t ii=0; ii<o_grid.ncols; ii++) {
const double org_x = (double)ii/scale_x;
const unsigned int org_ii = static_cast<unsigned int>( org_x );
const size_t org_ii = static_cast<size_t>( org_x );
const double dx = org_x - (double)org_ii; //normalized x, between 0 and 1
double F = 0., max=-std::numeric_limits<double>::max(), min=std::numeric_limits<double>::max();
......
......@@ -44,7 +44,7 @@ class ResamplingAlgorithms2D {
static void Bilinear(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static void NearestNeighbour(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static double bilinear_pixel(const Grid2DObject &i_grid, const unsigned int &org_ii, const unsigned int &org_jj, const unsigned int &org_ncols, const unsigned int &org_nrows, const double &x, const double &y);
static double bilinear_pixel(const Grid2DObject &i_grid, const size_t &org_ii, const size_t &org_jj, const size_t &org_ncols, const size_t &org_nrows, const double &x, const double &y);
static double BSpline_weight(const double &x);
};
} //end namespace
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment