LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

surface minimisation

Hi all,
 
I know what I want to do, but don't know how to go about it!
 
My problem: I have two arrays containing height data.
 
The first array contains relative heights measured in the x-direction.
Essentially, I'm measuring the heights along strips of a surface, but have no idea of zero height for any of the strips.
The heights in any one row are correct relative to each other. However, there is no established relationship between the heights in row 1 and the heights in row 2.
 
eg
 
row 1:   2, 3, 5, 7
row 2:   6, 7, 9, 11
 
row 1 and 2 have the same height variation along the rows but I have no idea whether row 2 is actaully 4 units above row 1 or not.
 
The 2nd array contains strips of height data measured in the y-direction. Again, elements along a row are correct relative to each other, but between rows there is no established relationship.
 
I should be able to use the y-height values to establish the x-height off sets or vice versa. However, due to small errors, this is not the case and depending on the path taken (ie use y heights to correct x-heights or vice versa) I get differing surfaces.
 
ideally, these two matrices establish a lattice of heights and I should be able to obtain a surface.
 
What I'm looking for is a method to obtain the best fit for the surface.
 
Any ideas?
 
As an example:
 
x-heights:
row 1: 2,3,5,7
row2: 6,7,9,11
row3: 1,-1,0,2
row4: 1,1,3,5
row5: 7,12,2,4
 
y-heights:
row 1: 2,2,3,4,7
row2: 1,1,-2,3,8
row3: 0,0,-3,-5,-3
row4:6,6,3,7,3
 
So setting row 2 element 1 in the x-array equal to the second element of row 1 in y-array ( as row 1 element 1 is already equal to the first element of row1 y-array) involves subtracting 4 from each element in row 2 so it now becomes 2,3,5,7.
 
Similarly, set row 3 element 1 of x equal to element 3 row 1 of y, I need to add 2 to each element of row 3 in x, to give 3,1,24 etc
 
This example is not path dependent.
 
This gives the ideal result:
2,3,5,7
2,3,5,7
3,1,2,4
4,4,0,8
7,12,2,4
 
However if any of the original matrix elements are wrong (eg rounding up or down) this throws up the wrong result. So a minimising surface routine is what I need. Any suggestions are welcome
0 Kudos
Message 1 of 5
(2,884 Views)
This looks like an interesting question. Are you using LabVIEW any chance you can post the code you have writen for the above example so i can see it in action and try to understand better what you are trying to do.
 
Best regards
Graham Green
Software Product Marketing
NI | Emerson
0 Kudos
Message 2 of 5
(2,836 Views)

Hi GrahamG,

Thanks for your reply and interest. I haven't got a code written for this but I have a pseudo algorithm written (if you can call it that!). I was thinking a "random walk" method would work best.

If I have the actual 6 x 4 height field as shown below:

0 0 2 4 5 6

1 1 4 6 6 7

2 3 4 5 6 7

2 2 5 5 7 8

 

In my measurements I get the X-heights: heights along a row are correct relative to elements in that row

1 1 3 5 6 7

2 2 5 7 7 8

6 7 8 9 10 11

-1-1 2 2 4 5

and Y-heights: heights in a column are correct relative to elements in that column.

3 1 2 0 4 -1

4 2 4 2 5 0

5 4 4 1 5 0

5 3 5 1 6 1

Start with an empty array,

choose start point and enter into array.

So if I start with element row 2, col 2 in th X data: height = 8. (rows and columns numbered 0->5 and 0->3)

start point (2,2) height= 8

move to next adjacent point in vertical or horizontal direction to start point (not diagonal) choice of (1,2), (3,2), (2,1), (2,3).

choose (1,2)

as move in vertical direction check the relation in the Y-data between (2,2) and (1,2):

Y (1,2) h=4, Y (2,2) h= 4 =>dh =0

 therefore height (1,2) =8+dh =8+0=8

  move to next adjacent point in vertical or horizontal direction to  point (1,2)

choose (1,3)

as move in horizontal direction check relation in X-data between (1,2) and (1,2)

X(1,2) h=5, X(1,3) h=7 =>dh = +2

therefore height (1,3) = 8+dh=8+2=10

repeat until all points have been adjusted (keep track with another array?)

 

This gives the correct relative heights for all points along columns and rows.

 

following the above pseudo algorithm would get

4 4 6 8 9 10

5 5 8 10 10 11

6 7 8 9 10 11

6 6 9 9 11 12 

 

each point is 4 greater than actual but relatively correct.

 

Now that I have written it out  like this it becomes a bit clearer for me! and will try to implement this solution. In the meantime any help gladly accepted.

0 Kudos
Message 3 of 5
(2,807 Views)
That was a really good explanation and it seems as though you have a great idea of how to work on it from here. So as to save us both working on the same problem in parallel, if you are a little more confident now I would recommend that you have a first attempt and if you get to a stage where you are not sure where to proceede then post it up here and I shall take a look. At the stage of your application that you are now, you are the expert with your algorithm but once you have something, whether it works or not, post it up and then two minds debugging it are better than one. I should be happy to help.
 
best regards
Graham Green
Software Product Marketing
NI | Emerson
0 Kudos
Message 4 of 5
(2,793 Views)

Hi GrahamG,

 

Just completed the vi and it works for the example I gave, so posting it so that it may help others. There are one or two little snags that someone might fix quite quickly. I explain in text boxes in the block diagram what the vi's are doing, the problem I have is that depending on where I put my conditional test to see have all valid points been assessed I either get one loop too many or one loop too little, this probably a basic error!

 

It is an untidy vi with lots of arrays (and indicators for my own debugging which I have not removed), but it works in the main.

Comments and suggestions are more than welcome.

 Three vis attached:

Main vi: random.vi

sub vi: sub_random_element_identifer2.vi

sub vi: sub_random_element_jump.vi

0 Kudos
Message 5 of 5
(2,771 Views)