LayerStacks.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00008  /*  This is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2 of the License, or (at your option) any later version.
00012  *
00013  *  This software is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *  Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public
00019  *  License along with this software; if not, write to the Free Software
00020  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #include "LayerStacks.h"
00025 
00026 #include <panodata/PanoramaData.h>
00027 #include <algorithms/basic/CalculateOverlap.h>
00028 #include <algorithms/nona/ComputeImageROI.h>
00029 
00030 namespace HuginBase
00031 {
00032 using namespace std;
00033 
00034 vector<UIntSet> getHDRStacks(const PanoramaData & pano, UIntSet allImgs, PanoramaOptions opts)
00035 {
00036     vector<UIntSet> result;
00037 
00038     // if no images are available, return empty result vector
00039     if ( allImgs.empty() )
00040     {
00041         return result;
00042     }
00043 
00044     UIntSet stack;
00045 
00046     CalculateImageOverlap overlap(&pano);
00047     overlap.calculate(10);  // we are testing 10*10=100 points
00048     do {
00049         unsigned srcImg = *(allImgs.begin());
00050         stack.insert(srcImg);
00051         allImgs.erase(srcImg);
00052 
00053         // find all images that have a suitable overlap.
00054         for (UIntSet::iterator it = allImgs.begin(); it !=  allImgs.end(); ) {
00055             unsigned srcImg2 = *it;
00056             it++;
00057             if(overlap.getOverlap(srcImg,srcImg2)>opts.outputStacksMinOverlap)
00058             {
00059                 stack.insert(srcImg2);
00060                 allImgs.erase(srcImg2);
00061             }
00062         }
00063         result.push_back(stack);
00064         stack.clear();
00065     } while (allImgs.size() > 0);
00066 
00067     return result;
00068 }
00069 
00070 vector<UIntSet> getExposureLayers(const PanoramaData & pano, UIntSet allImgs, PanoramaOptions opts)
00071 {
00072     vector<UIntSet> result;
00073 
00074     // if no images are available, return empty result vector
00075     if ( allImgs.empty() )
00076     {
00077         return result;
00078     }
00079 
00080     UIntSet stack;
00081 
00082     do {
00083         unsigned srcImg = *(allImgs.begin());
00084         stack.insert(srcImg);
00085         allImgs.erase(srcImg);
00086 
00087         // find all images that have a suitable overlap.
00088         SrcPanoImage simg = pano.getSrcImage(srcImg);
00089         double maxEVDiff = opts.outputLayersExposureDiff;
00090         for (UIntSet::iterator it = allImgs.begin(); it !=  allImgs.end(); ) {
00091             unsigned srcImg2 = *it;
00092             it++;
00093             SrcPanoImage simg2 = pano.getSrcImage(srcImg2);
00094             if ( fabs(simg.getExposureValue() - simg2.getExposureValue()) < maxEVDiff )
00095             {
00096                 stack.insert(srcImg2);
00097                 allImgs.erase(srcImg2);
00098             }
00099         }
00100         result.push_back(stack);
00101         stack.clear();
00102     } while (allImgs.size() > 0);
00103 
00104     return result;
00105 }
00106 
00107 UIntSet getImagesinROI (const PanoramaData& pano, const UIntSet activeImages)
00108 {
00109     UIntSet images;
00110     PanoramaOptions opts = pano.getOptions();
00111     for (UIntSet::const_iterator it = activeImages.begin(); it != activeImages.end(); ++it)
00112     {
00113         vigra::Rect2D roi = estimateOutputROI(pano, opts, *it);
00114         if (! (roi.isEmpty())) {
00115             images.insert(*it);
00116         }
00117     }
00118     return images;
00119 }
00120 
00121 }

Generated on Thu Apr 24 01:25:37 2014 for Hugintrunk by  doxygen 1.3.9.1