// -*- c-basic-offset: 4 -*- /** @file CalculateOverlap.cpp * * @brief declaration of class to calculate overlap between different images * * @author Thomas Modes * * $Id$ * */ /* 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 software 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 software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "CalculateOverlap.h" namespace HuginBase { using namespace hugin_utils; CalculateImageOverlap::CalculateImageOverlap(const HuginBase::PanoramaData *pano):m_pano(pano) { m_nrImg=pano->getNrOfImages(); if(m_nrImg>0) { m_overlap.resize(m_nrImg); PanoramaOptions opts=pano->getOptions(); m_transform.resize(m_nrImg); m_invTransform.resize(m_nrImg); for(unsigned int i=0;icreateTransform(*pano,i,opts); m_invTransform[i]=new PTools::Transform; m_invTransform[i]->createInvTransform(*pano,i,opts); }; // per default we are testing all images fill_set(testImages,0,m_nrImg-1); }; }; CalculateImageOverlap::~CalculateImageOverlap() { for(unsigned int i=0;igetImage(*it); vigra::Rect2D c=vigra::Rect2D(img.getSize()); if(img.getCropMode()!=SrcPanoImage::NO_CROP) { c&=img.getCropRect(); }; unsigned int frequency=std::min(steps,std::min(c.width(),c.height())); if(frequency<2) frequency=2; std::vector overlapCounter; overlapCounter.resize(m_nrImg,0); unsigned int pointCounter=0; for (unsigned int x=0; xtransformImgCoord(xi,yi,xc,yc)) { //now, check if point is inside an other image for(unsigned int j=0;jtransformImgCoord(xj,yj,xi,yi)) { p.x=xj; p.y=yj; if(m_pano->getImage(j).isInside(p,true)) { overlapCounter[j]++; }; }; }; }; }; }; }; //now calculate overlap and save m_overlap[*it][*it]=1.0; if(pointCounter>0) { for(unsigned int k=0;k(m_overlap[i][j],m_overlap[j][i]); }; }; UIntSet CalculateImageOverlap::getOverlapForImage(unsigned int i) { UIntSet overlapImgs; for(unsigned int j=0;j0) { overlapImgs.insert(j); }; }; }; return overlapImgs; }; void CalculateImageOverlap::limitToImages(UIntSet img) { testImages=img; }; } // namespace