Is there a filtering algorithm that converges at some shape? My problem is that I am filtering a two dimensional graph, and applying filtering repeatedly. I'm down-sampling data and re-sampling it using gaussian filters (footprints), but the graph changes its shape with every subsequent filtering. What I need is to achieve some final shape, so that after enough filtering, the graph will no longer change shape.
是否有一种收敛于某种形状的滤波算法?我的问题是我正在过滤二维图,并重复应用过滤。我正在对数据进行下采样并使用高斯滤波器(足迹)对其进行重新采样,但是图形会随着每次后续滤波而改变其形状。我需要的是获得一些最终形状,以便在经过充分过滤后,图形将不再改变形状。
EDIT: by filtering I mean smoothing out, not dropping some information.
编辑:通过过滤我的意思是平滑,而不是删除一些信息。
3 个解决方案
#1
The simple answer is no. Mathematically filtering with a Gaussian means that you're convolving your data with a Gaussian. But convolving is the same as multiplying in the Fourier domain, so repeated application of the filter is like repeated multiplications in the Fourier domain, and here you can see that things will either blow up or go to zero. There might be something else that's also validly called filtering that doesn't do this, and you might be able make or dig something up that will do what you want, but repeated convolutions with the same kernel, Gaussian or otherwise, will not converge.
简单回答是不。使用高斯进行数学滤波意味着您使用高斯卷积数据。但是,卷积与傅里叶域中的乘法相同,因此重复应用滤波器就像傅立叶域中的重复乘法一样,在这里你可以看到事情会爆炸或变为零。可能还有一些其他东西也被称为过滤而不能做到这一点,并且你可能能够制造或挖掘一些可以做你想要的东西,但是使用相同内核(高斯或其他)的重复卷积将不会收敛。
#2
Found a pretty good hack to this problem. I'm not repeatedly re-filtering the data, but re-assigning weights-values to individual values of the 2d graph. This weight-value tells me how much filtering should be applied to corresponding graph locations. This weight-value also tells us the width of the gaussian filter (the range the value affects). Here's the code that needs to be executed every time graph values change.
找到了一个很好的黑客来解决这个问题。我没有重复过滤数据,而是将权重值重新分配给2d图的各个值。这个权重值告诉我应该对相应的图形位置应用多少过滤。该权重值还告诉我们高斯滤波器的宽度(值影响的范围)。这是每次图值更改时需要执行的代码。
vector<float> graph_values(100);
vector<float> graph_weights(100);
vector<float> graph_filtered_values(100);
// temp
vector<float> accumulated_weights(graph_values.size());
for(int x1=0;x1<graph_values.size();x1++)
{
graph_filtered_values[x1] = 0;
for(int x2=x1-30;x2<=x1+30;x2++)
{
float w = expf(-.5*(float)(x2-x1)*(x2-x1)/(graph_weights[x2]*graph_weights[x2]));
if( x2==x1&&!_finite(w) )
w = 1;
if( w<0.0001 )
w = 0;
graph_filtered_values[x1] += graph_values[x2] * w;
accumulated_weights[x1] += w;
}
}
for(int x1=0;x1<graph_values.size();x1++)
{
graph_filtered_values[x1] /= accumulated_weights[x1];
}
This algorithm uses triple the amount of memory: for graph_values, graph_weights and graph_filtered_values. This can be optimized by dropping first two arrays in the end product, when graph values no longer change.
该算法使用三倍的内存:对于graph_values,graph_weights和graph_filtered_values。当图表值不再变化时,可以通过在最终产品中删除前两个数组来优化这一点。
#3
You might want to try a median filter.
您可能想尝试中值滤波器。
The median filter is a special case of nonlinear filters used for smoothing signals. Since the output of the median filter is always one of the input samples, it is conceivable that certain signals could pass through the median filter unaltered. These signals define the signature of a filter and are referred to as root signals. Median filters are known to possess the convergence property, meaning that by repeating median filtering a root signal will be found, starting from any input signal.
(Burian Adrian, Kuosmanen Pauli: Tuning the smoothness of the recursive median filter, IEEE Transactions on Signal Processing 50(7), pp. 1631-1639, 2002)中值滤波器是用于平滑信号的非线性滤波器的特例。由于中值滤波器的输出始终是输入样本之一,因此可以想象某些信号可以不改变地通过中值滤波器。这些信号定义了滤波器的特征,并称为根信号。已知中值滤波器具有收敛特性,这意味着通过重复中值滤波,将从任何输入信号开始找到根信号。 (Burian Adrian,Kuosmanen Pauli:调整递归中值滤波器的平滑度,IEEE Transactions on Signal Processing 50(7),pp.1631-1639,2002)
#1
The simple answer is no. Mathematically filtering with a Gaussian means that you're convolving your data with a Gaussian. But convolving is the same as multiplying in the Fourier domain, so repeated application of the filter is like repeated multiplications in the Fourier domain, and here you can see that things will either blow up or go to zero. There might be something else that's also validly called filtering that doesn't do this, and you might be able make or dig something up that will do what you want, but repeated convolutions with the same kernel, Gaussian or otherwise, will not converge.
简单回答是不。使用高斯进行数学滤波意味着您使用高斯卷积数据。但是,卷积与傅里叶域中的乘法相同,因此重复应用滤波器就像傅立叶域中的重复乘法一样,在这里你可以看到事情会爆炸或变为零。可能还有一些其他东西也被称为过滤而不能做到这一点,并且你可能能够制造或挖掘一些可以做你想要的东西,但是使用相同内核(高斯或其他)的重复卷积将不会收敛。
#2
Found a pretty good hack to this problem. I'm not repeatedly re-filtering the data, but re-assigning weights-values to individual values of the 2d graph. This weight-value tells me how much filtering should be applied to corresponding graph locations. This weight-value also tells us the width of the gaussian filter (the range the value affects). Here's the code that needs to be executed every time graph values change.
找到了一个很好的黑客来解决这个问题。我没有重复过滤数据,而是将权重值重新分配给2d图的各个值。这个权重值告诉我应该对相应的图形位置应用多少过滤。该权重值还告诉我们高斯滤波器的宽度(值影响的范围)。这是每次图值更改时需要执行的代码。
vector<float> graph_values(100);
vector<float> graph_weights(100);
vector<float> graph_filtered_values(100);
// temp
vector<float> accumulated_weights(graph_values.size());
for(int x1=0;x1<graph_values.size();x1++)
{
graph_filtered_values[x1] = 0;
for(int x2=x1-30;x2<=x1+30;x2++)
{
float w = expf(-.5*(float)(x2-x1)*(x2-x1)/(graph_weights[x2]*graph_weights[x2]));
if( x2==x1&&!_finite(w) )
w = 1;
if( w<0.0001 )
w = 0;
graph_filtered_values[x1] += graph_values[x2] * w;
accumulated_weights[x1] += w;
}
}
for(int x1=0;x1<graph_values.size();x1++)
{
graph_filtered_values[x1] /= accumulated_weights[x1];
}
This algorithm uses triple the amount of memory: for graph_values, graph_weights and graph_filtered_values. This can be optimized by dropping first two arrays in the end product, when graph values no longer change.
该算法使用三倍的内存:对于graph_values,graph_weights和graph_filtered_values。当图表值不再变化时,可以通过在最终产品中删除前两个数组来优化这一点。
#3
You might want to try a median filter.
您可能想尝试中值滤波器。
The median filter is a special case of nonlinear filters used for smoothing signals. Since the output of the median filter is always one of the input samples, it is conceivable that certain signals could pass through the median filter unaltered. These signals define the signature of a filter and are referred to as root signals. Median filters are known to possess the convergence property, meaning that by repeating median filtering a root signal will be found, starting from any input signal.
(Burian Adrian, Kuosmanen Pauli: Tuning the smoothness of the recursive median filter, IEEE Transactions on Signal Processing 50(7), pp. 1631-1639, 2002)中值滤波器是用于平滑信号的非线性滤波器的特例。由于中值滤波器的输出始终是输入样本之一,因此可以想象某些信号可以不改变地通过中值滤波器。这些信号定义了滤波器的特征,并称为根信号。已知中值滤波器具有收敛特性,这意味着通过重复中值滤波,将从任何输入信号开始找到根信号。 (Burian Adrian,Kuosmanen Pauli:调整递归中值滤波器的平滑度,IEEE Transactions on Signal Processing 50(7),pp.1631-1639,2002)