3 # File : itkSTMS_BlurringSTMS.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.h"
67 #include "itkSTMS_XMLFileParser.h"
72 struct timespec timestamp;
74 clock_gettime(CLOCK_REALTIME, ×tamp);
75 return timestamp.tv_sec * 1000.0 + timestamp.tv_nsec * 1.0e-6;
81 template < class IndexType, class SpatialType, class PixelType, class ImageType >
82 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
83 ::itkSTMS_BlurringSTMS( IndexSampleSetType* idx, IndexSampleSetType* cla, IndexSampleSetType* wei,
84 SpatialSampleSetType* sp, RangeSampleSetType* ra, ParametersType* params, ParserOutputType* desc)
88 this->weightsSet = wei;
89 this->spatialSet = sp;
92 this->classSetMemory = new IndexSampleSetType ( *this->classSet );
93 this->spatialSetMemory = new SpatialSampleSetType( *this->spatialSet );
95 this->stmsParams = params;
96 this->expDescription = desc;
98 this->mergeFactor = 1000;
102 template < class IndexType, class SpatialType, class PixelType, class ImageType >
104 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
109 if( !stmsParams->merge )
111 std::cout<< std::endl<<"No merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
112 NoMergeSTMSFiltering();
115 ClassificationNoMergeSTMSFiltering();
116 dtime = gettime()-dtime;
117 std::cout<< std::endl<<"Classif: " << dtime/1000 << " s" <<std::endl;
122 std::cout<<std::endl<<"Merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
123 MergeSTMSFiltering();
125 // ClassificationNoMergeSTMSFiltering();
129 template < class IndexType, class SpatialType, class PixelType, class ImageType >
131 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
132 ::ClassificationNoMergeSTMSFiltering()
135 IndexSampleSetType* newClassSet
136 = new IndexSampleSetType();
137 newClassSet->reserve ( indexSet->size() );
139 IndexSampleSetType* newWeightsSet
140 = new IndexSampleSetType();
141 newWeightsSet->reserve( indexSet->size() );
143 IndexSampleSetType* newIndexSet
144 = new IndexSampleSetType();
145 newIndexSet->reserve ( indexSet->size() );
147 SpatialSampleSetType* newSpatialSet
148 = new SpatialSampleSetType();
150 newSpatialSet->reserve( indexSet->size() );
152 RangeSampleSetType* newRangeSet
153 = new RangeSampleSetType();
154 newRangeSet->reserve ( indexSet->size() );
157 newClassSet->push_back ( 1 );
158 newWeightsSet->push_back( 1 );
159 newIndexSet->push_back ( indexSet->at(0) );
160 newSpatialSet->push_back( spatialSet->at(0) );
161 newRangeSet->push_back ( rangeSet->at(0) );
162 classSetMemory->at( indexSet->at(0) ) = newClassSet->at(0);
170 for(unsigned int i=1 ; i<indexSet->size() ; ++i)
175 while( (k<newClassSet->size()) && newC )
177 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
180 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
183 VectorWeightedMean( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
184 VectorWeightedMean( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
186 classSetMemory->at( indexSet->at(i) ) = newClassSet->at(k);
198 newClassSet->push_back( (IndexType)newClassSet->back()+1 );
199 newWeightsSet->push_back( 1 );
200 newIndexSet->push_back ( indexSet->at(i) );
201 newSpatialSet->push_back( spatialSet->at(i) );
202 newRangeSet->push_back ( rangeSet->at(i) );
203 classSetMemory->at( indexSet->at(i) ) = newClassSet->back();
207 classSet->swap ( *newClassSet );
208 weightsSet->swap( *newWeightsSet );
209 indexSet->swap ( *newIndexSet );
210 spatialSet->swap( *newSpatialSet );
211 rangeSet->swap ( *newRangeSet );
214 delete newWeightsSet;
216 delete newSpatialSet;
221 template < class IndexType, class SpatialType, class PixelType, class ImageType >
223 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
224 ::NoMergeSTMSFiltering()
227 SpatialSampleSetType* newSpatialSet
228 = new SpatialSampleSetType( indexSet->size(), SpatialVectorType(stmsParams->dim, 0) );
229 RangeSampleSetType* newRangeSet
230 = new RangeSampleSetType( indexSet->size(), RangeVectorType(stmsParams->numTimePoints, 0) );
232 float globalEvolution = INFINITY;
233 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
234 float spDist, raDist;
236 unsigned int iter = 0;
239 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
242 globalEvolution = 0.0;
244 #pragma omp parallel for reduction(+:globalEvolution) private(spDist, raDist, raNorm)
245 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
247 unsigned int count = 0;
248 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
249 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
251 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
253 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
257 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
261 VectorAcc( tmpSpatial, spatialSet->at(j) );
262 VectorAcc( tmpRange , rangeSet->at(j) );
271 VectorDiv( tmpSpatial, count );
272 VectorDiv( tmpRange , count );
275 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
276 VectorDistance(raDist, rangeSet->at(i), tmpRange);
278 globalEvolution += (spDist+raDist);
282 newSpatialSet->at(i) = tmpSpatial;
283 newRangeSet->at(i) = tmpRange;
287 spatialSet->swap( *newSpatialSet );
288 rangeSet->swap ( *newRangeSet );
291 dtime = gettime()-dtime;
292 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution <<std::endl;
295 delete newSpatialSet;
302 template < class IndexType, class SpatialType, class PixelType, class ImageType >
304 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
305 ::MergeSTMSFiltering()
308 float globalEvolution = INFINITY;
309 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
310 float spDist, raDist;
311 bool raNorm, mergeNorm;
312 unsigned int iter = 0;
313 unsigned int merging;
316 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
318 SpatialSampleSetType* newSpatialSet
319 = new SpatialSampleSetType( *spatialSet );
320 RangeSampleSetType* newRangeSet
321 = new RangeSampleSetType ( *rangeSet );
324 globalEvolution = 0.0;
327 #pragma omp parallel for reduction(+:globalEvolution, merging) private(spDist, raDist, raNorm, mergeNorm)
328 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
330 unsigned int weight = 0;
332 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
333 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
335 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
337 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
341 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
345 VectorWeightedAcc(tmpSpatial, spatialSet->at(j), weightsSet->at(j));
346 VectorWeightedAcc(tmpRange , rangeSet->at(j) , weightsSet->at(j));
348 weight += weightsSet->at(j);
350 MergeInfiniteNorm(mergeNorm, rangeSet->at(i), rangeSet->at(j));
351 if( (spDist <= (1/mergeFactor)) && mergeNorm )
357 if(weight > weightsSet->at(i))
368 VectorDiv( tmpSpatial, weight );
369 VectorDiv( tmpRange , weight );
373 newSpatialSet->at(i) = tmpSpatial;
374 newRangeSet->at(i) = tmpRange;
377 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
378 VectorDistance(raDist, rangeSet->at(i), tmpRange);
380 globalEvolution += (spDist+raDist);
383 spatialSet->swap( *newSpatialSet );
384 rangeSet->swap ( *newRangeSet );
386 delete newSpatialSet;
393 dtime = gettime()-dtime;
394 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution << " numSamples: "<< classSet->size() <<std::endl;
399 template< class IndexType, class SpatialType, class PixelType, class ImageType >
401 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
405 IndexSampleSetType* newClassSet
406 = new IndexSampleSetType();
407 newClassSet->reserve ( indexSet->size() );
409 IndexSampleSetType* newWeightsSet
410 = new IndexSampleSetType();
411 newWeightsSet->reserve( indexSet->size() );
413 IndexSampleSetType* newIndexSet
414 = new IndexSampleSetType();
415 newIndexSet->reserve ( indexSet->size() );
417 SpatialSampleSetType* newSpatialSet
418 = new SpatialSampleSetType();
420 newSpatialSet->reserve( indexSet->size() );
422 RangeSampleSetType* newRangeSet
423 = new RangeSampleSetType();
424 newRangeSet->reserve ( indexSet->size() );
426 IndexSampleSetType* newClassSetMemory
427 = new IndexSampleSetType( *classSetMemory );
429 IndexSampleSetType* indexes
430 = new IndexSampleSetType( *classSet );
432 std::random_device rd;
433 std::mt19937 g(rd());
435 std::shuffle(indexes->begin(), indexes->end(), g);
438 newClassSet->push_back ( 1 );
439 newWeightsSet->push_back( weightsSet->at( indexes->at(0)-1 ) );
440 newIndexSet->push_back ( indexSet->at ( indexes->at(0)-1 ) );
441 newSpatialSet->push_back( spatialSet->at( indexes->at(0)-1 ) );
442 newRangeSet->push_back ( rangeSet->at ( indexes->at(0)-1 ) );
444 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
446 if(classSetMemory->at(l) == classSet->at(indexes->at(0)-1))
447 newClassSetMemory->at(l) = 1;
456 for(unsigned int m=1 ; m<indexes->size() ; ++m)
458 i = indexes->at(m)-1;
463 while( (k<newClassSet->size()) && newC )
465 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
466 MergeInfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
467 if( (spDist<=1/mergeFactor)&&raNorm )
469 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
470 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
472 newWeightsSet->at(k) += weightsSet->at(i);
474 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
475 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
477 for(unsigned int l=0 ; l<classSetMemory->size() ; ++l)
479 if(classSetMemory->at(l) == classSet->at(i))
480 newClassSetMemory->at(l) = newClassSet->at(k);
491 newClassSet->push_back( newClassSet->back()+1 );
492 newWeightsSet->push_back( weightsSet->at(i) );
493 newIndexSet->push_back ( indexSet->at(i) );
494 newSpatialSet->push_back( spatialSet->at(i) );
495 newRangeSet->push_back ( rangeSet->at(i) );
497 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
499 if(classSetMemory->at(l) == classSet->at(i))
500 newClassSetMemory->at(l) = newClassSet->back();
505 classSet->swap ( *newClassSet );
506 weightsSet->swap( *newWeightsSet );
507 indexSet->swap ( *newIndexSet );
508 spatialSet->swap( *newSpatialSet );
509 rangeSet->swap ( *newRangeSet );
510 classSetMemory->swap ( *newClassSetMemory );
513 delete newWeightsSet;
515 delete newSpatialSet;
517 delete newClassSetMemory;
522 template< class IndexType, class SpatialType, class PixelType, class ImageType >
524 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
527 unsigned int size = INFINITY;
528 std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+STMS_NUMBERING_FORM_ONE+expDescription->imageExtension;
530 while(size > classSet->size()){
531 IndexSampleSetType* newClassSet
532 = new IndexSampleSetType();
533 newClassSet->reserve ( indexSet->size() );
535 IndexSampleSetType* newWeightsSet
536 = new IndexSampleSetType();
537 newWeightsSet->reserve( indexSet->size() );
539 IndexSampleSetType* newIndexSet
540 = new IndexSampleSetType();
541 newIndexSet->reserve ( indexSet->size() );
543 SpatialSampleSetType* newSpatialSet
544 = new SpatialSampleSetType();
546 newSpatialSet->reserve( indexSet->size() );
548 RangeSampleSetType* newRangeSet
549 = new RangeSampleSetType();
550 newRangeSet->reserve ( indexSet->size() );
552 IndexSampleSetType* newClassSetMemory
553 = new IndexSampleSetType( *classSetMemory );
555 newClassSet->push_back ( 1 );
556 newWeightsSet->push_back( 1 );
557 newIndexSet->push_back ( indexSet->at(0) );
558 newSpatialSet->push_back( spatialSet->at(0) );
559 newRangeSet->push_back ( rangeSet->at(0) );
565 for(unsigned int i=1 ; i<classSet->size() ; ++i)
570 while( (k<newClassSet->size()) && newC )
572 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
575 ReaderPointer reader = ReaderType::New();
576 ImagePointer image = ImageType::New();
578 reader->SetFileName( imagePath );
580 image = reader->GetOutput();
581 image->FillBuffer( 0 );
583 ImageIndexSetType* refClass = new ImageIndexSetType();
584 ImageIndexSetType* candClass = new ImageIndexSetType();
585 refClass->reserve( classSet->size()/2 );
586 candClass->reserve( classSet->size()/2 );
589 for(unsigned int m=0 ; m<newClassSetMemory->size() ; ++m)
592 if(newClassSetMemory->at(m) == classSet->at(i)){
595 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
596 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
598 candClass->push_back( idx );
599 image->SetPixel(candClass->back(), 1);
603 if(newClassSetMemory->at(m) == newClassSet->at(k)){
606 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
607 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
609 refClass->push_back( idx );
610 image->SetPixel(refClass->back(), 2);
616 if(stmsParams->dim == 2)
618 if(refClass->size() < candClass->size())
622 while((m<refClass->size()) && !connex)
624 for(int x=-1 ; x<=1 ; ++x)
626 for(int y=-1 ; y<=1 ; ++y)
628 idx[0] = refClass->at(m)[0]+x;
629 idx[1] = refClass->at(m)[1]+y;
631 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
633 if(image->GetPixel(idx) == 2)
650 while((m<candClass->size()) && !connex)
652 for(int x=-1 ; x<=1 ; ++x)
654 for(int y=-1 ; y<=1 ; ++y)
656 idx[0] = candClass->at(m)[0]+x;
657 idx[1] = candClass->at(m)[1]+y;
659 if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
661 if(image->GetPixel(idx) == 1)
678 if(refClass->size() < candClass->size())
682 while((m<refClass->size()) && !connex)
684 for(int x=-1 ; x<=1 ; ++x)
686 for(int y=-1 ; y<=1 ; ++y)
688 for(int z=-1 ; z<=1 ; ++z)
690 idx[0] = refClass->at(m)[0]+x;
691 idx[1] = refClass->at(m)[1]+y;
692 idx[2] = refClass->at(m)[2]+z;
694 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)
696 if(image->GetPixel(idx) == 2)
715 while((m<candClass->size()) && !connex)
717 for(int x=-1 ; x<=1 ; ++x)
719 for(int y=-1 ; y<=1 ; ++y)
721 for(int z=-1 ; z<=1 ; ++z)
723 idx[0] = candClass->at(m)[0]+x;
724 idx[1] = candClass->at(m)[1]+y;
725 idx[2] = candClass->at(m)[2]+z;
727 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)
729 if(image->GetPixel(idx) == 1)
749 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
750 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
752 newWeightsSet->at(k) += weightsSet->at(i);
754 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
755 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
757 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
760 if(classSetMemory->at(l) == classSet->at(i))
761 newClassSetMemory->at(l) = newClassSet->at(k);
778 newClassSet->push_back( newClassSet->back()+1 );
779 newWeightsSet->push_back( weightsSet->at(i) );
780 newIndexSet->push_back ( indexSet->at(i) );
781 newSpatialSet->push_back( spatialSet->at(i) );
782 newRangeSet->push_back ( rangeSet->at(i) );
784 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
786 if(classSetMemory->at(l) == classSet->at(i))
787 newClassSetMemory->at(l) = newClassSet->back();
792 size = classSet->size();
794 classSet->swap ( *newClassSet );
795 weightsSet->swap( *newWeightsSet );
796 indexSet->swap ( *newIndexSet );
797 spatialSet->swap( *newSpatialSet );
798 rangeSet->swap ( *newRangeSet );
799 classSetMemory->swap ( *newClassSetMemory );
802 delete newWeightsSet;
804 delete newSpatialSet;
806 delete newClassSetMemory;
812 template< class IndexType, class SpatialType, class PixelType, class ImageType >
815 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
816 ::VectorDistance(float &dist, std::vector<T> &a, std::vector<T> &b)
821 for(unsigned int i=0 ; i<a.size() ; ++i)
822 dist += ( a[i]-b[i] )*( a[i]-b[i] );
826 template < class IndexType, class SpatialType, class PixelType, class ImageType >
828 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
829 ::InfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
833 for(unsigned int i=0 ; i<a.size() ; ++i)
835 if(((a[i]-b[i])*(a[i]-b[i])) > 1)
844 template < class IndexType, class SpatialType, class PixelType, class ImageType >
846 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
847 ::MergeInfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
851 for(unsigned int i=0 ; i<a.size() ; ++i)
853 if(((a[i]-b[i])*(a[i]-b[i])) > (1/mergeFactor))
862 template< class IndexType, class SpatialType, class PixelType, class ImageType >
865 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
866 ::VectorAcc(std::vector<T> &a, std::vector<T> &b)
869 for(unsigned int i=0 ; i<a.size() ; ++i)
873 template< class IndexType, class SpatialType, class PixelType, class ImageType >
876 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
877 ::VectorWeightedAcc(std::vector<T> &a, std::vector<T> &b, unsigned int &b_w)
880 for(unsigned int i=0 ; i<a.size() ; ++i)
884 template< class IndexType, class SpatialType, class PixelType, class ImageType >
887 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
888 ::VectorWeightedAcc(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
891 for(unsigned int i=0 ; i<a.size() ; ++i){
897 template< class IndexType, class SpatialType, class PixelType, class ImageType >
900 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
901 ::VectorWeightedMean(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
904 for(unsigned int i=0 ; i<a.size() ; ++i)
905 a[i] = ( (a[i]*a_w )+(b[i]*b_w) )/( a_w+b_w );
911 template< class IndexType, class SpatialType, class PixelType, class ImageType >
914 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
915 ::VectorMul(std::vector<T> &a, unsigned int &coeff)
918 for(unsigned int i=0 ; i<a.size() ; ++i)
923 template< class IndexType, class SpatialType, class PixelType, class ImageType >
926 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
927 ::VectorDiv(std::vector<T> &a, unsigned int &coeff)
930 for(unsigned int i=0 ; i<a.size() ; ++i)
934 } // end of namespace itkSTMS
936 #endif // itkmsSTMS_BlurringSTMS_TXX