/******************************************************************** ** 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 : ICLBlob/src/FMCreator.cpp ** ** Module : ICLBlob ** ** 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 using namespace std; namespace icl{ struct DefaultFMCreator : public FMCreator{ // {{{ open DefaultFMCreator(const Size &size, format fmt, vector refcolor, vector thresholds){ m_oSize = size; m_eFormat = fmt; m_vecRefColor = refcolor; m_vecThresholds = thresholds; m_poFM = new Img8u(size,formatMatrix); ICLASSERT_RETURN(refcolor.size() == thresholds.size()); ICLASSERT_RETURN(refcolor.size() > 0); } virtual ~DefaultFMCreator(){ delete m_poFM; } Size m_oSize; format m_eFormat; vector m_vecRefColor; vector m_vecThresholds; Img8u *m_poFM; virtual const ImgBase *getLastFM() const{ return m_poFM; } virtual Size getSize(){ return m_oSize; } virtual format getFormat(){ return m_eFormat; } virtual Img8u* getFM(Img8u *image){ ICLASSERT_RETURN_VAL(image && m_poFM , 0); ICLASSERT_RETURN_VAL(image->getChannels() == (int)m_vecRefColor.size() , 0); ICLASSERT_RETURN_VAL(image->getSize() == m_poFM->getSize(), 0); ICLASSERT_RETURN_VAL(image->getSize() == m_oSize, 0); Img8u src = *image; Img8u dst = *m_poFM; int nc = image->getChannels(); icl8u *pucDst = dst.getData(0); // 1 channel int t0 = m_vecThresholds[0]; int r0 = m_vecRefColor[0]; icl8u *pucSrc0 = src.getData(0); icl8u *pucSrc0End = src.getData(0)+m_oSize.getDim(); if(nc == 1){ for(;pucSrc0!=pucSrc0End;++pucSrc0,++pucDst){ *pucDst = 255 * (abs(*pucSrc0-r0) vecSrc(nc); for(int i=0;igetData(i); } for(int c=0;pucSrc0!=pucSrc0End;++pucDst,++pucSrc0){ *pucDst = 255 * (abs(*pucSrc0-r0) refcolor, vector thresholds){ // {{{ open return new DefaultFMCreator(size,fmt,refcolor,thresholds); } // }}} }