3 # File : itkSTMS_BlurringSTMS_Spine.txx
4 # ( C++ header file - STMS )
6 # Description : STMS lib that implements the STMS filter and clustering.
7 # This file is a part of the STMS Library project.
8 # ( https://www.creatis.insa-lyon.fr/site7/fr/realisations )
10 # [1] S. Mure, Grenier, T., Meier, S., Guttmann, R. G., et Benoit-Cattin, H.,
11 # « Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification »,
12 # Pattern Recognition Letters, vol. 68, Part 1, p. 48 - 55, 2015.
14 # Copyright : Thomas GRENIER - Simon MURE
15 # ( https://www.creatis.insa-lyon.fr/~grenier/ )
18 # ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.txt )
20 # This software is governed by the CeCILL license under French law and
21 # abiding by the rules of distribution of free software. You can use,
22 # modify and/ or redistribute the software under the terms of the CeCILL
23 # license as circulated by CEA, CNRS and INRIA at the following URL
24 # "http://www.cecill.info".
26 # As a counterpart to the access to the source code and rights to copy,
27 # modify and redistribute granted by the license, users are provided only
28 # with a limited warranty and the software's author, the holder of the
29 # economic rights, and the successive licensors have only limited
32 # In this respect, the user's attention is drawn to the risks associated
33 # with loading, using, modifying and/or developing or reproducing the
34 # software by the user in light of its specific status of free software,
35 # that may mean that it is complicated to manipulate, and that also
36 # therefore means that it is reserved for developers and experienced
37 # professionals having in-depth computer knowledge. Users are therefore
38 # encouraged to load and test the software's suitability as regards their
39 # requirements in conditions enabling the security of their systems and/or
40 # data to be ensured and, more generally, to use and operate it in the
41 # same conditions as regards security.
43 # The fact that you are presently reading this means that you have had
44 # knowledge of the CeCILL license and that you accept its terms.
47 /* Please don't forget to cite our work :
49 title = {Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification},
50 journal = {Pattern Recognition Letters},
51 volume = {68, Part 1},
55 doi = {http://dx.doi.org/10.1016/j.patrec.2015.07.021},
56 url = {http://www.sciencedirect.com/science/article/pii/S0167865515002305},
57 author = {S. Mure and T Grenier and Meier, S. and Guttmann, R.G. and H. Benoit-Cattin}
60 #ifndef itkSTMS_BlurringSTMS_TXX
61 #define itkSTMS_BlurringSTMS_TXX
66 #include "itkSTMS_BlurringSTMS_Spine.h"
71 struct timespec timestamp;
73 clock_gettime(CLOCK_REALTIME, ×tamp);
74 return timestamp.tv_sec * 1000.0 + timestamp.tv_nsec * 1.0e-6;
78 namespace itkSTMS_Spine
80 template < class IndexType, class SpatialType, class PixelType, class ImageType >
81 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
82 ::itkSTMS_BlurringSTMS( IndexSampleSetType* idx, IndexSampleSetType* cla, IndexSampleSetType* wei,
83 SpatialSampleSetType* sp, RangeSampleSetType* ra, ParametersType* params )
87 this->weightsSet = wei;
88 this->spatialSet = sp;
91 this->classSetMemory = new IndexSampleSetType ( *this->classSet );
92 this->spatialSetMemory = new SpatialSampleSetType( *this->spatialSet );
94 this->stmsParams = params;
96 this->mergeFactor = 1000;
100 template < class IndexType, class SpatialType, class PixelType, class ImageType >
102 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
107 if( !stmsParams->merge )
109 std::cout<< std::endl<<"No merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
110 NoMergeSTMSFiltering();
113 ClassificationNoMergeSTMSFiltering();
114 dtime = gettime()-dtime;
115 std::cout<< std::endl<<"Classif: " << dtime/1000 << " s" <<std::endl;
120 std::cout<<std::endl<<"Merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
121 MergeSTMSFiltering();
123 // ClassificationNoMergeSTMSFiltering();
127 template < class IndexType, class SpatialType, class PixelType, class ImageType >
129 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
130 ::ClassificationNoMergeSTMSFiltering()
133 IndexSampleSetType* newClassSet
134 = new IndexSampleSetType();
135 newClassSet->reserve ( indexSet->size() );
137 IndexSampleSetType* newWeightsSet
138 = new IndexSampleSetType();
139 newWeightsSet->reserve( indexSet->size() );
141 IndexSampleSetType* newIndexSet
142 = new IndexSampleSetType();
143 newIndexSet->reserve ( indexSet->size() );
145 SpatialSampleSetType* newSpatialSet
146 = new SpatialSampleSetType();
148 newSpatialSet->reserve( indexSet->size() );
150 RangeSampleSetType* newRangeSet
151 = new RangeSampleSetType();
152 newRangeSet->reserve ( indexSet->size() );
155 newClassSet->push_back ( 1 );
156 newWeightsSet->push_back( 1 );
157 newIndexSet->push_back ( indexSet->at(0) );
158 newSpatialSet->push_back( spatialSet->at(0) );
159 newRangeSet->push_back ( rangeSet->at(0) );
160 classSetMemory->at( indexSet->at(0) ) = newClassSet->at(0);
168 for(unsigned int i=1 ; i<indexSet->size() ; ++i)
173 while( (k<newClassSet->size()) && newC )
175 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
178 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
181 VectorWeightedMean( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
182 VectorWeightedMean( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
184 classSetMemory->at( indexSet->at(i) ) = newClassSet->at(k);
196 newClassSet->push_back( (IndexType)newClassSet->back()+1 );
197 newWeightsSet->push_back( 1 );
198 newIndexSet->push_back ( indexSet->at(i) );
199 newSpatialSet->push_back( spatialSet->at(i) );
200 newRangeSet->push_back ( rangeSet->at(i) );
201 classSetMemory->at( indexSet->at(i) ) = newClassSet->back();
205 classSet->swap ( *newClassSet );
206 weightsSet->swap( *newWeightsSet );
207 indexSet->swap ( *newIndexSet );
208 spatialSet->swap( *newSpatialSet );
209 rangeSet->swap ( *newRangeSet );
212 delete newWeightsSet;
214 delete newSpatialSet;
219 template < class IndexType, class SpatialType, class PixelType, class ImageType >
221 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
222 ::NoMergeSTMSFiltering()
225 SpatialSampleSetType* newSpatialSet
226 = new SpatialSampleSetType( indexSet->size(), SpatialVectorType(stmsParams->dim, 0) );
227 RangeSampleSetType* newRangeSet
228 = new RangeSampleSetType( indexSet->size(), RangeVectorType(stmsParams->numTimePoints, 0) );
230 float globalEvolution = INFINITY;
231 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
232 float spDist, raDist;
234 unsigned int iter = 0;
237 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
240 globalEvolution = 0.0;
242 #pragma omp parallel for reduction(+:globalEvolution) private(spDist, raDist, raNorm)
243 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
245 unsigned int count = 0;
246 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
247 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
249 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
251 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
255 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
259 VectorAcc( tmpSpatial, spatialSet->at(j) );
260 VectorAcc( tmpRange , rangeSet->at(j) );
269 VectorDiv( tmpSpatial, count );
270 VectorDiv( tmpRange , count );
273 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
274 VectorDistance(raDist, rangeSet->at(i), tmpRange);
276 globalEvolution += (spDist+raDist);
280 newSpatialSet->at(i) = tmpSpatial;
281 newRangeSet->at(i) = tmpRange;
285 spatialSet->swap( *newSpatialSet );
286 rangeSet->swap ( *newRangeSet );
289 dtime = gettime()-dtime;
290 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution <<std::endl;
293 delete newSpatialSet;
300 template < class IndexType, class SpatialType, class PixelType, class ImageType >
302 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
303 ::MergeSTMSFiltering()
306 float globalEvolution = INFINITY;
307 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
308 float spDist, raDist;
309 bool raNorm, mergeNorm;
310 unsigned int iter = 0;
311 unsigned int merging;
314 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
316 SpatialSampleSetType* newSpatialSet
317 = new SpatialSampleSetType( *spatialSet );
318 RangeSampleSetType* newRangeSet
319 = new RangeSampleSetType ( *rangeSet );
322 globalEvolution = 0.0;
325 #pragma omp parallel for reduction(+:globalEvolution, merging) private(spDist, raDist, raNorm, mergeNorm)
326 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
328 unsigned int weight = 0;
330 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
331 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
333 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
335 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
339 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
343 VectorWeightedAcc(tmpSpatial, spatialSet->at(j), weightsSet->at(j));
344 VectorWeightedAcc(tmpRange , rangeSet->at(j) , weightsSet->at(j));
346 weight += weightsSet->at(j);
348 MergeInfiniteNorm(mergeNorm, rangeSet->at(i), rangeSet->at(j));
349 if( (spDist <= (1/mergeFactor)) && mergeNorm )
355 if(weight > weightsSet->at(i))
366 VectorDiv( tmpSpatial, weight );
367 VectorDiv( tmpRange , weight );
371 newSpatialSet->at(i) = tmpSpatial;
372 newRangeSet->at(i) = tmpRange;
375 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
376 VectorDistance(raDist, rangeSet->at(i), tmpRange);
378 globalEvolution += (spDist+raDist);
381 spatialSet->swap( *newSpatialSet );
382 rangeSet->swap ( *newRangeSet );
384 delete newSpatialSet;
391 dtime = gettime()-dtime;
392 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution << " numSamples: "<< classSet->size() <<std::endl;
397 template< class IndexType, class SpatialType, class PixelType, class ImageType >
399 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
403 IndexSampleSetType* newClassSet
404 = new IndexSampleSetType();
405 newClassSet->reserve ( indexSet->size() );
407 IndexSampleSetType* newWeightsSet
408 = new IndexSampleSetType();
409 newWeightsSet->reserve( indexSet->size() );
411 IndexSampleSetType* newIndexSet
412 = new IndexSampleSetType();
413 newIndexSet->reserve ( indexSet->size() );
415 SpatialSampleSetType* newSpatialSet
416 = new SpatialSampleSetType();
418 newSpatialSet->reserve( indexSet->size() );
420 RangeSampleSetType* newRangeSet
421 = new RangeSampleSetType();
422 newRangeSet->reserve ( indexSet->size() );
424 IndexSampleSetType* newClassSetMemory
425 = new IndexSampleSetType( *classSetMemory );
427 IndexSampleSetType* indexes
428 = new IndexSampleSetType( *classSet );
430 std::random_device rd;
431 std::mt19937 g(rd());
433 std::shuffle(indexes->begin(), indexes->end(), g);
436 newClassSet->push_back ( 1 );
437 newWeightsSet->push_back( weightsSet->at( indexes->at(0)-1 ) );
438 newIndexSet->push_back ( indexSet->at ( indexes->at(0)-1 ) );
439 newSpatialSet->push_back( spatialSet->at( indexes->at(0)-1 ) );
440 newRangeSet->push_back ( rangeSet->at ( indexes->at(0)-1 ) );
442 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
444 if(classSetMemory->at(l) == classSet->at(indexes->at(0)-1))
445 newClassSetMemory->at(l) = 1;
454 for(unsigned int m=1 ; m<indexes->size() ; ++m)
456 i = indexes->at(m)-1;
461 while( (k<newClassSet->size()) && newC )
463 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
464 MergeInfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
465 if( (spDist<=1/mergeFactor)&&raNorm )
467 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
468 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
470 newWeightsSet->at(k) += weightsSet->at(i);
472 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
473 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
475 for(unsigned int l=0 ; l<classSetMemory->size() ; ++l)
477 if(classSetMemory->at(l) == classSet->at(i))
478 newClassSetMemory->at(l) = newClassSet->at(k);
489 newClassSet->push_back( newClassSet->back()+1 );
490 newWeightsSet->push_back( weightsSet->at(i) );
491 newIndexSet->push_back ( indexSet->at(i) );
492 newSpatialSet->push_back( spatialSet->at(i) );
493 newRangeSet->push_back ( rangeSet->at(i) );
495 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
497 if(classSetMemory->at(l) == classSet->at(i))
498 newClassSetMemory->at(l) = newClassSet->back();
503 classSet->swap ( *newClassSet );
504 weightsSet->swap( *newWeightsSet );
505 indexSet->swap ( *newIndexSet );
506 spatialSet->swap( *newSpatialSet );
507 rangeSet->swap ( *newRangeSet );
508 classSetMemory->swap ( *newClassSetMemory );
511 delete newWeightsSet;
513 delete newSpatialSet;
515 delete newClassSetMemory;
520 template< class IndexType, class SpatialType, class PixelType, class ImageType >
522 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
525 unsigned int size = INFINITY;
526 while(size > classSet->size()){
527 IndexSampleSetType* newClassSet
528 = new IndexSampleSetType();
529 newClassSet->reserve ( indexSet->size() );
531 IndexSampleSetType* newWeightsSet
532 = new IndexSampleSetType();
533 newWeightsSet->reserve( indexSet->size() );
535 IndexSampleSetType* newIndexSet
536 = new IndexSampleSetType();
537 newIndexSet->reserve ( indexSet->size() );
539 SpatialSampleSetType* newSpatialSet
540 = new SpatialSampleSetType();
542 newSpatialSet->reserve( indexSet->size() );
544 RangeSampleSetType* newRangeSet
545 = new RangeSampleSetType();
546 newRangeSet->reserve ( indexSet->size() );
548 IndexSampleSetType* newClassSetMemory
549 = new IndexSampleSetType( *classSetMemory );
551 newClassSet->push_back ( 1 );
552 newWeightsSet->push_back( 1 );
553 newIndexSet->push_back ( indexSet->at(0) );
554 newSpatialSet->push_back( spatialSet->at(0) );
555 newRangeSet->push_back ( rangeSet->at(0) );
561 for(unsigned int i=1 ; i<classSet->size() ; ++i)
566 while( (k<newClassSet->size()) && newC )
568 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
571 ReaderPointer reader = ReaderType::New();
572 ImagePointer image = ImageType::New();
574 reader->SetFileName( *stmsParams->images.begin() );
576 image = reader->GetOutput();
577 image->FillBuffer( 0 );
579 ImageIndexSetType* refClass = new ImageIndexSetType();
580 ImageIndexSetType* candClass = new ImageIndexSetType();
581 refClass->reserve( classSet->size()/2 );
582 candClass->reserve( classSet->size()/2 );
585 for(unsigned int m=0 ; m<newClassSetMemory->size() ; ++m)
588 if(newClassSetMemory->at(m) == classSet->at(i)){
591 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
592 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
594 candClass->push_back( idx );
595 image->SetPixel(candClass->back(), 1);
599 if(newClassSetMemory->at(m) == newClassSet->at(k)){
602 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
603 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
605 refClass->push_back( idx );
606 image->SetPixel(refClass->back(), 2);
612 if(stmsParams->dim == 2)
614 if(refClass->size() < candClass->size())
618 while((m<refClass->size()) && !connex)
620 for(int x=-1 ; x<=1 ; ++x)
622 for(int y=-1 ; y<=1 ; ++y)
624 idx[0] = refClass->at(m)[0]+x;
625 idx[1] = refClass->at(m)[1]+y;
627 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
629 if(image->GetPixel(idx) == 2)
646 while((m<candClass->size()) && !connex)
648 for(int x=-1 ; x<=1 ; ++x)
650 for(int y=-1 ; y<=1 ; ++y)
652 idx[0] = candClass->at(m)[0]+x;
653 idx[1] = candClass->at(m)[1]+y;
655 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
657 if(image->GetPixel(idx) == 1)
674 if(refClass->size() < candClass->size())
678 while((m<refClass->size()) && !connex)
680 for(int x=-1 ; x<=1 ; ++x)
682 for(int y=-1 ; y<=1 ; ++y)
684 for(int z=-1 ; z<=1 ; ++z)
686 idx[0] = refClass->at(m)[0]+x;
687 idx[1] = refClass->at(m)[1]+y;
688 idx[2] = refClass->at(m)[2]+z;
690 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
692 if(image->GetPixel(idx) == 2)
711 while((m<candClass->size()) && !connex)
713 for(int x=-1 ; x<=1 ; ++x)
715 for(int y=-1 ; y<=1 ; ++y)
717 for(int z=-1 ; z<=1 ; ++z)
719 idx[0] = candClass->at(m)[0]+x;
720 idx[1] = candClass->at(m)[1]+y;
721 idx[2] = candClass->at(m)[2]+z;
723 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
725 if(image->GetPixel(idx) == 1)
745 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
746 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
748 newWeightsSet->at(k) += weightsSet->at(i);
750 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
751 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
753 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
756 if(classSetMemory->at(l) == classSet->at(i))
757 newClassSetMemory->at(l) = newClassSet->at(k);
774 newClassSet->push_back( newClassSet->back()+1 );
775 newWeightsSet->push_back( weightsSet->at(i) );
776 newIndexSet->push_back ( indexSet->at(i) );
777 newSpatialSet->push_back( spatialSet->at(i) );
778 newRangeSet->push_back ( rangeSet->at(i) );
780 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
782 if(classSetMemory->at(l) == classSet->at(i))
783 newClassSetMemory->at(l) = newClassSet->back();
788 size = classSet->size();
790 classSet->swap ( *newClassSet );
791 weightsSet->swap( *newWeightsSet );
792 indexSet->swap ( *newIndexSet );
793 spatialSet->swap( *newSpatialSet );
794 rangeSet->swap ( *newRangeSet );
795 classSetMemory->swap ( *newClassSetMemory );
798 delete newWeightsSet;
800 delete newSpatialSet;
802 delete newClassSetMemory;
808 template< class IndexType, class SpatialType, class PixelType, class ImageType >
811 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
812 ::VectorDistance(float &dist, std::vector<T> &a, std::vector<T> &b)
817 for(unsigned int i=0 ; i<a.size() ; ++i)
818 dist += ( a[i]-b[i] )*( a[i]-b[i] );
822 template < class IndexType, class SpatialType, class PixelType, class ImageType >
824 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
825 ::InfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
829 for(unsigned int i=0 ; i<a.size() ; ++i)
831 if(((a[i]-b[i])*(a[i]-b[i])) > 1)
840 template < class IndexType, class SpatialType, class PixelType, class ImageType >
842 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
843 ::MergeInfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
847 for(unsigned int i=0 ; i<a.size() ; ++i)
849 if(((a[i]-b[i])*(a[i]-b[i])) > (1/mergeFactor))
858 template< class IndexType, class SpatialType, class PixelType, class ImageType >
861 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
862 ::VectorAcc(std::vector<T> &a, std::vector<T> &b)
865 for(unsigned int i=0 ; i<a.size() ; ++i)
869 template< class IndexType, class SpatialType, class PixelType, class ImageType >
872 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
873 ::VectorWeightedAcc(std::vector<T> &a, std::vector<T> &b, unsigned int &b_w)
876 for(unsigned int i=0 ; i<a.size() ; ++i)
880 template< class IndexType, class SpatialType, class PixelType, class ImageType >
883 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
884 ::VectorWeightedAcc(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
887 for(unsigned int i=0 ; i<a.size() ; ++i){
893 template< class IndexType, class SpatialType, class PixelType, class ImageType >
896 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
897 ::VectorWeightedMean(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
900 for(unsigned int i=0 ; i<a.size() ; ++i)
901 a[i] = ( (a[i]*a_w )+(b[i]*b_w) )/( a_w+b_w );
907 template< class IndexType, class SpatialType, class PixelType, class ImageType >
910 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
911 ::VectorMul(std::vector<T> &a, unsigned int &coeff)
914 for(unsigned int i=0 ; i<a.size() ; ++i)
919 template< class IndexType, class SpatialType, class PixelType, class ImageType >
922 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
923 ::VectorDiv(std::vector<T> &a, unsigned int &coeff)
926 for(unsigned int i=0 ; i<a.size() ; ++i)
930 } // end of namespace itkSTMS
932 #endif // itkmsSTMS_BlurringSTMS_Spine_TXX