示例#1
0
文件: MipRenderer.cs 项目: xa17d/vmd2
        protected override void OnRenderPixel(Image3D image, DisplayImage display, int x, int y)
        {
            double mipValue = double.MinValue;
            for (int z = image.LengthZ - 1; z >= 0; z--)
            {
                mipValue = Math.Max(mipValue, image[x, y, z]);
            }

            display.SetPixel(x, y, Window.GetColor(mipValue));
        }
示例#2
0
文件: DvrRenderer.cs 项目: xa17d/vmd2
        protected override void OnRenderPixel(Image3D image, DisplayImage display, int x, int y)
        {
            var voxelColor = Colors.Black;
            for (int z = image.LengthZ - 1; z >= 0; z--)
            {
                var color = tf.GetColor(image[x, y, z]);
                voxelColor = ColorHelper.BlendAlpha(color, voxelColor);
            }

            display.SetPixel(x, y, voxelColor);
        }
示例#3
0
 protected override void OnRenderPixel(Image3D image, DisplayImage display, int x, int y)
 {
     var voxel = image[x, y, 0];
     display.SetPixel(x, y, Window.GetColor(voxel));
 }
示例#4
0
文件: Histogram.cs 项目: xa17d/vmd2
        public void Render(DisplayImage display, TransferFunction1D tf)
        {
            // find max value
            int histogramMax = 0;
            int histogramMax2 = 0;
            int histogramSum = 0;
            for (int i = 0; i < histogramValues.Length; i++)
            {
                var v = histogramValues[i];
                if (v > histogramMax)
                {
                    histogramMax2 = histogramMax;
                    histogramMax = v;
                }

                if (v > histogramMax2 && v < histogramMax)
                {
                    histogramMax2 = v;
                }
                histogramSum += v;
            }

            int histogramHeight = histogramSum * 4 / Count; // TODO: find a suitable height function

            if (histogramHeight == 0) { histogramHeight = 1; } // avoid division by 0 error

            // draw histogram values
            int displayHeight = display.Height;
            int displayWidth = display.Width;

            double delta = (Maximum - Minimum) / Count;

            for (int x = 0; x < displayWidth; x++)
            {
                int histogramIndexStart = (x * Count) / (displayWidth);
                int histogramIndexEnd = ((x + 1) * Count) / (displayWidth);

                int sum = 0;
                for (int i = histogramIndexStart; i < histogramIndexEnd; i++)
                {
                    sum += histogramValues[i];
                }

                int barHeight = Math.Min(displayHeight, (sum * displayHeight) / histogramHeight);

                Color tfColor = tf.GetColor(Minimum + delta * x);
                for (int y = 0; y < 3; y++)
                {
                    display.SetPixel(x, y, tfColor);
                }
                for (int y = 3; y < (displayHeight - barHeight); y++)
                {
                    if (y >= display.Height) { break; }
                    display.SetPixel(x, y, Colors.Transparent);
                }
                for (int y = (displayHeight - barHeight); y < displayHeight; y++)
                {
                    if (y >= display.Height) { break; }
                    display.SetPixel(x, y, tfColor);
                }
            }
        }