Rectangle FitToImage Method Cognex VisionPro 9.22

Adjust the shape's geometric properties such that its default size is based on the image and its SelectedSpaceName. XScale and YScale are multipliers where 1.0 designates 100% scaling.

Namespace: Cognex.Vision
Assembly: Cognex.Vision.Core.Net (in Cognex.Vision.Core.Net.dll) Version: 9.22.2.0
Syntax

public void FitToImage(
	IImage image,
	double xScale,
	double yScale
)

Parameters

image
Type: Cognex.Vision IImage
The image to fit to.
xScale
Type: System Double
The amount to scale by in the x-direction. A value of 1.0 means to scale 100% in the x-direction.
yScale
Type: System Double
The amount to scale by in the x-direction. A value of 1.0 means to scale 100% in the y-direction.

Implements

IShape FitToImage(IImage, Double, Double)
Exceptions

ExceptionCondition
ArgumentExceptionxScale or yScale is <= 0.0 or > 1.0.
Remarks

Adjusts the shape's geometric properties such that its default size is based on the image and its SelectedSpaceName. Different shapes behave differently when FitToImage is called. Behavior of FitToImage() with different shapes

Shape

Behavior

Circle, Rectangle, RectangleAffine, CoordinateAxes

Scales the shape in the x- and y-directions according to the height and width of the image.

Ellipse

The ellipse is sized to fit just within the image after xScale and yScale have reduced the image size. The principal axes of the ellipse are aligned with the image, not with the selected space name.

CircularArc, CircularAnnulusSection, EllipticalArc, EllipticalAnnulusSection

The arc or annulus section is centered in the image and sized to fit just within the image after xScale and yScale have reduced the image size. The resulting shape covers the range from 0 to 270 degrees in pixel space. The principal axes of the underlying ellipse are aligned with the image, not with the selected space name.

LineSegment

The line segment is centered vertically centered and is horizontal across the image. xScale scales to the width of the image. yScale is ignored.

Line

The line's reference point is centered in the bounding rectangle, and its rotation is maintained. xScale and yScale are ignored.

Polygon

The centroid of the polygon is centered in the image. xScale and yScale are ignored.

PointMarker

The point is centered in the bounding rectangle. xScale and yScale are ignored.

See Also