Qu

affine_scale

Builtin index · Images

result = affine_scale(sx, [sy])

Input: sx, sy · Output: result

What it is

Builds a scaling transform for imwarp. sx is a number, the scale factor along x; sy is an optional number, the scale factor along y, defaulting to sx (uniform scale) when omitted — matching MATLAB imresize(img, scale)'s single-factor convention.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = affine_scale(sx, [sy])
sx numbersx is a number, the scale factor along x.
sy number, optionalsy is an optional number, the scale factor along y, defaulting to sx (uniform scale) when omitted — matching MATLAB imresize(img, scale)'s single-factor convention.
result Mat
Returns a new 3x3 Mat.

Examples

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

img = image_new(20, 20, r=0, g=0, b=0)

shifted = imtranslate(img, 5, 3, fill=255)
scaled = imscale(img, 1.5, fill=0)
imshow(shifted)

M = affine_scale(2, 1.5) * affine_shear(0.2, 0) * affine_identity()
print(shifted.width, scaled.width, M)
output
20 30 [2, 0.4, 0; 0, 1.5, 0; 0, 0, 1]
a synthetic field with one bright patch

from images

How it works

affine_scale(sx, [sy]) — uniform scale when sy is omitted (sy = sx), matching MATLAB imresize(img, scale)'s own single-factor convention.

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