kevin eccli
/
Freescale_CupV4
Adaptation K22F
Diff: Analyse.cpp
- Revision:
- 0:6004a7230f87
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Analyse.cpp Tue Dec 16 15:52:17 2014 +0000 @@ -0,0 +1,43 @@ +#include "Analyse.h" + +void seuil(unsigned short *v, bool *rslt, unsigned short seuil) +{ + for(int i= 0;i<128;i++){ + if(v[i]>seuil){ + rslt[i]=true; + }else{ + rslt[i]=false; + } + } +} + +//nbr doit etre impaire +void moyenneGlissante(unsigned short *v, int nbr, unsigned short *rslt) +{ + int i; + int j = (nbr - 1)/2; + + //Generation du premier terme + rslt[0] = (j+1)*v[0]; + for( i = 1 ; i <= j ;i++) { + rslt[0]+= v[j]; + } + + + //Generation des termes d'indice 1:j-1 + for(i = 1 ; i < j ; i++) { + rslt[i] = rslt[i-1] - v[0] + v[j + i]; + } + + //Generation des termes d'indice j:NBR_PIXEL-nbr-1 + + for(i = j; i < NBR_PIXEL-nbr; i++) { + rslt[i] = rslt[i-1] - v[i-j] + v[i+j]; + } + + //Generation des termes d'indice NBR_PIXEL-nbr : 127 + for(i = NBR_PIXEL-nbr; i < NBR_PIXEL-1; i++) { + rslt[i] = rslt[i-1] - v[i-j] + v[NBR_PIXEL-1]; + } + +} \ No newline at end of file