#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); } // }}} }