Example #1
0
void CorrectRect(Pt2di &  aP0,Pt2di &  aP1,const Pt2di & aSz)
{
    aP0 = Inf(aSz,Sup(aP0,Pt2di(0,0)));
    aP1 = Inf(aSz,Sup(aP1,Pt2di(0,0)));

    CorrectNonEmpty(aP0.x,aP1.x,aSz.x);
    CorrectNonEmpty(aP0.y,aP1.y,aSz.y);
}
    BooleanMappedValue BooleanValueImageExpanderEstimator::visit(SPnode * spn) const
    {
		#ifdef MYDEBUG
			std::cout << "in BooleanValueImageExpanderEstimator::visit, for " << spn->getNodeName() << std::endl;
		#endif
		
        // check if we need to split
        ivector box = spn->getBox();
		
		#ifdef MYDEBUG
			std::cout << "this box is " << box << std::endl;
        #endif
		
		#ifdef MYDEBUG
			std::cout << "this tolerance is " << tolerance << std::endl;
		#endif
		
		interval thisRange = fobj(box);
		
		#ifdef MYDEBUG
			std::cout << "this range is " << thisRange << std::endl;
		#endif
		
		
		bool retValue = false;
		
		if ( !(Sup(thisRange) < infCriterion) 
						&& !(Inf(thisRange) > supCriterion) ) { // overlap
			retValue = true;
			#ifdef MYDEBUG_MIN
				std::cout << "overlap, returning true" << std::endl;
			
			#endif
			
			if ( (Sup(thisRange) > supCriterion) 
				|| (Inf(thisRange) < infCriterion) ) { //indet
				
				int maxdiamcomp;
				double maxDiam = MaxDiam (box, maxdiamcomp);
				// check if box max width is < tolerance, expand if not
				if (!(maxDiam < tolerance)) {
					spn->nodeExpand();
					#ifdef MYDEBUG_MIN
						std::cout << "and max width >= tolerance " << std::endl;
					
					#endif
				}
				
			}
			// else thisRange is inside criterion				
		}
		
		
		return BooleanMappedValue(retValue);
    }
Example #3
0
         bool GenScaleIm<TObj>::do_it_gen(Pt2dr tr,REAL sc,Pt2di  pW0,Pt2di  pW1)
{

	_tr = tr;
	_sc = sc;
    XTransfo.Set(_tr.x,_sc);
    YTransfo.Set(_tr.y,_sc);


	_CoeffPds = round_ni(100.0/sc);
	pt_set_min_max(pW0,pW1);

	Pt2dr pu0 = Sup(Pt2dr(to_user(Pt2dr(pW0))),Pt2dr(0.0,0.0));
 	Pt2dr pu1 = Inf(Pt2dr(to_user(Pt2dr(pW1))),Pt2dr(_SzU));


	pW0 = Sup(Pt2di(0,0),round_down(to_window(pu0)));
	pW1 = Inf(_SzW		,round_up(to_window(pu1)));



	_pW0 = pW0;
	_pW1 = pW1;


	_xU0 = std::max(0		, round_down(0.5+x_to_user(_pW0.x-0.5)));
	_xU1 = std::min(_SzU.x	, round_up  (0.5+x_to_user(_pW1.x-0.5)));
	_yU0 = std::max(0		, round_down(0.5+y_to_user(_pW0.y-0.5)));
	_yU1 = std::min(_SzU.y	, round_up  (0.5+y_to_user(_pW1.y-0.5)));


    	if ((_xU0 >=_xU1) || (_yU0 >= _yU1))
           return false;

	for (INT ux=_xU0; ux<=_xU1 ; ux++)
	{
	     _u2wX[ux] =  FitInWX(PremPixelU2WX(ux));
    }

	for (INT uy=_yU0; uy<=_yU1 ; uy++)
	{
	     _u2wY[uy] =  FitInWY(PremPixelU2WY(uy));
    }

	for (INT wx= 0;wx<= _SzW.x ; wx++)	
	{
		 _Cw2uX[wx] = PixCenterW2U_x(wx);
	}
	for (INT wy=0;wy<= _SzW.y ; wy++)	
	{
		 _Cw2uY[wy] = PixCenterW2U_y(wy);
	}

     return true;
}
Example #4
0
      static base_t my_powr(const base_t&i, int p, unsigned q) 
	{
	  base_t po(Power(i, p));
	  if((q & 0x1) && my_inf(po) < 0) {
	    if(my_sup(po) <= 0)
	      return -Root(Abs(po), q);
	    base_t r(Root(Abs(po), q));
	    r = base_t(-Sup(r), Sup(r));
	    return r;
	  }
	  return Root(po,q);
	}
void WorkloadDistributionWidget::setupDistributionTable(){
	const ivector wlvector = this->workloads->getWorkloadVector();
	const int distLb = Lb( wlvector );
	const int distUb = Ub( wlvector );
	const int distCount = distUb - distLb + 1;

	distTable->setRowCount(distCount);

	QStringList rowHeaders;
	for (int i = distLb; i <= distUb; i++) {
		rowHeaders << QString("%1").arg(i);
	}

	distTable->setVerticalHeaderLabels(rowHeaders);

	for (int i = distLb; i <= distUb; i++) {
			stringstream strStr;
			strStr << Scientific << SetPrecision(15,16) << Sup(wlvector[i]) << endl
					<< Scientific << SetPrecision(15,16) << Inf(wlvector[i]);

			QString itemText = QString::fromStdString(strStr.str());
			QTableWidgetItem *newItem =	new QTableWidgetItem(itemText);
			distTable->setItem(i , 0 , newItem);
	}

	distTable->resizeRowsToContents();
}
Example #6
0
Point MessageSubWindow::getMinSize() const
 {
  Coord space_dxy=+cfg.space_dxy;
  
  Point size=showInfo.getMinSize()+2*Point::Diag(space_dxy);
  
  if( ulen count=btn_list.getLen() )
    {
     Point btnSpace=+cfg.btnSpace;
    
     Point s;
   
     for(ulen ind=0; ind<count ;ind++) s=Sup(s,btn_list[ind]->getMinSize());
    
     s+=btnSpace;
     
     Coord delta=s.y+2*space_dxy;
     
     Coord total=Coord(count)*s.x+Coord(count+1)*space_dxy;
     
     return Point(Max(total,size.x),size.y+delta);
    }
  else
    {
     Coord knob_dxy=+cfg.knob_dxy;
     
     Coord delta=knob_dxy+2*space_dxy;
     
     return Point(Max(knob_dxy,size.x),size.y+delta);
    }
 }
