Filter an image and/or resize with interpolation.


Compute frequency response of a 1-D filter.


Filter and resize a single 3-D numpy.ndarray.

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

Bases: pyctools.core.base.Transformer

Filter an image and/or resize with interpolation.

Resize (or just filter) an image using user supplied filter(s). The filters are supplied in a Frame object sent to the filter input. If the frame data’s 3rd dimension is unity then the same filter is applied to each component of the input. Alternatively the frame data’s 3rd dimension should match the input’s, allowing a different filter to be applied to each colour.

Images can be resized by almost any amount. The resizing is controlled by integer “up” and “down” factors and is not constrained to simple ratios such as 2:1 or 5:4.

To filter images without resizing leave the “up” and “down” factors at their default value of 1.

The core method resize_frame is written in Cython, allowing real-time image resizing on a typical computer.

The filter output forwards the filter frame whenever it changes. It can be connected to a FilterResponse component to compute the (new) frequency response.




Horizontal up-conversion factor.



Horizontal down-conversion factor.



Vertical up-conversion factor.



Vertical down-conversion factor.

inputs = ['input', 'filter']
outputs = ['output', 'filter']
class FilterResponse(config={}, **kwds)[source]

Bases: pyctools.core.base.Transformer

Compute frequency response of a 1-D filter.

The filter is padded to a power of 2 (e.g. 1024) before computing the Fourier transform. The magnitude of the positive frequency half is output in a form suitable for the PlotData component.

inputs = ['filter']
outputs = ['response']

Filter and resize a single 3-D numpy.ndarray.

This is the core of the Resize component but can also be used by other components (such as YUVtoRGB) that need high speed image filtering or interpolation.

The filter should be “normalised” so that the coefficients in each phase sum to unity. This is typically done by multiplying the filter coefficients by the horizontal and vertical up-conversion factors.

  • in_frame (numpy.ndarray) – Input image.

  • norm_filter (numpy.ndarray) – Normalised filter.

  • x_up (int) – Horizontal up-conversion factor.

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

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

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


A numpy.ndarray object containing the new image.

Comments or questions? Please email