How to use imwarp() with tform obtained by pcregrigid()?
Mostra commenti meno recenti
Hello,
I have two 3D images (of different size) that I would like to register. To do so, I extracted from both volumes the main features consisting in two 3D pointclouds. Then, I used the function pcregrigid() to register the two pointclouds and obtained a tform object T.
On pointclouds, T seems to be the good transformation.
However, when I want to come back to the image domain, i.e. transform the original moving image by using T and imwarp(), I do not obtain the desired registration.
I probably do not understand well the imwarp() function, especially the coordinate system it uses to transform the image. I don't know if I have to precise a particular imref3d() object, and what is the good tform to use: T or invert(T) ?
Let recall that the two original 3D volumes have not the same size, and that the coordinates of each pointcloud depend on the coordinate system of each image.
Thank you in advance for you precious help.
Emmanuel
Risposte (1)
Jonas Golde
il 15 Mag 2019
Modificato: Jonas Golde
il 15 Mag 2019
As I ended up here with the same issue a couple of days ago, here is the solution. Assume, you have the two 3D images of different size im1 and im2, and you somehow created point clouds from them...
[X1,Y1,Z1] = ind2sub(size(im1),find(im1>100));
pc1 = pointCloud([X1,Y1,Z1]);
[X2,Y2,Z2] = ind2sub(size(im2),find(im2>100));
pc2 = pointCloud([X2,Y2,Z2]);
...and subsequently did the registration, obviously successful:
tform = pcregistericp(pc1, pc2);
pcshowpair(pctransform(pc1,tform),pc2);
To apply the transformation now on the initial image im1, you have to permute dimensions (whatever is the reason for that...) and furthermore use spatial referencing, referring the transformation of the "moving" image to the "fixed" image im2 (while keeping in mind swapped dimensions y-x-z instead of x-y-z):
RA = imref3d([size(im2,2) size(im2,1) size(im2,3)]);
im1_aligned = permute( imwarp( permute( im1, [2 1 3] ), tform,...
'OutputView', RA), [2 1 3] );
Now, im1_aligned and im2 should be aligned.
Categorie
Scopri di più su Geometric Transformation and Image Registration in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!