RImGrid::RImGrid
(
     bool AdaptStep,
     Pt2dr aP0,
     Pt2dr aP1,
     Pt2dr  aStepGr,
     const std::string & aName,
     Pt2di aSz
) :
  mP0     (Inf(aP0,aP1)),
  mP1     (Sup(aP0,aP1)),
  mStepGr (AdaptStep ? AdaptPas(aStepGr,mP1-mP0) : aStepGr),
  mSzGrid ( (aSz!=Pt2di(0,0)) ? 
            aSz               :
            (
                AdaptStep                                        ?
	        (round_ni((aP1-aP0).dcbyc(mStepGr))+Pt2di(1,1))  :
                (round_up((aP1-aP0).dcbyc(mStepGr))+Pt2di(1,1))
            )
          ),
  mDef    (-1e20),
  mGrid   (mSzGrid.x,mSzGrid.y,mDef),
  mTim    (new TIm2D<REAL,REAL>(mGrid)),
  mName   (aName),
  mStepAdapted (AdaptStep)
{
}
Example #8
0
template <class Type>   Box2d<Type>  Inf(const Box2d<Type> & b1,const Box2d<Type> & b2)
{
      return  Box2d<Type>
              (
                   Sup(b1._p0,b2._p0),
                   Inf(b1._p1,b2._p1)
              );
}
Example #9
0
Box2di cWindowXmlEditor::Draw(Pt2di aP0,cElXMLTree * aTree,int aLev,cElXMLTree * aFilter)
{
     Box2di aBoxNone(aP0,aP0);
     if (! mSelector->SelectTree(aTree)) 
        return aBoxNone;


     if (aTree->Profondeur() <= 1)
     {
          return PrintTag(aP0,aTree,0,aLev,aFilter);
     }

     aP0.y +=mSpaceTag;

     Box2di aRes = PrintTag(aP0,aTree,1,aLev,aFilter);

      for
      (
            std::list<cElXMLTree *>::iterator itF= aTree->Fils().begin();
            itF != aTree->Fils().end();
            itF++
      )
      {
           cElXMLTree * aFilsFilter = aFilter ? aFilter->GetOneOrZero((*itF)->ValTag()) : 0;

           if ((aFilter==0)  || (aFilsFilter!=0))
           {
              Box2di aBox = Draw(Pt2di(aP0.x+mDecalX,aRes._p1.y),*itF,aLev+1,aFilsFilter);
              aRes = Sup(aRes,aBox);
           }
      }

      
     Box2di aBoxFerm = PrintTag(Pt2di(aP0.x,aRes._p1.y),aTree,-1,aLev,aFilter);

     aRes =  Sup(aBoxFerm,aRes);
     if (mXmlMode)
     {
         mW.draw_rect(Pt2dr(aRes._p0),Pt2dr(EndXOfLevel(aLev),aRes._p1.y),mW.pdisc()(P8COL::red));
     }
     aRes._p1.y += mSpaceTag; 

     return aRes;
}
Example #10
0
void ModelDiffBox::MakeIt(Box2di OldOne,Box2di NewOne)
{
    mInterIsEmpty = mEnPlus.MakeIt(NewOne,OldOne);
    mEnMoins.MakeIt(OldOne,NewOne);

    if (!mInterIsEmpty)
    {
           mInter = Box2di(Inf(OldOne._p0,NewOne._p0),Sup(OldOne._p1,NewOne._p1));
    }
}
Example #11
0
//----------------------------------------------------------------------------
// Intersection of an interval 'X' and an extended interval 'Y'. The result
// is given as a pair (vector) of intervals, where one or both of them can
// be empty intervals.
//----------------------------------------------------------------------------
ivector operator& ( const interval& X, const xinterval& Y )
{
  interval H;
  ivector  IS(2);

  IS[1] = EmptyIntval();
  IS[2] = EmptyIntval();

  switch (Y.kind) {
    case Finite     : // [X.inf,X.sup] & [Y.inf,Y.sup]
                      //------------------------------
                      H = _interval(Y.inf,Y.sup);
                      if ( !Disjoint(X,H) ) IS[1] = X & H;
                      break;
    case PlusInfty  : // [X.inf,X.sup] & [Y.inf,+oo]
                      //----------------------------
                      if (Sup(X) >= Y.inf) {
                        if (Inf(X) > Y.inf)
                          IS[1] = X;
                        else
                          IS[1] = _interval(Y.inf,Sup(X));
                      }
                      break;
    case MinusInfty : // [X.inf,X.sup] & [-oo,Y.sup]
                      //----------------------------
                      if (Y.sup >= Inf(X)) {
                        if (Sup(X)<Y.sup)
                          IS[1] = X;
                        else
                          IS[1] = _interval(Inf(X),Y.sup);
                      }
                      break;
    case Double     : if ( (Inf(X) <= Y.sup) && (Y.inf <= Sup(X)) ) {
                        IS[1] = _interval(Inf(X),Y.sup);    // X & [-oo,Y.sup]
                        IS[2] = _interval(Y.inf,Sup(X));    // X & [Y.inf,+oo]
                      }
                      else if (Y.inf <= Sup(X)) // [X.inf,X.sup] & [Y.inf,+oo]
                        if (Inf(X) >= Y.inf)    //----------------------------
                          IS[1] = X;
                        else
                          IS[1] = _interval(Y.inf,Sup(X));
                      else if (Inf(X) <= Y.sup){// [X.inf,X.sup] & [-oo,Y.sup]
                        if (Sup(X) <= Y.sup)    //----------------------------
                          IS[1] = X;
                        else
                          IS[1] = _interval(Inf(X),Y.sup);
                      }
                      break;
    case Empty      : break;                           // [X.inf,X.sup] ** [/]
  } // switch                                          //---------------------

  return IS;
} // operator&
    cxsc::interval IntervalExpanderEstimator::visit(SPnode * spn) const
    {
		#ifdef MYDEBUG
			std::cout << "in IntervalExpanderEstimator::visit, for " << spn->getNodeName() << std::endl;
		#endif
		
        // check if we need to split
        ivector box = spn->getBox();
		
		#ifdef MYDEBUG
			std::cout << "this box is " << box << std::endl;
        #endif
		
		interval thisRange = fobj(box);
		real thisMidImage = fobj.imageMid(box);
		
		#ifdef MYDEBUG
			std::cout << "this midImage is " << thisMidImage << std::endl;
		#endif
		
		#ifdef MYDEBUG
			std::cout << "this range is " << thisRange << std::endl;
		#endif
		
		#ifdef MYDEBUG
			std::cout << "this tolerance is " << tolerance << std::endl;
		#endif
		
		// split if so
		if (max(Sup(thisRange) - thisMidImage, thisMidImage - Inf(thisRange)) > tolerance) {
			spn->nodeExpand();

		}
		#ifdef MYDEBUG_MIN
		if (!(max(Sup(thisRange) - thisMidImage, thisMidImage - Inf(thisRange)) > tolerance)) {
		
			std::cout << "no need to expand further: interval image <= tolerance " << std::endl;
		}
		#endif
		
		return thisRange;
    }
    BooleanValueImageExpanderEstimator::BooleanValueImageExpanderEstimator(
												const MappedFobj& f,
												const cxsc::interval& crit,
												cxsc::real tol)
                : fobj(f), supCriterion(Sup(crit)), infCriterion(Inf(crit)),
					tolerance(tol) 
	{
		if (tolerance < cxsc::MinReal) 
			throw std::invalid_argument(
				"BooleanValueImageExpanderEstimator::BooleanValueImageExpanderEstimator(MappedFobj&, cxsc::real) : tol < cxsc::MinReal");
	}
