The flutter shutter camera simulator
|
00001 /*midway.cpp*/ 00002 /* 00003 * Copyright 2012, 2010 IPOL Image Processing On Line http://www.ipol.im/ 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00028 #ifdef _OPENMP 00029 #include <omp.h> 00030 #endif 00031 #include <vector> 00032 #include <algorithm> 00033 00034 typedef std::pair<float,int> midway_pair; 00035 00036 bool pairs_order( midway_pair P1, midway_pair P2) 00037 { 00038 return P1.first< P2.first; 00039 } 00040 00041 00051 void midway(float* I1,float* I2,int width,int height) 00052 { 00053 00054 00058 std::vector<midway_pair> P1; 00059 std::vector<midway_pair> P2; 00060 P1.resize(width*height); 00061 P2.resize(width*height); 00062 00063 for (int i=0; i<width*height; i++) 00064 { 00065 P1[i]=(std::make_pair(I1[i],i)); 00066 P2[i]=(std::make_pair(I2[i],i)); 00067 } 00068 00069 std::sort(P1.begin(), P1.end(),pairs_order); 00070 std::sort(P2.begin(), P2.end(),pairs_order); 00071 00072 00074 float temp; 00075 for (int i=0; i<width*height; i++) 00076 { 00077 temp=(P1[i].first+P2[i].first)/2; 00078 I1[P1[i].second]=temp; 00079 I2[P2[i].second]=temp; 00080 } 00081 00082 } 00083