Skip to content

pixtreme.feature

feature

Image feature response operations.

__all__ = ('corner_harris', 'match_template') module-attribute

corner_harris(frame, *, block_size=3, k=0.04, border='mirror', border_value=None)

Return the color-structure Harris response of a float32 Frame.

The fixed non-normalized 3x3 Sobel pair is evaluated for all channels. Per-channel products are combined into one color tensor before a centered, non-normalized block_size box sum. The final expression is A * D - B**2 - k * (A + D)**2. At output (y, x) it measures the input pixel at (y, x). mirror is the default border; replicate, wrap, and constant are also accepted, and the same extended input plane defines both Sobel and box sum samples.

The result is a private 2D C-contiguous float32 cupy.ndarray. It has new storage and no Frame metadata. This operation does not mutate its input, does not clamp scene values, and neither adds nor preserves a channel dimension. Convert non-float32 storage according to its meaning with px.values.cast_dtype, px.values.recode_dtype, or px.values.dequantize. To use the response as an image, add a length-one channel dimension and call px.io.from_array with explicit metadata.

match_template(frame, template, *, method='ccoeff_normed')

Return a valid 2D template response map for two compatible float32 Frames.

Output (y, x) compares the template with the frame window whose top-left pixel is (y, x); no padding is used. Every metric combines all channels. sqdiff and sqdiff_normed are smaller-is-better; ccorr, ccorr_normed, ccoeff, and the default ccoeff_normed are larger-is-better. Coefficient means are computed per channel. The two Frames must have identical dtype, channels, colorspace, gamma, and matrix. A zero normalized denominator returns zero, except nonzero sqdiff_normed returns +inf.

The result is a private 2D C-contiguous float32 cupy.ndarray. It has new storage and no Frame metadata. This operation does not mutate either input, does not clamp scene values, and neither adds nor preserves a channel dimension. Convert non-float32 storage according to its meaning with px.values.cast_dtype, px.values.recode_dtype, or px.values.dequantize. To use a response as an image, add a length-one channel dimension and call px.io.from_array with explicit metadata.