void StochasticProcessWidget::addQuantile() {
	QTableWidgetItem *item;

	int lastRowIndex = quantileTable->rowCount();
	quantileTable->setRowCount(lastRowIndex + 1);

	double probabilityLimit = quantileEdit->text().toDouble();
	int stateCount = process->getNumStates();


	item = new QTableWidgetItem(quantileEdit->text());
	item->setTextAlignment(Qt::AlignCenter);
	quantileTable->setItem(lastRowIndex, 0, item);
	item = new QTableWidgetItem("[DEL]");
	item->setTextAlignment(Qt::AlignCenter);
	quantileTable->setItem(lastRowIndex, stateCount+1, item);

	for (int stateIndex = 1; stateIndex <= stateCount; stateIndex++) {
		ivector distValues = intervalDists[stateIndex-1];
		real probabilityInf = 0.0;
		real probabilitySup = 0.0;
		int distIndexSup;
		int distIndexInf;
		for (distIndexSup = Lb(distValues); distIndexSup <= Ub(distValues); distIndexSup++) {
			interval distValue = distValues[distIndexSup];
			probabilityInf += Inf(distValue);
			probabilitySup += Sup(distValue);
			if (probabilitySup >= probabilityLimit) {
				if(probabilityInf <probabilityLimit)
					distIndexInf = distIndexSup - 1;
				else
					distIndexInf = distIndexSup;
				break;
			}
		}

		QTableWidgetItem *resultItem = new QTableWidgetItem(QString("[%1..%2]").arg(distIndexInf).arg(distIndexSup));
		resultItem->setTextAlignment(Qt::AlignCenter);
		quantileTable->setItem(lastRowIndex, stateIndex, resultItem);
	}

	int distCount = process->getNumStates();
	QColor quantileCellColor;

	for (int i = 0; i < distCount; i++) {
		int hueValue = (int)round(255.0
				/ ((double)distCount / (double)i));
		quantileCellColor.setHsv(hueValue, 40, 245);
		quantileTable->item(lastRowIndex, i+1)->setBackgroundColor(quantileCellColor);
	}
}
Example #15
0
File: dag.hpp Project: baharev/asol
bool PowInt<T>::propagate() {

    T& x = *arg1;
    const T& y = *(this->val);

    // Inverse operator
    T x_new( sqrt(y) );

    if      (Inf(x) >= 0.0)
        ;
    else if (Sup(x) <= 0.0)
        x_new = T(-Sup(x_new), -Inf(x_new));
    else
        x_new = T(-Sup(x_new), Sup(x_new));

    if ( Disjoint(x, x_new) )
        return true;
    else {
        x = Intersect(x, x_new);
    }

    return false;
}
template <class Type>   void cStructMergeTieP<Type>::DoExport()
{
    AssertUnExported();
    mExportDone = true;

    for (int aK=0 ; aK<mTheNb ; aK++)
    {
        tMapMerge & aMap = mTheMapMerges[aK];

        for (tItMM anIt = aMap.GT_Begin() ; anIt != aMap.GT_End() ; anIt++)
        {
            tMerge * aM = tMapMerge::GT_GetValOfIt(anIt);
            if (aM->IsOk())
            {
               mLM.push_back(aM);
               aM->SetNoOk();
            }
        }
    }

    for (int aK=0 ; aK<mTheNb ; aK++)
    {
       mNbSomOfIm[aK] = 0;
    }
    
    for (typename std::list<tMerge *>::const_iterator itM=mLM.begin() ; itM!=mLM.end() ; itM++)
    {
        int aNbA = (*itM)->NbArc();
        while (int(mStatArc.size()) <= aNbA)
        {
           mStatArc.push_back(0);
        }
        mStatArc[aNbA] ++;
        for (int aKS=0 ; aKS<mTheNb ; aKS++)
        {
           if ((*itM)->IsInit(aKS))
           {
               const tVal &  aVal = (*itM)->GetVal(aKS);
               if(mNbSomOfIm[aKS] == 0)
               {
                   mEnvSup[aKS] = mEnvInf[aKS] = aVal;
               }
               mNbSomOfIm[aKS] ++;
               mEnvInf[aKS] = Inf(mEnvInf[aKS],aVal);
               mEnvSup[aKS] = Sup(mEnvSup[aKS],aVal);
           }
        }
    }
}
Example #17
0
void MessageSubWindow::layout()
 {
  Point size=getSize();
  
  Coord space_dxy=+cfg.space_dxy;
  
  if( ulen count=btn_count )
    {
     Point btnSpace=+cfg.btnSpace;
     
     Point s;
    
     for(ulen ind=0; ind<count ;ind++) s=Sup(s,btn_list[ind]->getMinSize());
     
     s+=btnSpace;
     
     Coord delta=s.y+2*space_dxy;
     
     showInfo.setPlace(Pane(0,0,size.x,size.y-delta).shrink(space_dxy));
     
     dline.setPlace(Pane(0,size.y-delta-space_dxy,size.x,2*space_dxy));
      
     Coord total=Coord(count)*s.x+Coord(count-1)*space_dxy;
     
     Point o((size.x-total)/2,size.y-s.y-space_dxy);
     Coord delta_x=s.x+space_dxy;
    
     for(ulen ind=0; ind<count ;ind++)
       {
        btn_list[ind]->setPlace(Pane(o,s));
        
        o.x+=delta_x;
       }
    }
  else
    {
     Coord knob_dxy=+cfg.knob_dxy;
     Coord delta=knob_dxy+2*space_dxy;
    
     showInfo.setPlace(Pane(0,0,size.x,size.y-delta).shrink(space_dxy));
    
     dline.setPlace(Pane(0,size.y-delta-space_dxy,size.x,2*space_dxy));
     
     knobOk.setPlace(Pane((size.x-knob_dxy)/2,size.y-knob_dxy-space_dxy,knob_dxy));
    }
 }
