The flutter shutter camera simulator
midway.cpp
Go to the documentation of this file.
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 
00027 #include <vector>
00028 #include <algorithm>
00029 
00030 typedef std::pair<float,int> midway_pair;
00031 
00032 bool pairs_order( midway_pair P1, midway_pair P2)
00033 {
00034     return P1.first< P2.first;
00035 }
00036 
00037 
00047 void midway(float* I1,float* I2,int width,int height)
00048 {
00049 
00050 
00054     std::vector<midway_pair> P1;
00055     std::vector<midway_pair> P2;
00056     P1.resize(width*height);
00057     P2.resize(width*height);
00058 
00059     for (int i=0; i<width*height; i++)
00060     {
00061         P1[i]=(std::make_pair(I1[i],i));
00062         P2[i]=(std::make_pair(I2[i],i));
00063     }
00064 
00065     std::sort(P1.begin(), P1.end(),pairs_order);
00066     std::sort(P2.begin(), P2.end(),pairs_order);
00067 
00068 
00070     float temp;
00071     for (int i=0; i<width*height; i++)
00072     {
00073         temp=(P1[i].first+P2[i].first)/2;
00074         I1[P1[i].second]=temp;
00075         I2[P2[i].second]=temp;
00076     }
00077 
00078 }
00079 
 All Files Functions Variables Typedefs Defines