예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContinuousHistogram"/> class.
        /// </summary>
        /// 
        /// <param name="values">Values of the histogram.</param>
        /// <param name="range">Range of random values.</param>
        /// 
        /// <remarks>Values of the integer array are treated as total amount of hits on the
        /// corresponding subranges, which are calculated by splitting the specified range into
        /// required amount of consequent ranges (see <see cref="ContinuousHistogram"/> class
        /// description for more information).
        /// </remarks>
        /// 
        public ContinuousHistogram( int[] values, Range range )
        {
            this.values = values;
            this.range  = range;

            Update( );
        }
예제 #2
0
 public HSLFiltering( Range hue, RangeD saturation, RangeD luminance )
 {
     this.hue		= hue;
     this.saturation	= saturation;
     this.luminance	= luminance;
 }
예제 #3
0
        // Selection changed in channels combo
        private void channelCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            AForge.Math.Histogram h = null;
            Color	color = Color.White;
            Range	input = new Range(0, 255);
            Range	output = new Range(0, 255);
            int		index = channelCombo.SelectedIndex;

            if (!imgStat.IsGrayscale)
            {
                // RGB image
                histogram.Color = colors[index];

                switch (index)
                {
                    case 0:	// red
                        h		= imgStat.Red;
                        input	= inRed;
                        output	= outRed;
                        color	= Color.FromArgb(255, 0, 0);
                        break;
                    case 1:	// green
                        h		= imgStat.Green;
                        input	= inGreen;
                        output	= outGreen;
                        color	= Color.FromArgb(0, 255, 0);
                        break;
                    case 2:	// blue
                        h		= imgStat.Blue;
                        input	= inBlue;
                        output	= outBlue;
                        color	= Color.FromArgb(0, 0, 255);
                        break;
                }
            }
            else
            {
                // grayscale image
                histogram.Color = colors[3];
                h = imgStat.Gray;

                input	= inGreen;
                output	= outGreen;
            }
            histogram.Values = h.Values;

            inMinBox.Text = input.Min.ToString();
            inMaxBox.Text = input.Max.ToString();
            outMinBox.Text = output.Min.ToString();
            outMaxBox.Text = output.Max.ToString();

            // input slider
            inSlider.Color2		= color;
            inSlider.Min		= input.Min;
            inSlider.Max		= input.Max;
            // output slider
            outSlider.Color2	= color;
            outSlider.Min		= output.Min;
            outSlider.Max		= output.Max;
        }
예제 #4
0
 public ColorFiltering( Range red, Range green, Range blue )
 {
     this.red	= red;
     this.green	= green;
     this.blue	= blue;
 }
예제 #5
0
        // Perform frequency filtering
        public void FrequencyFilter( Range range )
        {
            if ( fmode )
            {
                int hw = width >> 1;
                int hh = height >> 1;
                int min = range.Min;
                int max = range.Max;

                // process all data
                for ( int i = 0; i < height; i++ )
                {
                    int y = i - hh;

                    for ( int j = 0; j < width; j++ )
                    {
                        int	x = j - hw;
                        int d = (int) Math.Sqrt( x * x + y * y );

                        if ( ( d > max ) || ( d < min ) )
                        {
                            data[i, j].Re = 0;
                            data[i, j].Im = 0;
                        }
                    }
                }
            }
        }
예제 #6
0
 public ChannelFiltering( Range red, Range green, Range blue )
 {
     Red		= red;
     Green	= green;
     Blue	= blue;
 }
예제 #7
0
 // Calculate map
 private void CalculateMap( Range range, byte fill, bool fillOutsideRange, byte[] map )
 {
     for (int i = 0; i < 256; i++)
     {
         if ( ( i >= range.Min ) && ( i <= range.Max ) )
         {
             map[i] = ( fillOutsideRange ) ? (byte) i : fill;
         }
         else
         {
             map[i] = ( fillOutsideRange ) ? fill : (byte) i;
         }
     }
 }
예제 #8
0
        // Calculate map
        private void CalculateMap( Range inRange, Range outRange, byte[] map )
        {
            double	k = 0, b = 0;

            if ( inRange.Max != inRange.Min )
            {
                k = (double)( outRange.Max - outRange.Min ) / (double)( inRange.Max - inRange.Min );
                b = (double)( outRange.Min ) - k * inRange.Min;
            }

            for ( int i = 0; i < 256; i++ )
            {
                byte v = (byte) i;

                if ( v >= inRange.Max )
                    v = (byte) outRange.Max;
                else if ( v <= inRange.Min )
                    v = (byte) outRange.Min;
                else
                    v = (byte) ( k * v + b );

                map[i] = v;
            }
        }