gari
gari

Reputation: 63

Why changes the orientation of the 3D image when using isosurface vs plot3 and ind2sub?

I have a indexed 3D image A, that I can visualize with isosurface. If I create another version of the same image using ind2sub, when I plot it with plot3, one of the axes is flipped.

Here is an example:

    isosurface(A)
    [x, y, z] = ind2sub(size(A),find(A==1));
    plot3(x, y, z,'b.');

And here and example image: image_flipped

Is this a normal behavior or am I missing anything in the process?

If I go back in the process I reach the same point:

    Y = zeros(size(A));
    Y(sub2ind(size(A), x, y, z))=1;

Obviously, isequal(A,Y) gives 1.

Upvotes: 2

Views: 132

Answers (1)

chappjc
chappjc

Reputation: 30579

Because ind2sub returns rows then columns as the first two outputs, not x,y.

[y, x, z] = ind2sub(size(A),find(A==1));

Upvotes: 1

Related Questions