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); }
public override void ApplyFilter() { int length = _sourceData[0].GetLength(0); int num = _sourceData.Length; double std = (double)(length / _newWidth) * 0.5; for (int i = 0; i < num; i++) { GrayImage data = new GrayImage(_sourceData[i]); data = Convolution.Instance.GaussianConv(data, std); _sourceData[i] = data.ToByteArray2D(); } NNResize nNResize = new NNResize(); _destinationData = nNResize.Apply(_sourceData, _newWidth, _newHeight); }
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); }
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))); }
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))); }