/** * @brief Standard response functions * * * This file is a part of PFS CALIBRATION package. * ---------------------------------------------------------------------- * Copyright (C) 2004 Grzegorz Krawczyk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ---------------------------------------------------------------------- * * @author Grzegorz Krawczyk, * * $Id: responses.cpp,v 1.5 2006/03/21 12:47:37 gkrawczyk Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #define MIN_WEIGHT 1e-3 //#define MIN_WEIGHT 0.0f void dump_gnuplot( const char* filename, const float* array, int M ) { FILE* fp = fopen(filename, "w"); fprintf(fp, "# GNUPlot dump\n"); for( int i=0 ; iMmax ) w[m] = 0.0f; else { // gkrawczyk: that's not really a gaussian, but equation is // taken from Robertson02 paper. float weight = exp( -sigma * (m-mid) * (m-mid) / mid2 ); if( weightM ) std::cerr << "response: camera value out of range," << " m=" << m << std::endl; else I[m] = val; } return true; } bool weightsLoad( FILE* file, float* w, int M) { char line[1024]; int m=0,c=0; // parse weighting function matrix header while( fgets(line, 1024, file) ) if( sscanf(line, "# rows: %d\n", &m) == 1 ) break; if( m!=M ) { std::cerr << "response: number of input levels is different," << " M=" << M << " m=" << m << std::endl; return false; } while( fgets(line, 1024, file) ) if( sscanf(line, "# columns: %d\n", &c) == 1 ) break; if( c!=2 ) return false; // read response for( int i=0 ; i1 ) // there is someting to interpolate { float delta= (I[m2]-I[m1]) / (m2-m1); if( I[m2]<=0.0f ) delta = (I[m1] - I[m1-1])/2.0f; // for some wierd data use gradient for( int m=m1+1 ; m