protected override void ApplyFilter()
        {
            // get source image size
            int width  = _sourceData[0].GetLength(0),
                height = _sourceData[0].GetLength(1);

            int channels = _sourceData.Length;

            // Estimate a good filter size for the gaussian.
            // Note that gaussian isn't an ideal bandpass filter
            //  so this is an experimentally determined quantity
            double std = (width / _newWidth) * 0.50;

            for (int i = 0; i < channels; i++)
            {
                GrayImage channel = new GrayImage(_sourceData[i]);

                channel = Convolution.Instance.GaussianConv(channel, std);

                _sourceData[i] = channel.ToByteArray2D();
            }

            // number of pixels to shift in the original image
            double xStep = (double)width / _newWidth,
                   yStep = (double)height / _newHeight;


            NNResize resizer = new NNResize();

            _destinationData = resizer.Apply(_sourceData, _newWidth, _newHeight);
        }
        protected override void ApplyFilter()
        {
            // get source image size
            int width = _sourceData[0].GetLength(0),
                height = _sourceData[0].GetLength(1);

            int channels = _sourceData.Length;

            // Estimate a good filter size for the gaussian.
            // Note that gaussian isn't an ideal bandpass filter
            //  so this is an experimentally determined quantity
            double std = (width / _newWidth) * 0.50;

            for(int i = 0; i < channels; i++)
            {
                GrayImage channel = new GrayImage(_sourceData[i]);

                channel = Convolution.Instance.GaussianConv(channel, std);

                _sourceData[i] = channel.ToByteArray2D();
            }

            // number of pixels to shift in the original image
            double xStep = (double)width / _newWidth,
                   yStep = (double)height / _newHeight;


            NNResize resizer = new NNResize();

             _destinationData = resizer.Apply(_sourceData, _newWidth, _newHeight);


        }
Пример #3
0
        public Image Resize(double scale, ResamplingFilters technique)
        {
            FluxJpeg.Core.Filtering.Filter filter;
            int newHeight = (int) (scale * this._input.Height);
            int newWidth = (int) (scale * this._input.Width);
            switch (technique)
            {
                case ResamplingFilters.NearestNeighbor:
                    filter = new NNResize();
                    break;

                case ResamplingFilters.LowpassAntiAlias:
                    filter = new LowpassResize();
                    break;

                default:
                    throw new NotSupportedException();
            }
            return new Image(this._input.ColorModel, filter.Apply(this._input.Raster, newWidth, newHeight));
        }
Пример #4
0
        public Image Resize(double scale, ResamplingFilters technique)
        {
            int height = (int)(scale * _input.Height);
            int width = (int)(scale * _input.Width);

            Filter resizeFilter;

            switch (technique)
            {
                case ResamplingFilters.NearestNeighbor:
                    resizeFilter = new NNResize();
                    break;
                case ResamplingFilters.LowpassAntiAlias:
                    resizeFilter = new LowpassResize();
                    break;
                default:
                    throw new NotSupportedException();
            }

            return new Image(_input.ColorModel, resizeFilter.Apply(_input.Raster, width, height));
        }
Пример #5
0
 private Filter GetResizeFilter(ResamplingFilters technique)
 {
     Filter resizeFilter;
     switch (technique)
     {
         case ResamplingFilters.NearestNeighbor:
             resizeFilter = new NNResize();
             break;
         case ResamplingFilters.LowpassAntiAlias:
             resizeFilter = new LowpassResize();
             break;
         default:
             throw new NotSupportedException();
     }
     resizeFilter.ProgressChanged += ResizeProgressChanged;
     return resizeFilter;
 }