1
/// Copyright (c) 2009 Jeffrey Powers for Occipital Open Source.
2
/// Under the MIT License, details: License.txt.
4
namespace FluxJpeg.Core.Filtering
8
internal class LowpassResize : Filter
10
protected override void ApplyFilter()
12
// get source image size
13
int width = _sourceData[0].GetLength(0),
14
height = _sourceData[0].GetLength(1);
16
int channels = _sourceData.Length;
18
// Estimate a good filter size for the gaussian.
19
// Note that gaussian isn't an ideal bandpass filter
20
// so this is an experimentally determined quantity
21
double std = (width / _newWidth) * 0.50;
23
for(int i = 0; i < channels; i++)
25
GrayImage channel = new GrayImage(_sourceData[i]);
27
channel = Convolution.Instance.GaussianConv(channel, std);
29
_sourceData[i] = channel.ToByteArray2D();
32
// number of pixels to shift in the original image
33
double xStep = (double)width / _newWidth,
34
yStep = (double)height / _newHeight;
37
NNResize resizer = new NNResize();
39
_destinationData = resizer.Apply(_sourceData, _newWidth, _newHeight);