void StochasticProcessWidget::setupDistributionTable(
		const imatrix & distributionMatrix) {
	const int distLb = Lb(distributionMatrix, 1);
	const int distUb = Ub(distributionMatrix, 1);
	const int valueLb = Lb(distributionMatrix, 2);
	const int valueUb = Ub(distributionMatrix, 2);
	const int distCount = distUb - distLb + 1;
	const int valueCount = valueUb - valueLb + 1;

	distTable->setRowCount(valueCount);
	distTable->setColumnCount(distCount);

	QStringList columnHeaders;
	for (int i = distLb; i <= distUb; i++) {
		columnHeaders << QString("S%1").arg(i);
	}

	distTable->setHorizontalHeaderLabels(columnHeaders);

	QStringList rowHeaders;
	for (int i = valueLb; i <= valueUb; i++) {
		rowHeaders << QString("%1").arg(i);
	}

	distTable->setVerticalHeaderLabels(rowHeaders);

	for (int r = distLb; r <= distUb; r++) {
		for (int c = valueLb; c <= valueUb; c++) {
			double
					inf =
							_double(Inf(distributionMatrix[r][c]));
			double
					sup =
							_double(Sup(distributionMatrix[r][c]));

			QString itemText = QString("%1\n%2").arg(sup).arg(inf);

			QTableWidgetItem *newItem =
					new QTableWidgetItem(itemText);
			distTable->setItem(c - valueLb, r - distLb,
					newItem);
		}
	}
}
    BooleanMappedValue BooleanValueImageEstimator::visit(SPnode * spn) const
    {
		#ifdef MYDEBUG
			std::cout << "in BooleanValueImageEstimator::visit, for " << spn->getNodeName() << std::endl;
		#endif
		
        ivector box = spn->getBox();
		
		#ifdef MYDEBUG
			std::cout << "this box is " << box << std::endl;
        #endif
		
		interval thisRange = fobj(box);
			
		#ifdef MYDEBUG
			std::cout << "this range is " << thisRange << std::endl;
		#endif
		
		return BooleanMappedValue( !(Sup(thisRange) < infCriterion) 
				&& !(Inf(thisRange) > supCriterion) );
    }
