Exemple #1
0
        public void Apply(WriteableBitmap image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            for (int i = 0; i < image.Pixels.Length; i++)
            {
                Color pixel = FilterHelper.GetColor(image.Pixels[i]);

                double greyValue = pixel.R * 0.299 + pixel.G * 0.587 + pixel.B * 0.114;

                double r = greyValue + 2 * Value;
                if (r > 255)
                {
                    r = 255;
                }

                double g = greyValue + Value;
                if (g > 255)
                {
                    g = 255;
                }

                double b = greyValue;

                pixel.R = (byte)(r);
                pixel.G = (byte)(g);
                pixel.B = (byte)(b);

                image.Pixels[i] = FilterHelper.GetInt32(pixel);
            }
        }
Exemple #2
0
        public void Apply(WriteableBitmap image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            // Helligkeitsanpassung erfolgt durch addieren des gewünschten Betrages
            for (int i = 0; i < image.Pixels.Length; i++)
            {
                Color pixel = FilterHelper.GetColor(image.Pixels[i]);

                double r = pixel.R + Value;
                if (r > 255)
                {
                    r = 255;
                }
                if (r < 0)
                {
                    r = 0;
                }

                double g = pixel.G + Value;
                if (g > 255)
                {
                    g = 255;
                }
                if (g < 0)
                {
                    g = 0;
                }

                double b = pixel.B + Value;
                if (b > 255)
                {
                    b = 255;
                }
                if (b < 0)
                {
                    b = 0;
                }

                pixel.R = (byte)(r);
                pixel.G = (byte)(g);
                pixel.B = (byte)(b);

                image.Pixels[i] = FilterHelper.GetInt32(pixel);
            }
        }
Exemple #3
0
        public void Apply(WriteableBitmap image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            // Jeder Pixel erhält den selben Wert in allen Farbkanälen
            // die ungleichmäßige Berücksichtigung der Kanäle bewirkt eine natürliche Farbwiedergabe
            for (int i = 0; i < image.Pixels.Length; i++)
            {
                Color pixel = FilterHelper.GetColor(image.Pixels[i]);
                pixel.R = (byte)(pixel.R * 0.299 + pixel.G * 0.587 + pixel.B * 0.114);
                pixel.G = pixel.R;
                pixel.B = pixel.R;

                image.Pixels[i] = FilterHelper.GetInt32(pixel);
            }
        }
Exemple #4
0
        public void Apply(WriteableBitmap image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            // Kontrast = ((100 + X) / 100)²
            double contrast = (100.0 + Value) / 100.0;

            contrast *= contrast;

            // Kontrastanpassung erfolgt auf dem Bereich [-1,1] und wird durch Multiplikation mit dem Faktor erreicht
            for (int i = 0; i < image.Pixels.Length; i++)
            {
                Color pixel = FilterHelper.GetColor(image.Pixels[i]);

                double r = pixel.R / 255.0;
                r -= 0.5;
                r *= contrast;
                r += 0.5;
                r *= 255;
                if (r > 255)
                {
                    r = 255;
                }
                if (r < 0)
                {
                    r = 0;
                }

                double g = pixel.G / 255.0;
                g -= 0.5;
                g *= contrast;
                g += 0.5;
                g *= 255;
                if (g > 255)
                {
                    g = 255;
                }
                if (g < 0)
                {
                    g = 0;
                }

                double b = pixel.B / 255.0;
                b -= 0.5;
                b *= contrast;
                b += 0.5;
                b *= 255;
                if (b > 255)
                {
                    b = 255;
                }
                if (b < 0)
                {
                    b = 0;
                }

                pixel.R = (byte)(r);
                pixel.G = (byte)(g);
                pixel.B = (byte)(b);

                image.Pixels[i] = FilterHelper.GetInt32(pixel);
            }
        }