Exemple #1
0
        private static float CalculateVariance(ColorMoment[, , ,] moments, Box cube)
        {
            ColorMoment volume = Volume(cube, moments);

            return(volume.Variance());
        }
Exemple #2
0
        private static CubeCut Maximize(ColorMoment[, , ,] moments, Box cube, int direction, byte first, byte last, ColorMoment whole)
        {
            var  bottom   = Bottom(cube, direction, moments);
            var  result   = 0.0f;
            byte?cutPoint = null;

            for (var position = first; position < last; ++position)
            {
                var half = bottom + Top(cube, direction, position, moments);
                if (half.Weight == 0)
                {
                    continue;
                }

                var temp = half.WeightedDistance();

                half = whole - half;
                if (half.Weight != 0)
                {
                    temp += half.WeightedDistance();

                    if (temp > result)
                    {
                        result   = temp;
                        cutPoint = position;
                    }
                }
            }

            return(new CubeCut(cutPoint, result));
        }