Example #20
0
cTmpReechEpip::cTmpReechEpip
(
        bool aConsChan,
        const std::string & aNameOri,
        Box2dr aBoxImIn,
        ElDistortion22_Gen * anEpi,
        Box2dr aBox,
        double aStep,
        const std::string & aNameOut,
        const std::string & aPostMasq,
        int aNumKer ,
        bool Debug
) :
    mBoxImIn(aBoxImIn),
    mEpi    (anEpi),
    mStep   (aStep),
    mP0     (aBox._p0),
    mSzEpi  (aBox.sz()),
    mSzRed  (round_up (aBox.sz() / aStep) + Pt2di(1,1)),
    mRedIMasq  (mSzRed.x,mSzRed.y,0),
    mRedTMasq  (mRedIMasq),
    mRedImX    (mSzRed.x,mSzRed.y),
    mRedTImX   (mRedImX),
    mRedImY    (mSzRed.x,mSzRed.y),
    mRedTImY   (mRedImY)
{



    cInterpolateurIm2D<REAL4> * aPtrSCI = 0;


    if (aNumKer==0)
    {
        aPtrSCI = new cInterpolBilineaire<REAL4>;
    }
    else 
    {
      
       cKernelInterpol1D * aKer = 0;
       if (aNumKer==1)
          aKer = new cCubicInterpKernel(-0.5);
       else
          aKer = new cSinCardApodInterpol1D(cSinCardApodInterpol1D::eTukeyApod,aNumKer,aNumKer/2,1e-4,false);

       aPtrSCI =  new  cTabIM2D_FromIm2D<REAL4>   (aKer,1000,false);
       // cTabIM2D_FromIm2D<REAL4>   aSSCI (&aKer,1000,false);
    }

    cInterpolateurIm2D<REAL4> & aSCI = *aPtrSCI;



    Pt2di aPInd;

    for (aPInd.x=0 ; aPInd.x<mSzRed.x ; aPInd.x++)
    {
       for (aPInd.y=0 ; aPInd.y<mSzRed.y ; aPInd.y++)
       {
          bool Ok= false;
          Pt2dr aPEpi = ToFullEpiCoord(aPInd);
          Pt2dr aPIm =  anEpi->Inverse(aPEpi);
          if ((aPIm.x>mBoxImIn._p0.x) && (aPIm.y>mBoxImIn._p0.y) && (aPIm.x<mBoxImIn._p1.x) && (aPIm.y<mBoxImIn._p1.y))
          {
               Pt2dr aPEpi2 = anEpi->Direct(aPIm);
               if (euclid(aPEpi-aPEpi2) < 1e-2)
               {
                    Ok= true;
                    mRedTMasq.oset(aPInd,Ok);
               }
          }
          mRedTImX.oset(aPInd,aPIm.x);
          mRedTImY.oset(aPInd,aPIm.y);
       }
    }
    ELISE_COPY(mRedIMasq.all_pts(),dilat_d8(mRedIMasq.in(0),4),mRedIMasq.out());


    Tiff_Im aTifOri = Tiff_Im::StdConvGen(aNameOri.c_str(),aConsChan ? -1 :1 ,true);
    Tiff_Im aTifEpi  = Debug                       ?
                       Tiff_Im(aNameOut.c_str())     :
                       Tiff_Im
                       (
                           aNameOut.c_str(),
                           mSzEpi,
                           aTifOri.type_el(),
                           Tiff_Im::No_Compr,
                           aTifOri.phot_interp()
                       )                            ;

    Tiff_Im aTifMasq = aTifEpi;
    bool ExportMasq = (aPostMasq!="NONE");

// std::cout << "POSTMAS " << aPostMasq << "\n";

    if (ExportMasq)
    {
        std::string aNameMasq = StdPrefix(aNameOut)+ aPostMasq  +".tif";
        aTifMasq =  Debug                         ?
                    Tiff_Im(aNameMasq.c_str())    :
                    Tiff_Im
                    (
                        aNameMasq.c_str(),
                        mSzEpi,
                        GenIm::bits1_msbf,
                        Tiff_Im::No_Compr,
                        Tiff_Im::BlackIsZero
                    )                             ;
    }





    int aNbBloc=2000;
    int aBrd = aNumKer+10;
    Pt2di aSzBrd(aBrd,aBrd);

    int aX00 = 0;
    int aY00 = 0;

    for (int aX0=aX00 ; aX0<mSzEpi.x ; aX0+=aNbBloc)
    {
         int aX1 = ElMin(aX0+aNbBloc,mSzEpi.x);
         for (int aY0=aY00 ; aY0<mSzEpi.y ; aY0+=aNbBloc)
         {
// std::cout << "X0Y0 " << aX0 << " " << aY0 << "\n";

             int aY1 = ElMin(aY0+aNbBloc,mSzEpi.y);

             Pt2di aP0Epi(aX0,aY0);
             Pt2di aSzBloc(aX1-aX0,aY1-aY0);

             TIm2D<REAL4,REAL8> aTImX(aSzBloc);
             TIm2D<REAL4,REAL8> aTImY(aSzBloc);
             TIm2DBits<1>       aTImMasq(aSzBloc,0);

             Pt2dr aInfIm(1e20,1e20);
             Pt2dr aSupIm(-1e20,-1e20);
             bool  NonVide= false;

             for (int anX =aX0 ; anX<aX1  ; anX++)
             {
                 for (int anY =aY0 ; anY<aY1  ; anY++)
                 {
                     Pt2dr aIndEpi (anX/mStep , anY/mStep);
                     Pt2di aPIndLoc (anX-aX0,anY-aY0);
                     if (mRedTMasq.get(round_down(aIndEpi)))
                     {
                        double aXIm = mRedTImX.getr(aIndEpi,-1,true);
                        double aYIm = mRedTImY.getr(aIndEpi,-1,true);

                        if ((aXIm>0) && (aYIm>0))
                        {
                            // aTImMasq.oset(aPIndLoc,1);
                            aTImX.oset(aPIndLoc,aXIm);
                            aTImY.oset(aPIndLoc,aYIm);

                            aInfIm  = Inf(aInfIm,Pt2dr(aXIm,aYIm));
                            aSupIm  = Sup(aSupIm,Pt2dr(aXIm,aYIm));
                            NonVide= true;
                        }
                     }
                 }
             }
             Pt2di aP0BoxIm = Sup(Pt2di(0,0),Pt2di(round_down(aInfIm) - aSzBrd));
             Pt2di aP1BoxIm = Inf(aTifOri.sz(),Pt2di(round_down(aSupIm) + aSzBrd));
             Pt2di aSzIm = aP1BoxIm - aP0BoxIm;
             NonVide = NonVide && (aSzIm.x>0) && (aSzIm.y>0);
             if (NonVide)
             {

                 // std::vector<Im2D_REAL4>  aVIm;

                 std::vector<Im2D_REAL4>  aVIm= aTifOri.VecOfImFloat(aSzIm);

                 ELISE_COPY
                 (
                     rectangle(Pt2di(0,0),aSzIm),
                     trans(aTifOri.in(),aP0BoxIm),
                     StdOut(aVIm)
                 );

                 std::vector<Im2D_REAL4>  aVImEpi = aTifEpi.VecOfImFloat(aSzBloc);
                 ELISE_ASSERT(aVImEpi.size()==aVIm.size(),"Incohe in nb chan, cTmpReechEpip::cTmpReechEpip");

                 for (int aKIm=0 ; aKIm <int(aVImEpi.size()) ; aKIm++)
                 {
                      TIm2D<REAL4,REAL8> aImEpi(aVImEpi[aKIm]);
                      REAL4 ** aDataOri = aVIm[aKIm].data();
                      for (int anX =0 ; anX<aSzBloc.x ; anX++)
                      {
                           for (int anY =0 ; anY<aSzBloc.y ; anY++)
                           {

                               Pt2di aIndEpi(anX,anY);
                               aImEpi.oset(aIndEpi,0);
                               Pt2di anIndEpiGlob  = aIndEpi + aP0Epi;

                               Pt2dr aIndEpiRed (anIndEpiGlob.x/mStep , anIndEpiGlob.y/mStep);
                               if (mRedTMasq.get(round_down(aIndEpiRed),0))
                               {
                                   double aXIm = mRedTImX.getr(aIndEpiRed,-1,true);
                                   double aYIm = mRedTImY.getr(aIndEpiRed,-1,true);
                                   Pt2dr aPImLoc = Pt2dr(aXIm,aYIm) - Pt2dr(aP0BoxIm);
                                   double aV= 128;
                                   if ((aPImLoc.x>aNumKer+2) && (aPImLoc.y>aNumKer+2) && (aPImLoc.x<aSzIm.x-aNumKer-3) && (aPImLoc.y<aSzIm.y-aNumKer-3))
                                   {
                                       aTImMasq.oset(aIndEpi,1);
                                       aV = aSCI.GetVal(aDataOri,aPImLoc);
                                       // aV= 255;
                                   }
                                   aImEpi.oset(aIndEpi,aV);
                               }
                           }
                      }
                 }
                 ELISE_COPY
                 (
                     rectangle(aP0Epi,aP0Epi+aSzBloc),
                     Tronque(aTifEpi.type_el(),trans(StdInput(aVImEpi),-aP0Epi)),
                     aTifEpi.out()
                 );
             }
             if (ExportMasq)
             {
                ELISE_COPY
                (
                    rectangle(aP0Epi,aP0Epi+aSzBloc),
                    trans(aTImMasq._the_im.in(0),-aP0Epi),
                    aTifMasq.out()
                );
             }
             // std::cout << "ReechDONE " <<  aX0 << " "<< aY0 << "\n";

         }
    }
}
Example #21
0
void cZBuf::BasculerUnTriangle(cTriangle &aTri, bool doMask)
{
    vector <Pt3dr> Sommets;
    aTri.getVertexes(Sommets);

    if (Sommets.size() == 3 )
    {
        //Projection du terrain vers l'image
        Pt3dr A3 = mNuage->Euclid2ProfAndIndex(Sommets[0]);
        Pt3dr B3 = mNuage->Euclid2ProfAndIndex(Sommets[1]);
        Pt3dr C3 = mNuage->Euclid2ProfAndIndex(Sommets[2]);

        Pt2dr A2(A3.x, A3.y);
        Pt2dr B2(B3.x, B3.y);
        Pt2dr C2(C3.x, C3.y);

        Pt2dr AB = B2-A2;
        Pt2dr AC = C2-A2;
        REAL aDet = AB^AC;

        if (aDet==0) return;

        Pt2di A2i = round_down(A2);
        Pt2di B2i = round_down(B2);
        Pt2di C2i = round_down(C2);

         //On verifie que le triangle se projete entierement dans l'image
         //TODO: gerer les triangles de bord
        if (A2i.x < 0 || B2i.x < 0 || C2i.x < 0 || A2i.y < 0 || B2i.y < 0 || C2i.y < 0 || A2i.x >= mSzRes.x || B2i.x >= mSzRes.x || C2i.x >= mSzRes.x || A2i.y >= mSzRes.y  || B2i.y >= mSzRes.y  || C2i.y >= mSzRes.y)
             return;

        REAL zA = A3.z;
        REAL zB = B3.z;
        REAL zC = C3.z;

        Pt2di aP0 = round_down(Inf(A2,Inf(B2,C2)));
        aP0 = Sup(aP0,Pt2di(0,0));
        Pt2di aP1 = round_up(Sup(A2,Sup(B2,C2)));
        aP1 = Inf(aP1,mSzRes-Pt2di(1,1));

        if (doMask)
        {
            for (INT x=aP0.x ; x<= aP1.x ; x++)
                for (INT y=aP0.y ; y<= aP1.y ; y++)
                {
                    Pt2dr AP = Pt2dr(x,y)-A2;

                    // Coordonnees barycentriques de P(x,y)
                    REAL aPdsB = (AP^AC) / aDet;
                    REAL aPdsC = (AB^AP) / aDet;
                    REAL aPdsA = 1 - aPdsB - aPdsC;
                    if ((aPdsA>-Eps) && (aPdsB>-Eps) && (aPdsC>-Eps))
                    {
                        mImMask.set(x, y, 1);
                    }
                }
        }
        else
        {
            for (INT x=aP0.x ; x<= aP1.x ; x++)
                for (INT y=aP0.y ; y<= aP1.y ; y++)
                {
                    Pt2dr AP = Pt2dr(x,y)-A2;

                    // Coordonnees barycentriques de P(x,y)
                    REAL aPdsB = (AP^AC) / aDet;
                    REAL aPdsC = (AB^AP) / aDet;
                    REAL aPdsA = 1 - aPdsB - aPdsC;
                    if ((aPdsA>-Eps) && (aPdsB>-Eps) && (aPdsC>-Eps))
                    {
                        REAL4 aZ = (float) (zA*aPdsA + zB*aPdsB + zC*aPdsC);
                        if (aZ>mDataRes[y][x])
                        {
                            mDataRes[y][x] = aZ;
                            mImTriIdx.SetI(Pt2di(x,y),aTri.getIdx());
                        }
                    }
                }
        }
    }
}
    BooleanValueImageEstimator::BooleanValueImageEstimator(const MappedFobj& f,
											const cxsc::interval& crit)
                : fobj(f), supCriterion(Sup(crit)), infCriterion(Inf(crit))
	{}
