components.interp.filtergenerator

class FilterGenerator(config={}, **kwds)[source]

Bases: Component

Classic filter generator component.

Create a filter from a Hamming windowed sinc function. The cut frequency is set to the “Nyquist limit” (half the sampling frequency) of the input or output sampling frequency, whichever is the lower. This cut frequency can be adjusted with the xcut and ycut configuration.

Connecting a FilterGenerator component’s output to a Resize component’s filter input allows the filter to be updated (while the components are running) by changing the FilterGenerator config:

filgen = FilterGenerator(xup=2, xaperture=16)
resize = Resize(xup=2)
filgen.connect('output', resize.filter)
...
start(..., filgen, resize, ...)
...
filgen.set_config({'xaperture': 8})
...

If you don’t need to change the configuration after creating the Resize component then it’s simpler to use a FilterGeneratorCore to create a fixed filter.

2-dimensional filters can be produced by setting both xaperture and yaperture, but it is usually more efficient to use two Resize components to process the two dimensions independently.

Config:

xup

int

Horizontal up-conversion factor.

xdown

int

Horizontal down-conversion factor.

xaperture

int

Horizontal filter aperture.

xcut

int

Adjust horizontal cut frequency. Default is 100%.

yup

int

Vertical up-conversion factor.

ydown

int

Vertical down-conversion factor.

yaperture

int

Vertical filter aperture.

ycut

int

Adjust vertical cut frequency. Default is 100%.

classmethod core(x_up=1, x_down=1, x_ap=1, x_cut=100, y_up=1, y_down=1, y_ap=1, y_cut=100)[source]

Classic filter generator core.

Alternative to the FilterGenerator component that can be used to make a non-reconfigurable resizer:

resize = Resize(xup=2)
resize.filter(FilterGenerator.core(xup=2, xaperture=16))
...
start(..., resize, ...)
...
Parameters:
  • x_up (int) – Horizontal up-conversion factor.

  • x_down (int) – Horizontal down-conversion factor.

  • x_ap (int) – Horizontal filter aperture.

  • x_cut (int) – Horizontal cut frequency adjustment.

  • y_up (int) – Vertical up-conversion factor.

  • y_down (int) – Vertical down-conversion factor.

  • y_ap (int) – Vertical filter aperture.

  • y_cut (int) – Vertical cut frequency adjustment.

Returns:

A Frame object containing the filter.


Comments or questions? Please email jim@jim-easterbrook.me.uk.