Qu

blur

Builtin index · Images

result = blur(img)

Input: img · Output: result

What it is

img is an Image of any size. Applies a fixed 3x3 box-average blur kernel.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = blur(img)
img Imagenot documented yet
result Image
Returns a new Image, the same dimensions as img.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

m = [10, 200, 10, 200, 10; 200, 10, 200, 10, 200; 10, 200, 10, 200, 10]
img = image_from_matrix(m)

soft = blur(img)
crisp = sharpen(img)
imshow(soft)
imshow(crisp)

kernel = [0, -1, 0; -1, 5, -1; 0, -1, 0]      # explicit unsharp kernel

custom = imfilter(img, kernel)
print(soft.width, crisp.width, custom.width)
output
5 5 5
a synthetic field with one bright patch

from images

How it works

blur(img) / sharpen(img) — the two required convolution filters (3x3 box-average blur, 3x3 unsharp-mask sharpen); see image::Image's doc comments for the exact kernels. edge_detect(img) — a bonus third (3x3 discrete Laplacian). imfilter(img, kernel) — the generic escape hatch: an arbitrary odd-sized square Matrix kernel, direct 2-D convolution with edge-clamped borders (see image::Image::convolve's doc comment for why this is a small from-scratch 2-D convolution rather than a forced reuse of qu_core::transforms::conv, which is 1-D only).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.