Main Content

Apply Vertical Shear Transformation to Image

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 directionVertical

  • Output size after shearSame as input image size

  • Shear values sourceInput 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 value200

  • Background fill value[10 10 140]

  • Interpolation methodBilinear

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);