I've got a question regarding the isosurface function of MATLAB.
Let's say I've got a mask (a bw volume) representing object A, and a surface (vertices and faces) representing object B. We know that object A and object B are different representation of the same thing. Therefore we want to register them.
Now, the registration algorithm returns a certain transformation T, starting from an initial guess T'. To manually evaluate the initial guess I do the following:
[f1,v2] = loadGraphicalTemplate(B);
[f2,v2] = isosurface(mask); % aka object A
v2 = transformPointsForward(InitialGuess,v2);
labels = ( zeros(length(v1),1)'; ones(length(v2),1)' );
showMesh( [f1;f2], [v1;v2], labels );
where initial guess is an affine matrix that I manually modified, until the two surfaces are almost overlapping. At this point, the registration algorithm comes and does the rest.
The problem is that when I apply the transformation to the points cloud (generated from the object B, see the code below), the result doesn't make any sense! It's like the transformation matrix has been randomly generated!
%% coordinates of non zero elements
IDX = find(B);
[X,Y,Z] = ind2sub(size(B), IDX);
coords = [X,Y,Z];
%% values of non zero elements
linB = B(:);
vals = linB(IDX);
%% transformation
coords = transformPointsForward(T,coords);