# how can I use imregister() about the center of an image

조회 수: 3 (최근 30일)
Dan 2014년 8월 16일
댓글: Matt J 2014년 8월 19일
Straight to the point : Can anyone tell me 1) How I can convert the transformation matrix about the top left corner to the transformation about the center pixel? I assume this is some simple linear algebra ? or better yet. 2) How to use imregister() about the center pixel of the moving and fixed image?
This is why I am interested: I want to be able to apply a transformation onto a picture about its center , then use imregister to match it with the original picture and find out what imregister thinks the transformation that I applied was.
What I have done:
*I relied on this paper ( pages 6 and 7 has some relevant equations ).
1) I decided on transformation parameters ( translation in xy, rotation ccw, shear, and scale in xy). Then I made a transformation matrix from it based on the work of the reference above. 1)I took the original picture , translated it to the picture to the center pixel , applied the transformation , then applied an inverse of the translation matrix onto it. (ie inv(trans)*Transformaton*trans = newTransform.
2)I ran imregister with moving = transformed picture , fixed = original picture , standard optimization and metric parameters.
3)I extracted the tform.T martix that imregtransform() finds ( inside of imregister ).
4) I used the following reference above calculations to break down the transformation matrix into the parameters of the imregister transformation ( rotation, shear...etc)
5) I compared the inverse of the transformation I originally applied and the transformation that imregister found ... and they are not at all similar.
I made a similar program that did all the transformations about the top left corner and then imregister had no problem finding the right numbers...
I also tried to shift the moving and fixed pictures so that the center pixel is at the origin and run imregister. This also did not work.

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Matt J 2014년 8월 16일
편집: Matt J 2014년 8월 16일
How I can convert the transformation matrix about the top left corner to the transformation about the center pixel?
If you have an affine transformation
y=A*x+t
where A is a nxn linear transformation matrix and t a nx1 translation vector, you can express the transformation with respect to a different origin z by rewriting the above in the following equivalent form
y-z= A*(x-z) + A*z-z + t
Now, define
ynew=y-z
xnew=x-z
tnew= A*z-z + t
and this becomes
ynew=A*xnew+tnew
But note that xnew and ynew are the same as x and y but expressed relative to a new origin, z.
2) How to use imregister() about the center pixel of the moving and fixed image?
You can specify the location of the world coordinate origin in each image using the 2nd syntax of imregister mentioned in the documentation
[moving_reg,R_reg]= imregister(moving,Rmoving,fixed,Rfixed,transformType,optimizer,metric)
In particular Rmoving and Rfixed are created with imref2d (or imref3d) to define the relationship between the coordinates of the two images with world coordinates.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Matt J 2014년 8월 19일
Dan commented:
Thank you very much - that was exactly what I needed.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by