MATLAB Answers

# Find the surface area of an object using stereo vision.

4 views (last 30 days)
Naseeb Gill on 6 Jan 2020
Edited: Adam Danz on 7 Jan 2020
Hello,
I want to find out the surface area of tree (only green part) using stereo vision. I know stereo vision and using the same I got the (X,Y,Z) values of tree, (of course one side only) (file is attached). I used delaunay function to calculate area but the problem is that I have some negative values of X and Y which cause error in surface area. How I can get the correct value of surface area using stereo vision?
It will be good if I can calculate volume also.
Thank You.

#### 4 Comments

Show 1 older comment
John D'Errico on 6 Jan 2020
Adam is of course correct. While negative values in your data should never compromise an area computation in correctly written code, if your code is unable to handle them, the simple solution is to just translate ALL of your data so that none are negative. Find the minimum (most negative) value in each dimension, then add a constant to all coordinates in that dimension.
This operation does not change the area. If it does in any significant way beyond floating point trash in the results, then again your code has a problem.
Naseeb Gill on 7 Jan 2020
Same I was thinking. But unable to do so. What I want to do is remove negative value and add that much value in positive value so that area reain same.
Say for example I have A = [-2,-7,0.5,14,3] by doing offset It should be convert into B =[0,0,2.5,21,3,].
I want to know how to do so? Also a case may be arises when negative values may be more than positive values like C = [-1,-9,-5,14,3]. How to solve this?
Adam Danz on 7 Jan 2020
"Say for example I have A = [-2,-7,0.5,14,3] by doing offset It should be convert into B ="[0,0,2.5,21,3,]. "
Why would A be converted to that? A would be offset by it's minimum value which is -7.
A = [-2,-7,0.5,14,3]
A = A - min(A)
A =
5 0 7.5 21 10
For C
C = [-1,-9,-5,14,3]
C - min(C)
ans =
8 0 4 23 12
Note that even if A or C do not have negative values, applying the same proceedure (A - min(A)) does not affect the area.

Sign in to comment.

### Answers (1)

KSSV on 7 Jan 2020
After using delaunayTriangulation, you have vertices and nodal connectivity in hand. Then you can use this function to get the area of each triangular element........sum the total areas, you will get the total sutgace area.
Have a look on function triarea from the package.

#### 4 Comments

Show 1 older comment
Naseeb Gill on 7 Jan 2020
I used below code: with x,y and z values I got answer = 99.32 but when I insert any negative value anywhere x = [0;-2;-4;6;8;9;0;2;4;6;8;9;0;2;4;6;8;9]; answer cames more than 99. How to solve this?
x = [0;2;4;6;8;9;0;2;4;6;8;9;0;2;4;6;8;9];
y = [0;0;0;0;0;0;5;5;5;5;5;5;10;10;10;10;10;10];
z = [22;21.3;21;21.4;22.2;23.5;22;21.3;21;21.4;22.2;23.5;22;21.3;21;21.4;22.2;23.5];
tri = delaunay(x,y);
P = [x,y,z];
v1 = P(tri(:,2), :) - P(tri(:,1), :);
v2 = P(tri(:,3), :) - P(tri(:,2), :);
cp = 0.5*cross(v1,v2);
surfaceArea = sum(sqrt(dot(cp, cp, 2)))
KSSV on 7 Jan 2020
The order of the vertices is important..maybe your messing with that. Did you try with triarea?
Naseeb Gill on 7 Jan 2020
Yes I tried with triarea, it shows error.
Error using triarea (line 29)
Incorrect input dimensions.
Mine pp array is 18x3 and tt array is 24x4.
Also, code I wrote in above comment is same as code written in triarea. Some of its part is:
%--------------------------------------- compute signed area
ev12 = pp(tt(:,2),:)-pp(tt(:,1),:) ;
ev13 = pp(tt(:,3),:)-pp(tt(:,1),:) ;
switch (size(pp,2))
case +2
area = ev12(:,1).*ev13(:,2) ...
- ev12(:,2).*ev13(:,1) ;
area = 0.5 * area;
case +3
avec = cross(ev12,ev13);
area = sqrt(sum(avec.^2,2)) ;
area = 0.5 * area;
otherwise
error('Unsupported dimension.') ;
end
After observing both codes, there is no difference. I'm not changing order of vertices, I'm using them as it as.

Sign in to comment.

Sign in to answer this question.

R2017b

Translated by