Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Signal1D.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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         // if low confidence, look for two nearest hig conf
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     // write image's binary block 
00080     file->BinaryWrite<float,const float *>(&values[0],&values[0]+values.size());
00081 
00082 }

Generated on Fri Jun 17 13:36:07 2005 for ImLib3D by  doxygen 1.4.2