Example #23
0
//----------------------------------------------------------------------------
// Extended interval division 'A / B' where 0 in 'B' is allowed.
//----------------------------------------------------------------------------
xinterval operator% ( const interval& A, const interval& B )
{
  interval  c;
  xinterval Q;

  if ( in(0.0, B) ) {
    if ( in(0.0, A) ) {
      Q.kind = Double;                    // Q = [-oo,+oo] = [-oo,0] v [0,+oo]
      Q.sup  = 0.0;                       //----------------------------------
      Q.inf  = 0.0;
    }
    else if ( B == 0.0 ) {                                          // Q = [/]
      Q.kind = PlusInfty;                                           //--------
      Q.inf  = divd(Sup(A),Inf(B));
    }
    else if ( (Sup(A) < 0.0) && (Sup(B) == 0.0) ) {         // Q = [Q.inf,+oo]
      Q.kind = PlusInfty;                                   //----------------
      Q.inf  = divd(Sup(A),Inf(B));
    }
    else if ( (Sup(A) < 0.0) && (Inf(B) < 0.0) && (Sup(B) > 0.0) ) {
      Q.kind = Double;                        // Q = [-oo,Q.sup] v [Q.inf,+oo]
      Q.sup  = divu(Sup(A),Sup(B));           //------------------------------
      Q.inf  = divd(Sup(A),Inf(B));
    }
    else if ( (Sup(A) < 0.0) && (Inf(B) == 0.0) ) {         // Q = [-oo,Q.sup]
      Q.kind = MinusInfty;                                  //----------------
      Q.sup  = divu(Sup(A),Sup(B));
    }
    else if ( (Inf(A) > 0.0) && (Sup(B) == 0.0) ) {         // Q = [-oo,Q.sup]
      Q.kind = MinusInfty;                                  //----------------
      Q.sup  = divu(Inf(A),Inf(B));
    }
    else if ( (Inf(A) > 0.0) && (Inf(B) < 0.0) && (Sup(B) > 0.0) ) {
      Q.kind = Double;                        // Q = [-oo,Q.sup] v [Q.inf,+oo]
      Q.sup  = divu(Inf(A),Inf(B));           //------------------------------
      Q.inf  = divd(Inf(A),Sup(B));
    }
    else { // if ( (Inf(A) > 0.0) && (Inf(B) == 0.0) )
      Q.kind = PlusInfty;                                   // Q = [Q.inf,+oo]
      Q.inf  = divd(Inf(A),Sup(B));                         //----------------
    }
  } // in(0.0,B)
  else {  // !in(0.0,B)
    c = A / B;                                            // Q = [C.inf,C.sup]
    Q.kind = Finite;                                      //------------------
    Q.inf  = Inf(c);
    Q.sup  = Sup(c);
  }

  return Q;
} // operator%
Example #24
0
        void CalcMaxLoc<Type,TypeBase,Compare>::AllMaxLoc 
             (
                  ElSTDNS vector<Pt2di> &res,
                  Im2D<Type,TypeBase> Im,
                  Pt2di    Vois,
                  Pt2di    p0, Pt2di    p1,
                  TypeBase vMin
             )
{
   Pt2di Sz(Im.tx(),Im.ty());
   Vois.x = ElAbs(Vois.x);
   Vois.y = ElAbs(Vois.y);
   pt_set_min_max(p0,p1);

   p0 = Sup(p0,Vois);
   p1 = Inf(p1,Sz-Vois);

   if ((p1.x<=p0.x) || (p1.y <= p0.y))
      return;

   INT dlx = Vois.x;
   INT dly = Vois.y;
   Type ** data = Im.data();
 

   res.clear();
   ElSTDNS vector<Pt3di> & OVois = OrdVois(Vois);

   for (INT Y0=p0.y ; Y0<p1.y ; Y0+=dly)
   {
       INT Y1 = ElMin(p1.y,Y0+dly);
       for (INT X0=p0.x ; X0<p1.x ; X0+=dlx)
       {
           INT X1 = ElMin(p1.x,X0+dlx);
           Type vMax = vMin;
           INT xMax = DefXY;
           INT yMax = DefXY;

           for (INT y=Y0; y<Y1 ; y++)
           {
               for (INT x=X0; x<X1 ; x++)
               {
                   if (mCmp((TypeBase)vMax,(TypeBase)data[y][x]))
                   {
                       xMax = x;
                       yMax = y;
                       vMax = data[y][x];
                   }
               }
           }
           if (xMax != DefXY)
           {
              bool IsMax = true;
              for 
              ( 
                  std::vector<Pt3di> ::iterator itOV = OVois.begin();
                  IsMax &&(itOV != OVois.end());
                  itOV++
              )
              {
                   Type aVal = data[yMax+itOV->y][xMax+itOV->x];
                   if (itOV->z)
                   {
                      if (!mCmp((TypeBase)aVal,(TypeBase)vMax))
                          IsMax = false;
                   }
                   else
                   {
                      if (mCmp((TypeBase)vMax,(TypeBase)aVal))
                          IsMax = false;
                   }
              }
              if (IsMax)
              {
                 res.push_back(Pt2di(xMax,yMax));

              }
           }
       }
   }
}
Example #25
0
void ElSegMerge
     (
         std::vector<Seg2d> & VecInits,
         REAL  dLong,
         REAL  dLarg
     )
{
     if (VecInits.size() ==0) 
         return;

     // std::vector<SegComp> VC(VecInits.begin(),VecInits.end()); Error sur Sun-Fronte
     std::vector<SegComp> VC;
     for 
     ( 
        std::vector<Seg2d>::iterator ItS = VecInits.begin();
        ItS != VecInits.end();
        ItS++
     )
        VC.push_back(*ItS);

     std::sort(VC.begin(),VC.end(),LengthIsSup);

     Box2dr box(VC[0].p0(),VC[0].p1());

     for(tItSC itV = VC.begin(); itV != VC.end(); itV++)
     {
         box = Sup(box,Box2dr(itV->p0(),itV->p1()));
     }
     box = box.dilate(10);


     MyPrimFQdt aPrim;
     REAL d = box.diam()/sqrt(double(VC.size()));
     tElMergeSegQdt   aQdt( aPrim, box, 10, d);

     VecInits.clear();
     std::set<SegComp *> sVois;

	 {
     for(tItSC itV = VC.begin(); itV != VC.end(); itV++)
     {
        sVois.clear();
        aQdt.RVoisins(sVois,*itV,std::max(dLong,dLarg));

        bool Ok = true;
        for
        (
            std::set<SegComp *>::iterator itVois = sVois.begin();
            (itVois != sVois.end()) && Ok;
            itVois++
        )
             Ok = !((*itVois)->BoxContains(*itV,dLong,dLarg));

        if (Ok)
        {
           aQdt.insert(&(*itV));
           VecInits.push_back(*itV);
        }
     }
	 }
}
Example #26
0
      static double my_sup(const base_t &i) 
	{
	  return Sup(i);
	}
