Contenuto principale

Apply Vertical Shear Transformation to Image

R2026b

This example shows how to apply shear transformation to an input image in the vertical direction.

Example Model

Add the input image folder to the MATLAB® path.

imDir = fullfile(matlabroot,"toolbox","vision","visiondata","imageSets","books");
addpath(imDir)

Open the Simulink® model.

modelname = "ex_shearblkvertical.slx";
open_system(modelname)

The model reads an input image using the Image From File block.

To shear the image in the vertical direction, the model uses the Shear block with these parameter values:

  • Shear direction — Vertical

  • Output size after shear — Same as input image size

  • Shear values source — Input port. This selection enables the S input port on the block and the Maximum shear value parameter. The Constant block specifies a vector of shear values, [10 70], to the S port.

  • Maximum shear value — 200

  • Background fill value — [10 10 140]

  • Interpolation method — Bilinear

Simulate and Display the Results

Run the model. The model displays the input image and the transformed output image by using Video Viewer blocks. The transformed output image is sheared along the vertical direction.

sim(modelname);