SoFunction
Updated on 2024-11-13

Gaussian decay python implementation

Gaussian decay python implementation

def get_score_time_weight(original, offset,scale,current_data):
    diff = current_data-original
    if  (diff) < offset:
        return 1
    else:
        var_sqr = scale**2/(2*(2))
        return (,-((diff)-offset)**2/(2*var_sqr))

The effect is as follows:

The corresponding actual formula normal distribution probability density function removes theconstant term (math.)For:

Gaussian Filtering Study Notes

In image processing, Gaussian filtering is generally implemented in two ways, one by convolution with a discretized window sliding window, and the other by Fourier transform. The most common is the first kind of sliding window implementation, only when the discretization window is very large, with the sliding window computation is very large (i.e., the use of separable filter implementation), may consider the implementation of the Fourier transform-based approach.

principle

Most of the image noise belongs to Gaussian noise, so Gaussian filter is also widely used. Gaussian filter is a linear smoothing filter, suitable for eliminating Gaussian noise, widely used in image denoising.

It can be simply understood that Gaussian filter denoising is a weighted average of the pixel values of the whole image, for each pixel point the value is obtained by a weighted average of its own value and other pixel values in the neighborhood.

Gaussian filtering is done by scanning each pixel in the image with a user-specified template (or convolution, mask), and replacing the value of the pixel point at the center of the template with the weighted average gray value of the pixels in the neighborhood determined by the template.

One-dimensional Gaussian distribution:

Two-dimensional Gaussian distribution:

Gaussian Blur:

We often say that Gaussian blur is done using a Gaussian filter, Gaussian blur is a kind of low-pass filtering, that is, the filter function is a low-pass Gaussian function, but Gaussian filtering refers to the use of a Gaussian function as a filter function, as for whether it is blurred or not, depends on whether it is a Gaussian low-pass or Gaussian high-pass, the low-pass is a blur, and the high-pass is a sharpening.

A filter is a mathematical model that transforms the image data into energy, and excludes the low-energy ones; noise belongs to the low-energy part. The programming operation is a template operation, taking the eight connected areas of the image, the pixel value of the center point is equal to the average of the pixel values of the eight connected areas, so as to achieve the smoothing effect. If an ideal filter is used, it produces ringing in the image. If a Gaussian filter is used, the system function is smooth, avoiding the ringing phenomenon (image processing, filtering of an image, if the frequency domain filter selected has a steep change, the filtered image will produce "ringing", the so-called "ringing", that is, the gray scale of the output image is the same as the gray scale of the output image, the so-called "ringing". (The so-called "ringing" refers to the oscillation of the output image at the sharp change in gray scale, as if the bell was struck by the air vibration). .

The ideal filter is a filter that can make the amplitude and phase of the signal in the passband undistorted, and the frequency components in the stopband are attenuated to zero, and there is a clear demarcation line between the passband and the stopband. In other words, the ideal filter in the passband amplitude-frequency characteristics should be a constant, the slope of the phase frequency characteristics of a constant value; outside the passband amplitude-frequency characteristics should be zero.

Since the Fourier transform of a Gaussian function is still a Gaussian function, a Gaussian function can form a low-pass filter with smoothing properties in the frequency domain. Gaussian filtering can be realized by doing the product in the frequency domain. Mean filtering is a local averaging of the signal, with the mean value representing the gray value of the pixel. The Averaging Box Filter smoothes each component of the two-dimensional vector independently. Through calculation and transformation, a unit vector map is obtained. This 512 × 512 vector map is divided into a 8 × 8 small regions, and then in each small region, the main direction of the region, that is, the number of point directions in the region is counted, the most direction as the main direction of the region. A new 64×64 vector map is then obtained. This new vector map can be further smoothed using a 3×3 template.

summarize

The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.