Hi, I have a problem, I have to calculate the matrix that makes the centers of two mirrored images aligned. How should I proceed?

You’ll have to move the origin in the direction of the mirroring by the size of the image (spacing*dimensions).

If you know the centerpoint then it should be easy: concatenate transforms that shifts center to the origin, apply mirroring, shift it back to the center.

If you don’t know the centerpoint then mark corresponding anatomical points on the two sides and compute the transform using landmark registration (e.g., SlicerIGT extension’s Fiducial registration wizard module).