How can I automatically crop the black borders after transforming (rotation, translation, scale and shear) an image?
I am using an intensity-based automatic image registration (imregtform, optimizer, imregister....) to rotate one image to fit the other. Now after rotation, I need to crop both images to have the same size, and still be lined up.
The simplest representation of what the rotated image will look like would be a white square to which the transformation matrix was applied.
An example of what a set of the actual images I am using would look like can be seen here.
I assume the fact, that the image may have zero-value pixels at its edges may complicate the operation, although I assume the whole images will be non-zero, due to noise.
Maybe I can use the transformation matrix to actually calculate the border that needs cropping. in the example above the matrix was:
0,999428374496743 0,00888472048904662 0
-0,00888472048904659 0,999428374496743 0
3,79626401832983 -0,493066986575474 1
The matrix is listed in a '1x1 affine 2d' object in the workspace. I wasn't able to find out the syntax to use it from there.