Example #27
0
      static bool is_special(const base_t &i)
	{
	  return is_empty(i) || base_traits<iv_base_t>::is_special(Inf(i)) ||
	    base_traits<iv_base_t>::is_special(Sup(i));
	}
Example #28
0
      static bool is_empty(const base_t& i)
	{
	  return Sup(i) < Inf(i);
	}
Example #29
0
void cApply_CreateEpip_main::DoEpipGen()
{
      mLengthMin = 500.0;
      mStepReech = 10.0;
      mNbZ       = 1;
      mNbXY      = 100;
      ElPackHomologue aPack;
      Pt2dr aDir2 =  DirEpipIm2(mGenI1,mGenI2,aPack,true);
      Pt2dr aDir1 =  DirEpipIm2(mGenI2,mGenI1,aPack,false);

      std::cout << "Compute Epip\n";
      CpleEpipolaireCoord * aCple = CpleEpipolaireCoord::PolynomialFromHomologue(false,aPack,mDegre,aDir1,aDir2);

      EpipolaireCoordinate & e1 = aCple->EPI1();
      EpipolaireCoordinate & e2 = aCple->EPI2();

      Pt2dr aInf1(1e20,1e20),aSup1(-1e20,-1e20);
      Pt2dr aInf2(1e20,1e20),aSup2(-1e20,-1e20);

      double aErrMax = 0.0;
      double aErrMoy = 0.0;
      int    mNbP = 0;
      double aX2mX1 = 0.0;

      CpleEpipolaireCoord * aCple3 = 0;
      CpleEpipolaireCoord * aCple7 = 0;
      if (0)
      {
         aCple3 = CpleEpipolaireCoord::PolynomialFromHomologue(false,aPack,3,aDir1,aDir2);
         aCple7 = CpleEpipolaireCoord::PolynomialFromHomologue(false,aPack,7,aDir1,aDir2);
      }

      double aErrMaxDir1 = 0.0;
      double aErrMaxInv1 = 0.0;

      for (ElPackHomologue::const_iterator itC=aPack.begin() ; itC!= aPack.end() ; itC++)
      {
           Pt2dr aP1 = e1.Direct(itC->P1());
           Pt2dr aP2 = e2.Direct(itC->P2());
           aInf1 = Inf(aInf1,aP1);
           aSup1 = Sup(aSup1,aP1);
           aInf2 = Inf(aInf2,aP2);
           aSup2 = Sup(aSup2,aP2);

           aX2mX1 += aP2.x - aP1.x;

           double anErr = ElAbs(aP1.y-aP2.y);
           mNbP++;
           aErrMax = ElMax(anErr,aErrMax);
           aErrMoy += anErr;

           if (aCple3)
           {
               Pt2dr aQ1D3 = aCple3->EPI1().Direct(itC->P1());
               Pt2dr aQ1D7 = aCple7->EPI1().Direct(itC->P1());
               double aDQ1 = euclid(aQ1D3-aQ1D7);
               aErrMaxDir1 = ElMax(aDQ1,aErrMaxDir1);

               Pt2dr aR1D3 =  aCple3->EPI1().Inverse(aQ1D3);
               Pt2dr aR1D7 =  aCple7->EPI1().Inverse(aQ1D7);
               double aDR1 = euclid(aR1D3-aR1D7);
               aErrMaxInv1 = ElMax(aDR1,aErrMaxInv1);

           }

      }
      if (aCple3)
      {
         std::cout << "MAX ER " << aErrMaxDir1 << " " << aErrMaxInv1 << "\n";
      }

      aX2mX1 /= mNbP;

      double aInfY = ElMax(aInf1.y,aInf2.y);
      double aSupY = ElMax(aSup1.y,aSup2.y);
      aInf1.y = aInf2.y = aInfY;
      aSup1.y = aSup2.y = aSupY;

      std::cout << aInf1 << " " <<  aSup1 << "\n";
      std::cout << aInf2 << " " <<  aSup2 << "\n";
      std::cout << "DIR " << aDir1 << " " << aDir2 << " X2-X1 " << aX2mX1<< "\n";
      std::cout << "Epip Rect Accuracy, Moy " << aErrMoy/mNbP << " Max " << aErrMax << "\n";


      cTmpReechEpip aReech1(true,mName1,Box2dr(Pt2dr(0,0),Pt2dr(mGenI1->SzBasicCapt3D())),&e1,Box2dr(aInf1,aSup1),mStepReech,"ImEpi1"+mPostIm+".tif",mPostMasq,mNumKer,mDebug);
      std::cout << "DONE IM1 \n";
      cTmpReechEpip aReech2(true,mName2,Box2dr(Pt2dr(0,0),Pt2dr(mGenI2->SzBasicCapt3D())),&e2,Box2dr(aInf2,aSup2),mStepReech,"ImEpi2"+mPostIm+".tif",mPostMasq,mNumKer,mDebug);
      std::cout << "DONE IM2 \n";

      std::cout << "DONNE REECH TMP \n";

//  ::cTmpReechEpip(cBasicGeomCap3D * aGeom,EpipolaireCoordinate * anEpi,Box2dr aBox,double aStep) :
}
Example #30
0
cAppliOneReechMarqFid::cAppliOneReechMarqFid(int argc,char ** argv) :
     cAppliWithSetImage   (argc-1,argv+1,TheFlagNoOri),
     mAffPixIm2ChambreMm  (ElAffin2D::Id()),
     mBySingle            (true),
     mNumKer              (5),
     mPostMasq            ("NONE")
{
    ElInitArgMain
    (
          argc,argv,
          LArgMain()  << EAMC(mNamePat,"Pattern image", eSAM_IsExistFile)
                      << EAMC(mResol,"Resolution"),
          LArgMain()   <<  EAM(mBoxChambreMm,"BoxCh",true,"Box in Chambre (generally in mm)")
                       << EAM(mNumKer,"Kern",true,"Kernel of interpol,0 Bilin, 1 Bicub, other SinC (fix size of apodisation window), Def=5")
                       << EAM(mPostMasq,"AttrMasq",true,"Atribut for masq toto-> toto_AttrMasq.tif, NONE if unused, Def=NONE")
    );

    if (mPostMasq!="NONE") 
       mPostMasq = "_"+mPostMasq+"Masq";

    const cInterfChantierNameManipulateur::tSet * aSetIm = mEASF.SetIm();
    if (aSetIm->size()>1)
    {
         mBySingle = false;
         ExpandCommand(2,"",true);
         return;
    }

    mNameIm =(*aSetIm)[0];
 
    mDir = DirOfFile(mNameIm);
    mICNM = cInterfChantierNameManipulateur::BasicAlloc(mDir);

    std::pair<std::string,std::string> aPair = mICNM->Assoc2To1("Key-Assoc-STD-Orientation-Interne",mNameIm,true);


    mSzIm = Tiff_Im::StdConvGen(mNameIm,-1,true).sz();

    cMesureAppuiFlottant1Im aMesCam = StdGetFromPCP(mDir+aPair.first,MesureAppuiFlottant1Im);
    cMesureAppuiFlottant1Im aMesIm  = StdGetFromPCP(mDir+aPair.second,MesureAppuiFlottant1Im);

    mPack = PackFromCplAPF(aMesCam,aMesIm);
    if (! EAMIsInit(&mBoxChambreMm))
    {
          mBoxChambreMm._p0 = Pt2dr(1e20,1e20);
          mBoxChambreMm._p1 = Pt2dr(-1e20,-1e20);
          for (ElPackHomologue::const_iterator itC=mPack.begin() ; itC!=mPack.end() ; itC++)
          {
               mBoxChambreMm._p0  = Inf(mBoxChambreMm._p0,itC->P1());
               mBoxChambreMm._p1  = Sup(mBoxChambreMm._p1,itC->P1());
          }
    }
    mBoxChambrePix._p0 = ChambreMm2ChambrePixel(mBoxChambreMm._p0);
    mBoxChambrePix._p1 = ChambreMm2ChambrePixel(mBoxChambreMm._p1);

/*
    mAffChambreMm2PixIm = ElAffin2D::L2Fit(mPack,&mResidu);
    mAffPixIm2ChambreMm  = mAffChambreMm2PixIm.inv();
    std::cout << "FOR " << mNameIm << " RESIDU " << mResidu  << " \n";
*/
}