Пример #1
0
        private static void Sharpen(Vector4[] pixels)
        {
            float[] gaussianKernel = new float[]
            {
                0.011254f,
                0.016436f,
                0.023066f,
                0.031105f,
                0.040306f,
                0.050187f,
                0.060049f,
                0.069041f,
                0.076276f,
                0.080977f,
                0.082607f,
                0.080977f,
                0.076276f,
                0.069041f,
                0.060049f,
                0.050187f,
                0.040306f,
                0.031105f,
                0.023066f,
                0.016436f,
                0.011254f
            };
            int length = pixels.Length;

            Vector4[] edges = new Vector4[length];
            for (int i = length - 1; i != 0;)
            {
                edges[i] = VectorExtension.Abs(pixels[i] - pixels[--i]);
            }

            Vector4[] edgesBlured = new Vector4[length];
            for (int i = 0; i < length; ++i)
            {
                for (int j = -10; j < 11; ++j)
                {
                    if (i + j >= 0 && i + j < length)
                    {
                        edgesBlured[i] += edges[i + j] * gaussianKernel[j + 10];
                    }
                }
            }

            for (int i = 0; i < length; ++i)
            {
                pixels[i] -= edgesBlured[i] * 5.0f;
            }
        }
Пример #2
0
        private static Vector4 hueToRGB(float hue)
        {
            hue = hue - (float)Math.Floor(hue);
            float h6 = hue * 6;

            Vector4 ret = new Vector4(
                Math.Abs(3 - h6) - 1,
                2 - Math.Abs(2 - h6),
                2 - Math.Abs(4 - h6),
                0);

            VectorExtension.Clamp0_1(ref ret);
            return(ret);
        }
Пример #3
0
        public void Send()
        {
            int    index    = 0;
            ushort arg_2B_0 = (ushort)(this.whiteLeft * 65535f);
            ushort wr       = (ushort)(this.whiteRight * 65535f);

            dataBuffer[index] = 61;
            index++;
            BitConverter.GetBytes(arg_2B_0).CopyTo(dataBuffer, index);
            index += 2;
            BitConverter.GetBytes(wr).CopyTo(dataBuffer, index);
            index += 2;
            Vector4 multiplier = new Vector4(Settings.Default.RedMultiplier, Settings.Default.GreenMultiplier, Settings.Default.BlueMultiplier, 0f);

            multiplier *= 255f;
            Vector4 error = new Vector4();

            for (int i = 0; i < 120; i++)
            {
                Vector4 pixel = pixelsLeft[i];
                pixel *= multiplier;
                pixel += error;
                Vector4 value = VectorExtension.Round(pixel);
                VectorExtension.Clamp0_255(ref value);
                error = pixel - value;
                dataBuffer[index++] = (byte)value.X;
                dataBuffer[index++] = (byte)value.Y;
                dataBuffer[index++] = (byte)value.Z;
            }
            error = new Vector4();
            for (int i = 0; i < 120; i++)
            {
                Vector4 pixel = pixelsRight[i];
                pixel *= multiplier;
                pixel += error;
                Vector4 value = VectorExtension.Round(pixel);
                VectorExtension.Clamp0_255(ref value);
                error = pixel - value;
                dataBuffer[index++] = (byte)value.X;
                dataBuffer[index++] = (byte)value.Y;
                dataBuffer[index++] = (byte)value.Z;
            }
            Write(dataBuffer, 0, index);
        }