Transformation of a multidimensional array into a vector

조회 수: 7 (최근 30일)
Peter Saytsev
Peter Saytsev 2017년 4월 30일
댓글: Peter Saytsev 2017년 4월 30일
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

답변 (1개)

Guillaume
Guillaume 2017년 4월 30일
"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?
  댓글 수: 1
Peter Saytsev
Peter Saytsev 2017년 4월 30일
The thing is that my task is to isolate the signs from the faces of the faces and compare them with the base of the available attributes. I know that in matlab there is a function exctractLBPFeatures, and at the output of this function we obtain a vector of characteristics, and we can compare the measure of closeness of new vectors with vectors in the database. But this function is not very clear to me, since the result is not correct. So I decided to try another efficientLBP function. And at the output of this function we get a multidimensional array. That is why this question arose.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by