Beispiel #1
0
 public Constant(ColorBgra setColor)
 {
     this.setColor = setColor;
 }
Beispiel #2
0
 public override ColorBgra Apply(ColorBgra color)
 {
     return(setColor);
 }
Beispiel #3
0
            public Level(ColorBgra in_lo, ColorBgra in_hi, float[] gamma, ColorBgra out_lo, ColorBgra out_hi)
            {
                colorInLow   = in_lo;
                colorInHigh  = in_hi;
                colorOutLow  = out_lo;
                colorOutHigh = out_hi;

                if (gamma.Length != 3)
                {
                    throw new ArgumentException("gamma", "gamma must be a float[3]");
                }

                this.gamma = gamma;
                UpdateLookupTable();
            }
Beispiel #4
0
            public override ColorBgra Apply(ColorBgra color)
            {
                byte i = color.GetIntensityByte();

                return(ColorBgra.FromBgra(i, i, i, color.A));
            }
Beispiel #5
0
 public override ColorBgra Apply(ColorBgra color)
 {
     return(ColorBgra.FromBgra(CurveB[color.B], CurveG[color.G], CurveR[color.R], color.A));
 }
Beispiel #6
0
 public override ColorBgra Apply(ColorBgra color)
 {
     return(ColorBgra.FromBgra((byte)(255 - color.B), (byte)(255 - color.G), (byte)(255 - color.R), (byte)(255 - color.A)));
 }
Beispiel #7
0
            public override ColorBgra Apply(ColorBgra color)
            {
                byte average = (byte)(((int)color.R + (int)color.G + (int)color.B) / 3);

                return(ColorBgra.FromBgra(average, average, average, color.A));
            }
Beispiel #8
0
 public override ColorBgra Apply(ColorBgra color)
 {
     return(ColorBgra.FromUInt32((color.Bgra & 0x00ffffff) + addValue));
 }
Beispiel #9
0
 public override ColorBgra Apply(ColorBgra color)
 {
     return(ColorBgra.FromUInt32(color.Bgra | 0xff000000));
 }
Beispiel #10
0
 public override ColorBgra Apply(ColorBgra color)
 {
     color[channel] = setValue;
     return(color);
 }
Beispiel #11
0
 public BlendConstant(ColorBgra blendColor)
 {
     this.blendColor = blendColor;
 }
Beispiel #12
0
        public void SetFromLeveledHistogram(HistogramRgb inputHistogram, UnaryPixelOps.Level upo)
        {
            if (inputHistogram == null || upo == null)
            {
                return;
            }

            Clear();

            float[] before = new float[3];
            float[] slopes = new float[3];

            for (int c = 0; c < 3; c++)
            {
                long[] channelHistogramOutput = histogram[c];
                long[] channelHistogramInput  = inputHistogram.histogram[c];

                for (int v = 0; v <= 255; v++)
                {
                    ColorBgra after = ColorBgra.FromBgr((byte)v, (byte)v, (byte)v);

                    upo.UnApply(after, before, slopes);

                    if (after[c] > upo.ColorOutHigh[c] ||
                        after[c] < upo.ColorOutLow[c] ||
                        (int)Math.Floor(before[c]) < 0 ||
                        (int)Math.Ceiling(before[c]) > 255 ||
                        float.IsNaN(before[c]))
                    {
                        channelHistogramOutput[v] = 0;
                    }
                    else if (before[c] <= upo.ColorInLow[c])
                    {
                        channelHistogramOutput[v] = 0;

                        for (int i = 0; i <= upo.ColorInLow[c]; i++)
                        {
                            channelHistogramOutput[v] += channelHistogramInput[i];
                        }
                    }
                    else if (before[c] >= upo.ColorInHigh[c])
                    {
                        channelHistogramOutput[v] = 0;

                        for (int i = upo.ColorInHigh[c]; i < 256; i++)
                        {
                            channelHistogramOutput[v] += channelHistogramInput[i];
                        }
                    }
                    else
                    {
                        channelHistogramOutput[v] = (int)(slopes[c] * PixelUtils.Lerp(
                                                              channelHistogramInput[(int)Math.Floor(before[c])],
                                                              channelHistogramInput[(int)Math.Ceiling(before[c])],
                                                              before[c] - Math.Floor(before[c])));
                    }
                }
            }

            OnHistogramUpdated();
        }
Beispiel #13
0
        public override ColorBgra GetPercentileColor(float fraction)
        {
            int[] perc = GetPercentile(fraction);

            return(ColorBgra.FromBgr((byte)(perc[0]), (byte)(perc[1]), (byte)(perc[2])));
        }
Beispiel #14
0
 public override ColorBgra GetMeanColor()
 {
     float[] mean = GetMean();
     return(ColorBgra.FromBgr((byte)(mean[0] + 0.5f), (byte)(mean[1] + 0.5f), (byte)(mean[2] + 0.5f)));
 }