21 #ifndef otbOutcoreFunctor_h
22 #define otbOutcoreFunctor_h
37 template<
class TInput,
class TOutput>
52 TOutput nb_non_zero_pixels;
53 nb_non_zero_pixels.SetSize(1);
54 nb_non_zero_pixels.Fill(0.);
56 for (
unsigned long pos = 0; pos < itA.Size(); ++pos)
58 pixel = itA.GetPixel(pos);
60 for (
unsigned long i = 0; i < pixel.Size(); ++i)
64 nb_non_zero_pixels[i]++;
68 for (
unsigned long i = 0; i < pixel.Size(); ++i)
70 if (nb_non_zero_pixels[i] !=0.)
72 meanA[i] /= nb_non_zero_pixels[i];
80 TOutput ratio=itA.GetCenterPixel();
81 ratio.SetSize(meanA.GetSize()+1);
83 for (
unsigned long i = 0; i < meanA.Size(); ++i)
85 if ((meanA[i]!=0.)&&(ratio[i]!=0.))
94 ratio[meanA.Size()]=int(ratio[0]>0.);
96 return static_cast<TOutput
>(ratio);