1 | initial version |
What do you mean by view?
If you have set a ROI (region of interest) for an image, you need to remove the roi with cvResetImageROI().
But if the affine transform merely transforms some points out of the defined boundaries of the image, then the only solution is to use a larger image for transforming.
You could first create a new image with double the dimensions,
then call cvSetImageROI() on that image to select a region in the middle with the size of your old image
then cvCopy() the old image to the new one
then call cvResetImageROI() to remove the roi (important!)
then do your transforms with the new image
2 | No.2 Revision |
What do you mean by view?
If you have set a ROI (region of interest) for an image, you need to remove the roi with cvResetImageROI().
But if the affine transform merely transforms some points out of the defined boundaries of the image, then the only solution is to use a larger image for transforming.
You could first create a new image with double the dimensions,
then call cvSetImageROI() on that image to select a region in the middle with the size of your old image
then cvCopy() the old image to the new one
then call cvResetImageROI() to remove the roi (important!)
then do your transforms with the new image
EDIT:
If the affine transformations are such that even a much larger image will not contain the result, I can think of two options:
1) instead of transforming a 2d matrix, transform a list of points:
make a matrix that contains all the (foreground) pixels in your image, with their x coordinate in channel 0 and their y coordinate in channel 1. The dimensions of the matrix do not matter.
then call transform instead of WarpAffine with this matrix
then paint the resulting transformed points in a new image
2) change your affine transforms so that they do not shift the image quite as much
If you use getAffineTransform, then simply shift your 3 reference dst points so that they have the same centroid as your 3 src points before calling getAffineTransform