Transformation of a multidimensional array into a vector
7 views (last 30 days)
Show older comments
Good afternoon. I have the following problem. I need to convert the multidimensional matrix obtained after the execution of the operator: efficientLBP, into the vector.
function lbp = lbpFace(face)
face = rgb2gray(face);
face = imresize(face, [190, 142]);
lbp = efficientLBP(face);
This is necessary, because in the future I need to calculate the Mahalanobis distance.
function sravnFace = sravnLBP(face, face2)
lbpface1 = lbpFace(face);
lbpface2 = lbpFace(face2);
distance = mahal(lbpface1', lbpface2');
If i do not do this conversion, i will get the following error:
Error using '
Transpose on ND array is not defined. Use PERMUTE instead.
Error in sravnLBP (line 21)
distance = mahal(lbpface1', lbpface2');
Error in union_prog (line 8)
x = sravnLBP(face, face2);
And how to use the operator permute in this case, i do not know. So it seems reasonable to make a transformation
0 Comments
Answers (1)
Guillaume
on 30 Apr 2017
"So it seems reasonable to make a transformation"
No it doesn't. At all. Certainly not with the limited information provided. While you could certainly reshape the original multidimensional array into a 2D or 1D array without any care for what each dimension means, computing a distance from that would most likely be meaningless.
There must be a reason your data is a multidimensional. Reshaping it just so it conforms to the input expected by a function is not the way to go. Maybe you need to iterate over one of the dimension before calculating your distance on 2D matrices, maybe you need to do something else. Why is the data ND in the first place?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!