From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D Interpolation

I'm trying to do 2D bilinear interpolation on a 2D array. Is there an easy way to do this in LabVIEW? I see there is a standard function called "Interpolate 1D array". Is there a way to use this function extended to 2 dimensions?

Thanks,
Rob
0 Kudos
Message 1 of 7
(13,656 Views)
In this link

http://forums.ni.com/ni/board/message?board.id=170&message.id=125907

Christian post a bunch of examples that sholud help.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(13,648 Views)
(The above mentioned link is not really what you need.)

In bilinear interpolation, you have a 2D array and try to obtain interpolated values using fractional array indices. For this, you need to get the 4 nearest points and weight them according to the proximity to the desired fractional index. (For integer indices, it should return the same result as "index array").

You can do a google search for the formulas. I made a quick demo (LabVIEW 7.0) that incorporates a simple bilinear interpolator I just wrote for you. I think it is working correctly, but please verify for yourself and modify as needed. 🙂

See if this suits your needs. Good luck!
Message 3 of 7
(13,636 Views)
Thanks! That is exactly what I was looking for. Now I have to figure out how you did it. I understand the bilinear interpolation equations but implementing it in LabVIEW was where I got stuck.

Rob
0 Kudos
Message 4 of 7
(13,627 Views)

@rmoss78 wrote:
Thanks! That is exactly what I was looking for. Now I have to figure out how you did it. I understand the bilinear interpolation equations but implementing it in LabVIEW was where I got stuck.

Rob

Well, the diagram of my code is right there in front of your eyes. 🙂

True, the way I wrote it, the code is extremely compact and the weighting matrix is generated using the outer product of the fx (=fractional x part), 1-fx, fy, and 1-fy terms. The rest operates directly on the 2x2 2D array, taking the array sum later. It might be a bit hard to read.

I divide the numbers by 1 using quotient and remainder, which gives me the integer part to get the correct 2x2 subset and the fractional part for the weighting.

You could have equally well programmed it a bit more explicit, e.g. instead of the outer product, use something like in the attached image. Same difference. 😉

(IF you're coming from a text based programming background, you could have even used a formula node, which I personally don't like).

Let me know if anything else is still does not make sense to you.

Message Edited by altenbach on 06-24-2005 09:53 AM

Message 5 of 7
(13,622 Views)

I found this thread while searching for a 4D linear interpolation function, which I didn't manage to find.  So, I built one based off the well done 2D interpolation function here.  Since it would have saved me some effort had it already existed, I thought I'd post it here for posterity. It was made for LabVIEW 7.1, but I don't see any reason why it shouldn't work outside that version.

 

There's one complication, which I left in place to match the operation of altenbach's code.  As he said in the previous post, you have to normalize whatever actual grid spacing you may have into integer indices that span [0 : n-1]. Your point of interest then needs to be scaled accordingly.

 

Hope this helps any future searchers.

 

0 Kudos
Message 6 of 7
(11,839 Views)

uuu

0 Kudos
Message 7 of 7
(10,136 Views)