Exemple #1
0
        public int[] Process(int[] data, int width, int height)
        {
            var tumorPixelData = _tumor.GetTumorAsBitsTable();

            var random = new Random();
            var x      = random.Next(0, width - _tumor.Width);
            var y      = random.Next(0, height - _tumor.Height);

            var tumorColor = -(65536 * _tumor.Color + 256 * _tumor.Color + _tumor.Color);

            var tumorHeight = 0;

            for (var h = y; h < y + _tumor.Height; h++)
            {
                var tumorWidth = 0;
                for (var w = x; w < x + _tumor.Width; w++)
                {
                    if (tumorPixelData[tumorHeight * _tumor.Width + tumorWidth] == tumorColor)
                    {
                        data[h * width + w] = tumorColor;
                    }
                    tumorWidth++;
                }
                tumorHeight++;
            }

            return(data);
        }
        public int[] Process(int[] data, int width, int height)
        {
            var tumorPixelData           = _tumor.GetTumorAsBitsTable();
            var potentialPointsPixelData = _potentialPoints;

            var x = 0;
            var y = 0;

            // populate lists
            var xList  = Enumerable.Range(0, width - _tumor.Width).ToList();
            var yList  = Enumerable.Range(0, height - _tumor.Height).ToList();
            var random = new Random();

            do
            {
                xList.Remove(x);
                yList.Remove(y);

                var randomXIndex = random.Next(xList.Count);
                var randomYIndex = random.Next(yList.Count);

                x = xList[randomXIndex];
                y = yList[randomYIndex];
            } while (potentialPointsPixelData[y * width + x] == 0 && xList.Count > 1 && yList.Count > 1);

            var tumorColor = -(65536 * _tumor.Color + 256 * _tumor.Color + _tumor.Color);

            var tumorHeight = 0;

            for (var h = y; h < y + _tumor.Height; h++)
            {
                var tumorWidth = 0;
                for (var w = x; w < x + _tumor.Width; w++)
                {
                    if (tumorPixelData[tumorHeight * _tumor.Width + tumorWidth] == tumorColor)
                    {
                        data[h * width + w] = tumorColor;
                    }
                    tumorWidth++;
                }
                tumorHeight++;
            }

            return(data);
        }
        private static int CountPixelsForTumor(Tumor tumor)
        {
            var pixelCounter   = 0;
            var tumorPixelData = tumor.GetTumorAsBitsTable();

            for (var h = 0; h < tumor.Height; h++)
            {
                for (var w = 0; w < tumor.Width; w++)
                {
                    if (tumorPixelData[h * tumor.Width + w] == tumor.ComputedColor)
                    {
                        pixelCounter++;
                    }
                }
            }

            return(pixelCounter);
        }