/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* $Id: db_utilities.cpp,v 1.4 2011/06/17 14:03:31 mbansal Exp $ */ #include "db_utilities.h" #include #include float** db_SetupImageReferences_f(float *im,int w,int h) { int i; float **img; assert(im); img=new float* [h]; for(i=0;i must be a 2D image array with the same image size // ---> the size of the input and output images must be same // // ------------------------------------------------------------------------------------------------------------ ; void db_CopyImage_u(unsigned char **d,const unsigned char * const *s, int w, int h, int over_allocation) { int i; for (i=0;i(lut_x[j][i]); //yd = static_cast(lut_y[j][i]); xd = (unsigned int)(lut_x[j][i]); yd = (unsigned int)(lut_y[j][i]); if ( xd >= w || yd >= h || xd < 0 || yd < 0) dst[j][i] = 0; else dst[j][i] = src[yd][xd]; } } inline void db_WarpImageLutBilinear_u(const unsigned char * const * src, unsigned char ** dst, int w, int h, const float * const * lut_x,const float * const* lut_y) { assert(src && dst); double xd=0.0, yd=0.0; for ( int i = 0; i < w; ++i ) for ( int j = 0; j < h; ++j ) { xd = static_cast(lut_x[j][i]); yd = static_cast(lut_y[j][i]); if ( xd > w || yd > h || xd < 0.0 || yd < 0.0) dst[j][i] = 0; else dst[j][i] = db_BilinearInterpolation(yd, xd, src); } } void db_WarpImageLut_u(const unsigned char * const * src, unsigned char ** dst, int w, int h, const float * const * lut_x,const float * const * lut_y, int type) { switch (type) { case DB_WARP_FAST: db_WarpImageLutFast_u(src,dst,w,h,lut_x,lut_y); break; case DB_WARP_BILINEAR: db_WarpImageLutBilinear_u(src,dst,w,h,lut_x,lut_y); break; default: break; } } void db_PrintDoubleVector(double *a,long size) { printf("[ "); for(long i=0;i