Ejemplo n.º 1
0
        private void DrawDepthColorMatrix()
        {
            var minValue = GetMinValueFromBlockDistMat();
            var maxValue = GetMaxValueFromBlockDistMat();

            workImageBlockMatch.Lock();
            for (int i = 0; i < workImageBlockMatch.Width; i++)
            {
                for (int j = 0; j < workImageBlockMatch.Height; j++)
                {
                    var   colorValue = (blockDistMatrix[i, j] * WHITE_COLOR_VALUE) / maxValue;
                    Color color      = Color.FromArgb(colorValue, colorValue, colorValue);

                    if (blockDistMatrix[i, j] == minValue)
                    {
                        color = Color.White;
                    }
                    else if (blockDistMatrix[i, j] == maxValue)
                    {
                        color = Color.Black;
                    }

                    workImageBlockMatch.SetPixel(i, j, color);
                }
            }
            panelDestination.BackgroundImage = null;
            panelDestination.BackgroundImage = workImageBlockMatch.GetBitMap();
            workImageBlockMatch.Unlock();
        }
Ejemplo n.º 2
0
        private void TrackBarDelta_ValueChanged(object sender, EventArgs e)
        {
            var deltaValue = trackBarDelta.Value;

            workImage.Lock();
            initialWorkImage.Lock();

            for (var i = 0; i < workImage.Width; i++)
            {
                for (var j = 0; j < workImage.Height; j++)
                {
                    var color = initialWorkImage.GetPixel(i, j);

                    var redNew   = GetColorBasedOnDelta(color.R, deltaValue);
                    var greenNew = GetColorBasedOnDelta(color.G, deltaValue);
                    var blueNew  = GetColorBasedOnDelta(color.B, deltaValue);

                    color = Color.FromArgb(redNew, greenNew, blueNew);

                    workImage.SetPixel(i, j, color);
                }
            }

            UpdateWorkImage();

            workImage.Unlock();
            initialWorkImage.Unlock();
        }
Ejemplo n.º 3
0
        private void buttonGrayscale_Click(object sender, EventArgs e)
        {
            Color color;

            workImage.Lock();
            for (int i = 0; i < workImage.Width; i++)
            {
                for (int j = 0; j < workImage.Height; j++)
                {
                    color = workImage.GetPixel(i, j);
                    byte R = color.R;
                    byte G = color.G;
                    byte B = color.B;

                    byte average = (byte)((R + G + B) / 3);

                    color = Color.FromArgb(average, average, average);

                    workImage.SetPixel(i, j, color);
                }
            }

            panelDestination.BackgroundImage = null;
            panelDestination.BackgroundImage = workImage.GetBitMap();
            workImage.Unlock();
        }