components.interp.resize
Filter an image and/or resize with interpolation. |
|
Compute frequency response of a 1-D filter. |
|
Filter and resize a single 3-D |
- class Resize(config={}, **kwds)[source]
Bases:
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 real-time 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 up-conversion factor.
xdown
int
Horizontal down-conversion factor.
yup
int
Vertical up-conversion factor.
ydown
int
Vertical down-conversion factor.
- inputs = ['input', 'filter']
- outputs = ['output', 'filter']
- class FilterResponse(config={}, **kwds)[source]
Bases:
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']
- resize_frame(in_frame, norm_filter, x_up, x_down, y_up, y_down)
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 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 up-conversion factors.
- Parameters:
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.
- Returns:
A
numpy.ndarray
object containing the new image.
Comments or questions? Please email jim@jim-easterbrook.me.uk.