Transpose on ND array is not defined.

15 views (last 30 days)
david Fernandez
david Fernandez on 24 Feb 2011
somebody could help me with this message ???
Transpose on ND array is not defined.
I tried to use the function inhull(testpts,K,tess) but I can't! ??? Error using ==> inhull at 67 testpts and xyz must have the same number of columns
>> size(K)
ans =
1452 3
>> size(testpts)
ans =
32 8 66
  2 Comments
Jan
Jan on 24 Feb 2011
What is the error message: "Transpose on ND..." or "testpts and xyz must have..."?
david Fernandez
david Fernandez on 25 Feb 2011
the question is how i could solve the problem of using inhull with the testpts and K as a variables, how I can manage to have the same dimension?

Sign in to comment.

Answers (2)

Jan
Jan on 24 Feb 2011
If you are working with John D'Errico's INHULL, the documentation in the FEX seems to tell, that you need 2D matrices as input. Why is your textpts a 3D array?
  2 Comments
david Fernandez
david Fernandez on 25 Feb 2011
yes, I'm using John D'Errico's inhull, but it says:
arguments: (input)
% testpts - nxp array to test, n data points, in p dimensions
% If you have many points to test, it is most efficient to
% call this function once with the entire set.
%
% xyz - mxp array of vertices of the convex hull, as used by
% convhulln.
%
% tess - tessellation (or triangulation) generated by convhulln
% If tess is left empty or not supplied, then it will be
% generated.
It works for any 'd' dimension, no ?
I create my testpts as: testpts=[xMat, yMat, zMat]
K=convhulln(V);
V are the vertices of my triangulated mesh of the image in file.stl binary
Walter Roberson
Walter Roberson on 25 Feb 2011
No, it doesn't work for any 'd' dimension. When you are working with a points in higher-dimension space, it is common to represent them as 2D matrix, one row per point, and then the number of columns corresponds to the dimensionality of the points.

Sign in to comment.


Walter Roberson
Walter Roberson on 24 Feb 2011
Transpose is only defined for 2D arrays. For arrays of higher dimension, permute() must be used.
If you are working with an image, you have probably inadvertently used a truecolor (RGB) image in a context that needs a binary or grayscale image.
  4 Comments
david Fernandez
david Fernandez on 25 Feb 2011
i'm trying to find the skeleton of an image in stl file (binary).
The code I use is:
%Read the binari STL file
[F,V,N] = STLREAD('FILENAME'); % returns faces F, vertices V and the face normal vectors N separately
%create 3D binary box
bboxPts=[min(V,[],1);max(V,[],1)];
bboxDiff=ceil(diff(bboxPts));
%subdivision of the space box
xVec=linspace(bboxPts(1,1),bboxPts(2,1),2*bboxDiff(1));
yVec=linspace(bboxPts(1,2),bboxPts(2,2),2*bboxDiff(2));
zVec=linspace(bboxPts(1,3),bboxPts(2,3),2*bboxDiff(3));
[xMat,yMat,zMat]=meshgrid(xVec,yVec,zVec);
normals=N;
%convex hull
K=convhulln(V);
trisurf(K,V(:,1),V(:,2),V(:,3));
%call inhull, return if is inside or not
X =[xMat;yMat;zMat]; %option1
testpts=permute(X,[2 3 1]);
%testpts=[xMat';yMat';zMat']; %option 2
tess=trisurf(K,V(:,1),V(:,2),V(:,3));
in = inhull(testpts,K,tess);
image3D = reshape(in,size(xMat));
%Calculate Skeleton
edtImage3D=bwdist(~image3D);
labeledImage = watershed(edtImage3D);
unique(labeledImage(:)) %ans = 1
Walter Roberson
Walter Roberson on 25 Feb 2011
X = [xMat(:), yMat(:), zMat(:)]

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!