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
67 #include "itkSTMS_BlurringSTMS.h"
68 #include "itkSTMS_XMLFileParser.h"
73 struct timespec timestamp;
75 clock_gettime(CLOCK_REALTIME, ×tamp);
76 return timestamp.tv_sec * 1000.0 + timestamp.tv_nsec * 1.0e-6;
82 template < class IndexType, class SpatialType, class PixelType, class ImageType >
83 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
84 ::itkSTMS_BlurringSTMS( IndexSampleSetType* idx, IndexSampleSetType* cla, IndexSampleSetType* wei,
85 SpatialSampleSetType* sp, RangeSampleSetType* ra, ParametersType* params, ParserOutputType* desc)
89 this->weightsSet = wei;
90 this->spatialSet = sp;
93 this->classSetMemory = new IndexSampleSetType ( *this->classSet );
94 this->spatialSetMemory = new SpatialSampleSetType( *this->spatialSet );
96 this->stmsParams = params;
97 this->expDescription = desc;
99 this->mergeFactor = 1000;
103 template < class IndexType, class SpatialType, class PixelType, class ImageType >
105 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
110 if( !stmsParams->merge )
112 std::cout<< std::endl<<"No merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
113 NoMergeSTMSFiltering();
116 ClassificationNoMergeSTMSFiltering();
117 dtime = gettime()-dtime;
118 std::cout<< std::endl<<"Classif: " << dtime/1000 << " s" <<std::endl;
123 std::cout<<std::endl<<"Merge Filtering!"<<std::endl<<"numSamples: "<< indexSet->size() <<std::endl<< std::endl;
124 MergeSTMSFiltering();
126 // ClassificationNoMergeSTMSFiltering();
130 template < class IndexType, class SpatialType, class PixelType, class ImageType >
132 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
133 ::ClassificationNoMergeSTMSFiltering()
136 IndexSampleSetType* newClassSet
137 = new IndexSampleSetType();
138 newClassSet->reserve ( indexSet->size() );
140 IndexSampleSetType* newWeightsSet
141 = new IndexSampleSetType();
142 newWeightsSet->reserve( indexSet->size() );
144 IndexSampleSetType* newIndexSet
145 = new IndexSampleSetType();
146 newIndexSet->reserve ( indexSet->size() );
148 SpatialSampleSetType* newSpatialSet
149 = new SpatialSampleSetType();
151 newSpatialSet->reserve( indexSet->size() );
153 RangeSampleSetType* newRangeSet
154 = new RangeSampleSetType();
155 newRangeSet->reserve ( indexSet->size() );
158 newClassSet->push_back ( 1 );
159 newWeightsSet->push_back( 1 );
160 newIndexSet->push_back ( indexSet->at(0) );
161 newSpatialSet->push_back( spatialSet->at(0) );
162 newRangeSet->push_back ( rangeSet->at(0) );
163 classSetMemory->at( indexSet->at(0) ) = newClassSet->at(0);
171 for(unsigned int i=1 ; i<indexSet->size() ; ++i)
176 while( (k<newClassSet->size()) && newC )
178 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
181 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
184 VectorWeightedMean( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
185 VectorWeightedMean( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
187 classSetMemory->at( indexSet->at(i) ) = newClassSet->at(k);
199 newClassSet->push_back( (IndexType)newClassSet->back()+1 );
200 newWeightsSet->push_back( 1 );
201 newIndexSet->push_back ( indexSet->at(i) );
202 newSpatialSet->push_back( spatialSet->at(i) );
203 newRangeSet->push_back ( rangeSet->at(i) );
204 classSetMemory->at( indexSet->at(i) ) = newClassSet->back();
208 classSet->swap ( *newClassSet );
209 weightsSet->swap( *newWeightsSet );
210 indexSet->swap ( *newIndexSet );
211 spatialSet->swap( *newSpatialSet );
212 rangeSet->swap ( *newRangeSet );
215 delete newWeightsSet;
217 delete newSpatialSet;
222 template < class IndexType, class SpatialType, class PixelType, class ImageType >
224 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
225 ::NoMergeSTMSFiltering()
228 SpatialSampleSetType* newSpatialSet
229 = new SpatialSampleSetType( indexSet->size(), SpatialVectorType(stmsParams->dim, 0) );
230 RangeSampleSetType* newRangeSet
231 = new RangeSampleSetType( indexSet->size(), RangeVectorType(stmsParams->numTimePoints, 0) );
233 float globalEvolution = INFINITY;
234 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
235 float spDist, raDist;
237 unsigned int iter = 0;
240 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
243 globalEvolution = 0.0;
245 #pragma omp parallel for reduction(+:globalEvolution) private(spDist, raDist, raNorm)
246 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
248 unsigned int count = 0;
249 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
250 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
252 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
254 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
258 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
262 VectorAcc( tmpSpatial, spatialSet->at(j) );
263 VectorAcc( tmpRange , rangeSet->at(j) );
272 VectorDiv( tmpSpatial, count );
273 VectorDiv( tmpRange , count );
276 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
277 VectorDistance(raDist, rangeSet->at(i), tmpRange);
279 globalEvolution += (spDist+raDist);
283 newSpatialSet->at(i) = tmpSpatial;
284 newRangeSet->at(i) = tmpRange;
288 spatialSet->swap( *newSpatialSet );
289 rangeSet->swap ( *newRangeSet );
292 dtime = gettime()-dtime;
293 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution <<std::endl;
296 delete newSpatialSet;
303 template < class IndexType, class SpatialType, class PixelType, class ImageType >
305 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
306 ::MergeSTMSFiltering()
309 float globalEvolution = INFINITY;
310 float epsilon = (stmsParams->epsilon)*(stmsParams->epsilon);
311 float spDist, raDist;
312 bool raNorm, mergeNorm;
313 unsigned int iter = 0;
314 unsigned int merging;
317 while( (globalEvolution>epsilon) & (iter<stmsParams->maxIt) )
319 SpatialSampleSetType* newSpatialSet
320 = new SpatialSampleSetType( *spatialSet );
321 RangeSampleSetType* newRangeSet
322 = new RangeSampleSetType ( *rangeSet );
325 globalEvolution = 0.0;
328 #pragma omp parallel for reduction(+:globalEvolution, merging) private(spDist, raDist, raNorm, mergeNorm)
329 for(unsigned int i=0 ; i<indexSet->size() ; ++i)
331 unsigned int weight = 0;
333 SpatialVectorType tmpSpatial( stmsParams->dim, 0 );
334 RangeVectorType tmpRange ( stmsParams->numTimePoints, 0 );
336 for(unsigned int j=0 ; j<indexSet->size() ; ++j)
338 VectorDistance( spDist, spatialSet->at(i), spatialSet->at(j));
342 InfiniteNorm(raNorm, rangeSet->at(i), rangeSet->at(j));
346 VectorWeightedAcc(tmpSpatial, spatialSet->at(j), weightsSet->at(j));
347 VectorWeightedAcc(tmpRange , rangeSet->at(j) , weightsSet->at(j));
349 weight += weightsSet->at(j);
351 MergeInfiniteNorm(mergeNorm, rangeSet->at(i), rangeSet->at(j));
352 if( (spDist <= (1/mergeFactor)) && mergeNorm )
358 if(weight > weightsSet->at(i))
369 VectorDiv( tmpSpatial, weight );
370 VectorDiv( tmpRange , weight );
374 newSpatialSet->at(i) = tmpSpatial;
375 newRangeSet->at(i) = tmpRange;
378 VectorDistance(spDist, spatialSet->at(i), tmpSpatial);
379 VectorDistance(raDist, rangeSet->at(i), tmpRange);
381 globalEvolution += (spDist+raDist);
384 spatialSet->swap( *newSpatialSet );
385 rangeSet->swap ( *newRangeSet );
387 delete newSpatialSet;
394 dtime = gettime()-dtime;
395 std::cout<< "Iter: " << iter <<" "<< dtime/1000 << " s" <<" GE: "<< globalEvolution << " numSamples: "<< classSet->size() <<std::endl;
400 template< class IndexType, class SpatialType, class PixelType, class ImageType >
402 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
406 IndexSampleSetType* newClassSet
407 = new IndexSampleSetType();
408 newClassSet->reserve ( indexSet->size() );
410 IndexSampleSetType* newWeightsSet
411 = new IndexSampleSetType();
412 newWeightsSet->reserve( indexSet->size() );
414 IndexSampleSetType* newIndexSet
415 = new IndexSampleSetType();
416 newIndexSet->reserve ( indexSet->size() );
418 SpatialSampleSetType* newSpatialSet
419 = new SpatialSampleSetType();
421 newSpatialSet->reserve( indexSet->size() );
423 RangeSampleSetType* newRangeSet
424 = new RangeSampleSetType();
425 newRangeSet->reserve ( indexSet->size() );
427 IndexSampleSetType* newClassSetMemory
428 = new IndexSampleSetType( *classSetMemory );
430 IndexSampleSetType* indexes
431 = new IndexSampleSetType( *classSet );
433 std::random_device rd;
434 std::mt19937 g(rd());
436 std::shuffle(indexes->begin(), indexes->end(), g);
439 newClassSet->push_back ( 1 );
440 newWeightsSet->push_back( weightsSet->at( indexes->at(0)-1 ) );
441 newIndexSet->push_back ( indexSet->at ( indexes->at(0)-1 ) );
442 newSpatialSet->push_back( spatialSet->at( indexes->at(0)-1 ) );
443 newRangeSet->push_back ( rangeSet->at ( indexes->at(0)-1 ) );
445 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
447 if(classSetMemory->at(l) == classSet->at(indexes->at(0)-1))
448 newClassSetMemory->at(l) = 1;
457 for(unsigned int m=1 ; m<indexes->size() ; ++m)
459 i = indexes->at(m)-1;
464 while( (k<newClassSet->size()) && newC )
466 VectorDistance( spDist, newSpatialSet->at(k), spatialSet->at(i) );
467 MergeInfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
468 if( (spDist<=1/mergeFactor)&&raNorm )
470 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
471 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
473 newWeightsSet->at(k) += weightsSet->at(i);
475 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
476 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
478 for(unsigned int l=0 ; l<classSetMemory->size() ; ++l)
480 if(classSetMemory->at(l) == classSet->at(i))
481 newClassSetMemory->at(l) = newClassSet->at(k);
492 newClassSet->push_back( newClassSet->back()+1 );
493 newWeightsSet->push_back( weightsSet->at(i) );
494 newIndexSet->push_back ( indexSet->at(i) );
495 newSpatialSet->push_back( spatialSet->at(i) );
496 newRangeSet->push_back ( rangeSet->at(i) );
498 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
500 if(classSetMemory->at(l) == classSet->at(i))
501 newClassSetMemory->at(l) = newClassSet->back();
506 classSet->swap ( *newClassSet );
507 weightsSet->swap( *newWeightsSet );
508 indexSet->swap ( *newIndexSet );
509 spatialSet->swap( *newSpatialSet );
510 rangeSet->swap ( *newRangeSet );
511 classSetMemory->swap ( *newClassSetMemory );
514 delete newWeightsSet;
516 delete newSpatialSet;
518 delete newClassSetMemory;
523 template< class IndexType, class SpatialType, class PixelType, class ImageType >
525 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
528 unsigned int size = std::numeric_limits<unsigned int>::max() - 1; // INFINITY;
529 std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+STMS_NUMBERING_FORM_ONE+expDescription->imageExtension;
531 while(size > classSet->size()){
532 IndexSampleSetType* newClassSet
533 = new IndexSampleSetType();
534 newClassSet->reserve ( indexSet->size() );
536 IndexSampleSetType* newWeightsSet
537 = new IndexSampleSetType();
538 newWeightsSet->reserve( indexSet->size() );
540 IndexSampleSetType* newIndexSet
541 = new IndexSampleSetType();
542 newIndexSet->reserve ( indexSet->size() );
544 SpatialSampleSetType* newSpatialSet
545 = new SpatialSampleSetType();
547 newSpatialSet->reserve( indexSet->size() );
549 RangeSampleSetType* newRangeSet
550 = new RangeSampleSetType();
551 newRangeSet->reserve ( indexSet->size() );
553 IndexSampleSetType* newClassSetMemory
554 = new IndexSampleSetType( *classSetMemory );
556 newClassSet->push_back ( 1 );
557 newWeightsSet->push_back( 1 );
558 newIndexSet->push_back ( indexSet->at(0) );
559 newSpatialSet->push_back( spatialSet->at(0) );
560 newRangeSet->push_back ( rangeSet->at(0) );
566 for(unsigned int i=1 ; i<classSet->size() ; ++i)
571 while( (k<newClassSet->size()) && newC )
573 InfiniteNorm( raNorm, newRangeSet->at(k), rangeSet->at(i) );
576 ReaderPointer reader = ReaderType::New();
577 ImagePointer image = ImageType::New();
579 reader->SetFileName( imagePath );
581 image = reader->GetOutput();
582 image->FillBuffer( 0 );
584 ImageIndexSetType* refClass = new ImageIndexSetType();
585 ImageIndexSetType* candClass = new ImageIndexSetType();
586 refClass->reserve( classSet->size()/2 );
587 candClass->reserve( classSet->size()/2 );
590 for(unsigned int m=0 ; m<newClassSetMemory->size() ; ++m)
593 if(newClassSetMemory->at(m) == classSet->at(i)){
596 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
597 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
599 candClass->push_back( idx );
600 image->SetPixel(candClass->back(), 1);
604 if(newClassSetMemory->at(m) == newClassSet->at(k)){
607 for(unsigned int n=0 ; n<stmsParams->dim ; ++n)
608 idx[n] = spatialSetMemory->at(m)[n]*stmsParams->spScales[n];
610 refClass->push_back( idx );
611 image->SetPixel(refClass->back(), 2);
617 if(stmsParams->dim == 2)
619 if(refClass->size() < candClass->size())
623 while((m<refClass->size()) && !connex)
625 for(int x=-1 ; x<=1 ; ++x)
627 for(int y=-1 ; y<=1 ; ++y)
629 idx[0] = refClass->at(m)[0]+x;
630 idx[1] = refClass->at(m)[1]+y;
632 if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && (idx[0]>0)
633 && (idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && (idx[1]>0) )
635 if(image->GetPixel(idx) == 2)
652 while((m<candClass->size()) && !connex)
654 for(int x=-1 ; x<=1 ; ++x)
656 for(int y=-1 ; y<=1 ; ++y)
658 idx[0] = candClass->at(m)[0]+x;
659 idx[1] = candClass->at(m)[1]+y;
661 if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 )
662 && ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) )
664 if(image->GetPixel(idx) == 1)
681 if(refClass->size() < candClass->size())
685 while((m<refClass->size()) && !connex)
687 for(int x=-1 ; x<=1 ; ++x)
689 for(int y=-1 ; y<=1 ; ++y)
691 for(int z=-1 ; z<=1 ; ++z)
693 idx[0] = refClass->at(m)[0]+x;
694 idx[1] = refClass->at(m)[1]+y;
695 idx[2] = refClass->at(m)[2]+z;
697 if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && (idx[0] > 0) &&
698 ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && (idx[1] > 0) &&
699 ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && (idx[2] > 0) )
701 if(image->GetPixel(idx) == 2)
720 while((m<candClass->size()) && !connex)
722 for(int x=-1 ; x<=1 ; ++x)
724 for(int y=-1 ; y<=1 ; ++y)
726 for(int z=-1 ; z<=1 ; ++z)
728 idx[0] = candClass->at(m)[0]+x;
729 idx[1] = candClass->at(m)[1]+y;
730 idx[2] = candClass->at(m)[2]+z;
732 if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 ) &&
733 ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) &&
734 ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && ( idx[2] > 0 ) )
736 if(image->GetPixel(idx) == 1)
756 VectorWeightedAcc( newSpatialSet->at(k), newWeightsSet->at(k), spatialSet->at(i), weightsSet->at(i) );
757 VectorWeightedAcc( newRangeSet->at(k) , newWeightsSet->at(k), rangeSet->at(i) , weightsSet->at(i) );
759 newWeightsSet->at(k) += weightsSet->at(i);
761 VectorDiv(newSpatialSet->at(k), newWeightsSet->at(k));
762 VectorDiv(newRangeSet->at(k), newWeightsSet->at(k));
764 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
767 if(classSetMemory->at(l) == classSet->at(i))
768 newClassSetMemory->at(l) = newClassSet->at(k);
785 newClassSet->push_back( newClassSet->back()+1 );
786 newWeightsSet->push_back( weightsSet->at(i) );
787 newIndexSet->push_back ( indexSet->at(i) );
788 newSpatialSet->push_back( spatialSet->at(i) );
789 newRangeSet->push_back ( rangeSet->at(i) );
791 for(unsigned int l=0 ; l< classSetMemory->size() ; ++l)
793 if(classSetMemory->at(l) == classSet->at(i))
794 newClassSetMemory->at(l) = newClassSet->back();
799 size = classSet->size();
801 classSet->swap ( *newClassSet );
802 weightsSet->swap( *newWeightsSet );
803 indexSet->swap ( *newIndexSet );
804 spatialSet->swap( *newSpatialSet );
805 rangeSet->swap ( *newRangeSet );
806 classSetMemory->swap ( *newClassSetMemory );
809 delete newWeightsSet;
811 delete newSpatialSet;
813 delete newClassSetMemory;
819 template< class IndexType, class SpatialType, class PixelType, class ImageType >
822 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
823 ::VectorDistance(float &dist, std::vector<T> &a, std::vector<T> &b)
828 for(unsigned int i=0 ; i<a.size() ; ++i)
829 dist += ( a[i]-b[i] )*( a[i]-b[i] );
833 template < class IndexType, class SpatialType, class PixelType, class ImageType >
835 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
836 ::InfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
840 for(unsigned int i=0 ; i<a.size() ; ++i)
842 if(((a[i]-b[i])*(a[i]-b[i])) > 1)
851 template < class IndexType, class SpatialType, class PixelType, class ImageType >
853 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
854 ::MergeInfiniteNorm(bool &dist, RangeVectorType &a, RangeVectorType &b)
858 for(unsigned int i=0 ; i<a.size() ; ++i)
860 if(((a[i]-b[i])*(a[i]-b[i])) > (1/mergeFactor))
869 template< class IndexType, class SpatialType, class PixelType, class ImageType >
872 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
873 ::VectorAcc(std::vector<T> &a, std::vector<T> &b)
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, std::vector<T> &b, unsigned int &b_w)
887 for(unsigned int i=0 ; i<a.size() ; ++i)
891 template< class IndexType, class SpatialType, class PixelType, class ImageType >
894 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
895 ::VectorWeightedAcc(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
898 for(unsigned int i=0 ; i<a.size() ; ++i){
904 template< class IndexType, class SpatialType, class PixelType, class ImageType >
907 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
908 ::VectorWeightedMean(std::vector<T> &a, unsigned int &a_w, std::vector<T> &b, unsigned int &b_w)
911 for(unsigned int i=0 ; i<a.size() ; ++i)
912 a[i] = ( (a[i]*a_w )+(b[i]*b_w) )/( a_w+b_w );
918 template< class IndexType, class SpatialType, class PixelType, class ImageType >
921 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
922 ::VectorMul(std::vector<T> &a, unsigned int &coeff)
925 for(unsigned int i=0 ; i<a.size() ; ++i)
930 template< class IndexType, class SpatialType, class PixelType, class ImageType >
933 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
934 ::VectorDiv(std::vector<T> &a, unsigned int &coeff)
937 for(unsigned int i=0 ; i<a.size() ; ++i)
941 } // end of namespace itkSTMS
943 #endif // itkmsSTMS_BlurringSTMS_TXX