/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2012 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLAlgorithms/src/HoughLineDetector.cpp ** ** Module : ICLAlgorithms ** ** Authors: Christof Elbrechter ** ** ** ** ** ** Commercial License ** ** ICL can be used commercially, please refer to our website ** ** www.iclcv.org for more details. ** ** ** ** GNU General Public License Usage ** ** Alternatively, this file may be used under the terms of the ** ** GNU General Public License version 3.0 as published by the ** ** Free Software Foundation and appearing in the file LICENSE.GPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the GNU General Public License ** ** version 3.0 requirements will be met: ** ** http://www.gnu.org/copyleft/gpl.html. ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** *********************************************************************/ #include #include #include namespace icl{ HoughLineDetector::HoughLineDetector(float dRho, float dR, const Range32f rRange, float rInhibitionRange, float rhoInhibitionRange, bool gaussianInhib, bool blurHoughSpace,bool dilateEntries,bool blurredSampling): m_dRho(dRho),m_rRange(rRange),m_rInhib(rInhibitionRange),m_rhoInhib(rhoInhibitionRange), m_gaussianInhibition(gaussianInhib), m_blurHoughSpace(blurHoughSpace),m_dilateEntries(dilateEntries), m_blurredSampling(blurredSampling){ m_w = ceil(2*M_PI/dRho); m_h = (rRange.maxVal-rRange.minVal)/dR; m_image = Img32s(Size(m_w,m_h),1); m_lut = m_image[0]; m_mr = (m_h-1)/(rRange.maxVal-rRange.minVal); m_br = -rRange.minVal * m_mr; m_mrho = (m_w-1)/(2*M_PI); if(gaussianInhib){ /// create inhibition image float dx = m_rhoInhib/(2*M_PI) * float(m_w); float dy = m_rInhib/(m_rRange.maxVal-m_rRange.minVal) * float(m_h); int w = 2*dx, h=2*dy; if(dx >0 && dy >0){ m_inhibitImage = Img32f(Size(2*dx,2*dy),1); Channel32f I = m_inhibitImage[0]; Point32f c(I.getWidth()/2,I.getHeight()/2); for(int x=0;xasImg(); ICL_DELETE(image); m_image.setFullROI(); m_lut = m_image[0]; } } std::vector HoughLineDetector::getLines(int max) { blur_hough_space_if_necessary(); std::vector ls; ls.reserve(max); for(int i=0;i HoughLineDetector::getLines(int max, std::vector &significances){ blur_hough_space_if_necessary(); std::vector ls; ls.reserve(max); significances.clear(); significances.reserve(max); int firstMax = -1; for(int i=0;i