Example #1
0
        private int[] HistogrammeDuCanal(Canal_e Canal)
        {
            int[] pixels_map = new int[Width * Height];

            Verrouiller();

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Color P = GetPixel(x, y);

                    Double Val = 0;

                    switch (Canal)
                    {
                        case Canal_e.Rouge:
                            Val = P.R;
                            break;
                        case Canal_e.Vert:
                            Val = P.G;
                            break;
                        case Canal_e.Bleu:
                            Val = P.B;
                            break;
                        case Canal_e.Alpha:
                            Val = P.A;
                            break;
                        case Canal_e.Teinte:
                            Val = (P.GetHue() * _PlageCouleur) / 360;
                            break;
                        case Canal_e.Saturation:
                            Val = P.GetSaturation() * _PlageCouleur;
                            break;
                        case Canal_e.Luminosite:
                            Val = P.GetBrightness() * _PlageCouleur;
                            break;
                        default:
                            Val = 0;
                            break;
                    }
                    pixels_map[x + Width * y] = Convert.ToInt32(Val);
                }
            }

            Liberer();

            int pLg = pixels_map.Length;
            int[] pHistogram = new int[_PlageCouleur + 1];

            for (int i = 0; i < pLg; i++)
            {
                int pPixel = pixels_map[i];
                pHistogram[pPixel]++;
            }

            return pHistogram;
        }
Example #2
0
        public int[] Histogramme(Canal_e Canal)
        {
            int[] pHistogramme = new int[_PlageCouleur + 1];

            if (Canal.HasFlag(Canal_e.Rouge))
            {
                if (_HistRouge == null)
                    _HistRouge = HistogrammeDuCanal(Canal_e.Rouge);

                Add(ref pHistogramme, _HistRouge);
            }

            if (Canal.HasFlag(Canal_e.Vert))
            {
                if (_HistVert == null)
                    _HistVert = HistogrammeDuCanal(Canal_e.Vert);

                Add(ref pHistogramme, _HistVert);
            }

            if (Canal.HasFlag(Canal_e.Bleu))
            {
                if (_HistBleu == null)
                    _HistBleu = HistogrammeDuCanal(Canal_e.Bleu);

                Add(ref pHistogramme, _HistBleu);
            }

            if (Canal.HasFlag(Canal_e.Alpha))
            {
                if (_HistAlpha == null)
                    _HistAlpha = HistogrammeDuCanal(Canal_e.Alpha);

                Add(ref pHistogramme, _HistAlpha);
            }

            if (Canal.HasFlag(Canal_e.Teinte))
            {
                if (_HistTeinte == null)
                    _HistTeinte = HistogrammeDuCanal(Canal_e.Teinte);

                Add(ref pHistogramme, _HistTeinte);
            }

            if (Canal.HasFlag(Canal_e.Saturation))
            {
                if (_HistSaturation == null)
                    _HistSaturation = HistogrammeDuCanal(Canal_e.Saturation);

                Add(ref pHistogramme, _HistSaturation);
            }

            if (Canal.HasFlag(Canal_e.Luminosite))
            {
                if (_HistLuminosite == null)
                    _HistLuminosite = HistogrammeDuCanal(Canal_e.Luminosite);

                Add(ref pHistogramme, _HistLuminosite);
            }

            return pHistogramme;
        }