Using AffineMatrix2D to rotate an image by 180 degrees changes with

Hello,

I am using the following code to rotate an image by 180 degrees.

When I do, the width of the output image is 1 pixel less than the input image. Since this is a simple 180-degree rotation, I would expect the output to be the same width.

Can you suggest a mechanism to keep the image size constant or an alternative to the AffineTransform operation ?

Many Thanks

var angle = new Angle
{
Deg = 180
};
var matrix = new Matrix2D( angle);
var affineMatrix = new AffineMatrix2D(matrix, Point2Dd.Empty);
var rotateImage = CurrentImage.AffineTransform(affineMatrix);
CurrentImage?.Dispose();
CurrentImage = rotateImage;

As an alternative I have tried to set the driver to rotate the image by 180 degrees using the code below. This seems to have no effect. I have taken the values from the INI file and tried to set them in code.
What am I doing wrong? Is there some documentation that explains this? I have searched for “RotateImage” and that doesn’t return any results in the .NET API documentation.

discoveryList [foundIndex].SetParameter(“RotateImage”, “2”);
_device = DeviceFactory.Open(discoveryList[foundIndex].AccessToken, acquisitionStack);

Thanks for your help.

Partially answering my own question…

Rotation achieved using SubImage keeps the image size.

if (IsFlipped)
{
var area = new Area2D( CurrentImage .Bounds .Right ,
CurrentImage .Bounds.Bottom ,
CurrentImage .Bounds.Right ,
CurrentImage .Bounds.Top,
CurrentImage .Bounds.Left ,
CurrentImage .Bounds.Bottom);

            var rotatedImage = CurrentImage.SubImage(area);
            CurrentImage?.Dispose();
            CurrentImage = rotatedImage;
        }

However, it would still be useful to understand why I can’t do the rotation in the driver?

Hi @BitSmith ,

which acquisition Stack are you using as parameter?
I assume you are using the GenTL here.
For now it seems like a bug in CVB, I will forward this information to have it fixed in one of the next releases.
As a workaround: AcquisitionStack::Vin should work.

Cheers
Chris

Hi,

Yes, I am using the GenTL stack. The reason for using this stack is so that I can identify individual corrupt frames which I can’t do using the vin stack.

I will stick with using the SubImage rotation after acquisition, but good to know why it wasn’t working trying to set in the driver.

Steve