Пример #1
0
        private int GetSideLength(Cube3 cube)
        {
            int rLength = cube.MaxR - cube.MinR;
            int gLength = cube.MaxG - cube.MinG;
            int bLength = cube.MaxB - cube.MinB;

            if (rLength >= gLength)
            {
                if (rLength >= bLength)
                {
                    return(rLength);
                }
                else
                {
                    return(bLength);
                }
            }
            else if (gLength >= bLength)
            {
                return(gLength);
            }
            else
            {
                return(bLength);
            }
        }
Пример #2
0
        private void Button3_Click(object sender, RoutedEventArgs e)
        {
            var sw = new Stopwatch();

            sw.Start();
            var neko = new Cube3(OriginPixels);

            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds.ToString());
        }
Пример #3
0
        //Cubeリストから選択、分割、選択Cubeをリストから削除、分割したCubeをリストに追加
        //最大辺の中間で分割
        private void Bunkatu(Cube3 cube, int count)
        {
            int rLength = MaxR - MinR;
            int gLength = MaxG - MinG;
            int bLength = MaxB - MinB;

            byte[] cPixels    = cube.Pixels;
            int    colorCount = 1;
            //中間は切り捨てで取得、判定は以下(より大きい)
            int mid;
            var lowList = new List <byte>();
            var HiList  = new List <byte>();

            if (rLength >= gLength)
            {
                if (rLength >= bLength)
                {
                    //aka
                    mid = MaxR - MinR;//中間は切り捨てで取得
                    for (int i = 0; i < cPixels.Length; i += 4)
                    {
                        if (cPixels[i + 2] > mid)
                        {
                            HiList.Add(cPixels[i]);
                            HiList.Add(cPixels[i + 1]);
                            HiList.Add(cPixels[i + 2]);
                            HiList.Add(cPixels[i + 3]);
                        }
                        else
                        {
                            lowList.Add(cPixels[i]);
                            lowList.Add(cPixels[i + 1]);
                            lowList.Add(cPixels[i + 2]);
                            lowList.Add(cPixels[i + 3]);
                        }
                    }
                }
                //分割できなかった場合
                if (HiList.Count == 0 && lowList.Count == 0)
                {
                }
                //分割できたら元のCubeをリストから削除、分割Cubeをリストに追加
                else
                {
                    Cubes.Remove(cube);
                    Cubes.Add(new Cube3(HiList.ToArray()));
                    Cubes.Add(new Cube3(lowList.ToArray()));
                    count++;
                    if (colorCount < count)
                    {
                        //次の分割
                    }
                }
            }
            else if (gLength >= bLength)
            {
            }
            else
            {
            }
        }