components.interp.resize¶
Filter an image and/or resize with interpolation. 

Compute frequency response of a 1D filter. 

Filter and resize a single 3D 
 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 thefilter
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 realtime image resizing on a typical computer.The
filter
output forwards the filter frame whenever it changes. It can be connected to aFilterResponse
component to compute the (new) frequency response.Config:
xup
int
Horizontal upconversion factor.
xdown
int
Horizontal downconversion factor.
yup
int
Vertical upconversion factor.
ydown
int
Vertical downconversion factor.
 inputs = ['input', 'filter']¶
 outputs = ['output', 'filter']¶
 class FilterResponse(config={}, **kwds)[source]¶
Bases:
pyctools.core.base.Transformer
Compute frequency response of a 1D 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']¶
 resize_frame()¶
Filter and resize a single 3D
numpy.ndarray
.This is the core of the
Resize
component but can also be used by other components (such asYUVtoRGB
) 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 upconversion factors.
 Parameters
in_frame (numpy.ndarray) – Input image.
norm_filter (numpy.ndarray) – Normalised filter.
x_up (int) – Horizontal upconversion factor.
x_down (int) – Horizontal downconversion factor.
y_up (int) – Vertical upconversion factor.
y_down (int) – Vertical downconversion factor.
 Returns
A
numpy.ndarray
object containing the new image.
Comments or questions? Please email jim@jimeasterbrook.me.uk.