00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00021 #include<ImLib3D/Signal1D.hpp>
00022 
00024 void
00025 LinearCompleteLowConfidence(Signal1Df &fct,vector<double> &confidence,float minconf)
00026 {
00027     for(int x=0;x<fct.NbSambles();x++)
00028     {
00029         
00030         if(confidence[x]<minconf)
00031         {
00032             double va,vb;
00033             int xa,xb;
00034             int ct=0,d=( x>fct.NbSambles()/2 ? -1 :1 );
00035             for(int xx=x;ct<=4;xx+=d)
00036             {
00037                 if(xx<0 || xx>=(int)confidence.size()){ThrowError("xx overflow:%d",xx);}
00038                 if(confidence[xx]>=minconf)
00039                 {
00040                     if(ct==0){va=fct[xx];xa=xx;}
00041                     if(ct==4){vb=fct[xx];xb=xx;}
00042                     ct++;
00043                 }
00044             }
00045             fct[x]=(x-xa)*(vb-va)/(float)(xb-xa)+va;
00046             printf("filling at:%d :pta:%d %f ptb:%d %f  ::%f \n",x,xa,va,xb,vb,fct[x]);
00047         }
00048     }
00049 }
00050 
00051 
00052 void 
00053 Signal1Df::Read( ImLib3DFile *file,xmlpp::Element *parentNode,xmlpp::Element *node)
00054 {
00055     node=CreateReadNode("Signal1Df",file,parentNode,node);
00056     xmlpp::Element *mNode=file->GetChild(node,"Size");
00057     values.resize(file->GetIntAttribute(mNode,"size"));
00058     mNode=file->GetChild(node,"Support");
00059     x0=file->GetDoubleAttribute(mNode,"x0");
00060     x1=file->GetDoubleAttribute(mNode,"x1");
00061     xmlpp::Element *dataN=file->GetChild(node,"SignalData");
00062     file->ReadBinaryNode(dataN);
00063     file->BinaryRead<float>(&values[0],&values[0]+values.size());
00064 
00065 }
00066 
00067 void 
00068 Signal1Df::Write(ImLib3DFile *file,xmlpp::Element *parentNode,xmlpp::Element *node) const
00069 {
00070     node=CreateWriteNode("Signal1Df",file,parentNode,node);
00071     xmlpp::Element *mNode=node->add_child("Size");
00072     mNode->set_attribute("size",SPrintf("%d",values.size()));
00073     mNode=node->add_child("Support");
00074     mNode->set_attribute("x0",SPrintf("%10.10f",x0));
00075     mNode->set_attribute("x1",SPrintf("%10.10f",x1));
00076 
00077     xmlpp::Element *dataN=node->add_child("SignalData");
00078     file->AddBinaryNode(dataN,values.size()*sizeof(float));
00079     
00080     file->BinaryWrite<float,const float *>(&values[0],&values[0]+values.size());
00081 
00082 }