# 2.6.5.6 imgShear

Shear

## Brief Information

Shear the image horizontally or vertically

## Command Line Usage

 

1. imgShear a:=30 h:=vertical fill:=0; 

2. imgShear a :=30 img:=[Mbook1]1!Mat(1) oimg:=<new>; 

## Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Angle a

Input

double

0

Specifies the amount of shearing, which refers to the angle between the original edges and the changed edge. The value varies between [-45, 45]. A positive value will slide the image clockwise, while a negative value will slide it counterclockwise.

Direction h

Input

int

hotizontal

Specifies the shear direction.

Option list

• horizontal:Horizontal
Slides the image horizontal edge along the X axis
• verical:Vertical
Slides the image vertical edge along the Y axis
Input Matrix img

Input

Image

<active>

Specifies the image to be manipulated. The default input is the active image.

Output Image oimg

Output

Image

<input>

Specifies the output image. By default, the output image is the same as the input image. See the syntax here.

Fill Color fill

Input

int

0

Specifies a color from the Origin color list to be used to fill the background of the output image.

## Description

This X-Function allows user to shear an image, or change the relative geometries of the x- and y-axes of that image. Shearing can change the geometry of an image from a rectangle to a non-rectangular parallelogram, or vice versa. The resulting image will look perspective-shifted to the viewer. Horizontal shearing fixes the length of the horizontal edge and allows the y-axis to change, while vertical shearing performs the same thing by fixing the length of the y-axis and allowing the x-axis to change length. The x- and y- axes can be independently manipulated via separate shearing angles.

Sheared images usually have empty triangles along each edge. These triangles are filled with black by default, but can be filled with a user-specified color from the dialog.

## Examples

In this example, we use the imgShear function to shear the input image by 30 degree and fill the background of the output image with orange:

1. When the image is active, select Image: Geometric Transform: Shear to open the dialog of the X-Function.
2. In the dialog, change the settings as the screenshot below and click OK to close the dialog.

A new image is created. It is the shared image.

 The original image The output image

## Algorithm

The computation uses L_ShearBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_ShearBitmap topic.

## References

LEADTOOLS Main API Help file, Version 14