LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array interpolation for intensity graph

I have an intensity graph with some specific data and I need to interpolate this 2d array and fill it with appropriate values and color it accordingly. If you run the VI the intensity graph will be populated with lines forming a triangle sort of shape. How do i interpolate this 2d array to fill the empty places?

0 Kudos
Message 1 of 12
(917 Views)

We discussed all this a month ago and you are still doing this way too complicated* and backwards. The calculation should be pixel based and not ray based. Have you studied my earlier advice? Is there anything you don't understand?

 

Your question is not clear at all. Which "empty places" do you want to fill (everything currently black? just between the five lines?)

 

*notes

  • Why is the diagram maximized to the screen?
  • You have a case structure where both cases have identical code, adding zero. What's the point? A simple orange wire would the the same thing!
  • You have a big case structure with five cases, each with mostly identical code, differing only by a diagram constant. Only the diagram constant belongs inside the case structure! The rest can be shared outside the case!
  • Why do you think you need to calculate cos of exactly the same value 2048 times? Why calculate sin(32*pi/180) 5x2048 times?!?!? Once is enough!

 

0 Kudos
Message 2 of 12
(885 Views)

Sorry for the late reply. I have modified the code and reduced the redundancy. I just want to fill between the "five lines" rest of the graph stays black. What do you mean by the calculation must be pixel based but not on ray based? I tried to understand your old code but couldn't get it why you have taken complex numbers.

0 Kudos
Message 3 of 12
(850 Views)

@sheshu9a1 wrote:

 I tried to understand your old code but couldn't get it why you have taken complex numbers.


Complex numbers are just a convenient container for x,y data... You get a lot of vector math for free.

0 Kudos
Message 4 of 12
(828 Views)

@sheshu9a1 wrote:

I have modified the code and reduced the redundancy. 


You are lucky that the LabVIEW compiler is smart an does a constant folding on the cos calculation in your inner loop. This does NOT belong in the inner loop because it is loop invariant. Right?

 

Here's how I would have simplified your earlier code instead. Don't rely on the compiler to clean up your redundancies! (note that this is a literal rewrite, leaving all your weird calculations in place. I am sure there are fundamentally better ways to approach this)

 

altenbach_1-1640023155060.png

 

 

 


@sheshu9a1 wrote:

I just want to fill between the "five lines" rest of the graph stays black. What do you mean by the calculation must be pixel based but not on ray based?


Your intensity graph is a 2D array and only has a 295x456 area, so unless you want to zoom in later, that all you need in terms of array size. You are replacing data along arbitrary lines (ray based) and that means that sometimes you hit the same element multiple times or skip one once in a while. OTOH, you can calculate from simple geometry exactly what value each 2D array element should have. It is much more reasonable to iterate over all array elements, preferably using interpolation as in my earlier example.

 


@sheshu9a1 wrote:

I tried to understand your old code but couldn't get it why you have taken complex numbers.


Complex numbers are just a convenient way to represent point in a 2D plane and do calculations in 2D. It would take 5 minutes to learn and would immediately simplify all your 2D trigonometry. Complex does not add complexity, it simplifies! Nobody forces you to use complex, you can do exactly the same using simple numbers and some high-school trigonometry. Your choice!!

 

If you did not understand my solution, you need to simply ask for clarification! It is not efficient to come back after a month still stuck in the same rut and start a new thread!

 

Now go back to the old thread, study my last solution, try to understand every detail, and ask specific questions where things are not clear. Good luck!

 

The entire problem does not make a lot of sense to me anyway. Each ray has the same values, so graphing it at multiple angles seems completely redundant. The full data could just be displayed in a simple waveform graph, right? An intensity graph would be useful if the data depends on direction, for example

0 Kudos
Message 5 of 12
(820 Views)

Actually the data does change along with the angles.

0 Kudos
Message 6 of 12
(802 Views)

You'd also need to specify how you want to interpolate the values.

 

As far as we've been told (by you) you have 'lines' with 'values'. Theoretically, these lines have an infinite number of points, although you display just a few in the graph

 

You can't just 'interpolate between lines'. You could interpolate between horizontal lines in the graph, or vertical, that's relatively easy. Interpolation between the closest point of several lines is a lot harder. This would start to look like polygon rendering. Then you have algorithms like Inverse Distance Weighting, but that isn't really suitable for lines either. The way you want to interpolate could lead to completely different approaches.

 

It would help us help you if you could specify very, very, clearly what you want. You could for instance show us what you want the result to look like, even if it's created in paint, 3DS, matlab or on a napkin. 

0 Kudos
Message 7 of 12
(783 Views)

Capture.PNG

Those lines have only 2048 points and if the sin angle is constant at 30 degrees and cos angle is varied from 30 to 170 it would form in this similar shape but without any kind of interpolation. The above image is resultant of interpolation.

 

 

0 Kudos
Message 8 of 12
(778 Views)

@sheshu9a1 wrote:

Capture.PNG

Those lines have only 2048 points and if the sin angle is constant at 30 degrees and cos angle is varied from 30 to 170 it would form in this similar shape but without any kind of interpolation. The above image is resultant of interpolation.


So... Why not post this code and tell us where do you need help?

 

It seems you can already do what you're asking for?

 

Can you post this actual data set? It seems what you posted is only a small part of the data, so it will never look like this. Could be wrong...

0 Kudos
Message 9 of 12
(773 Views)

No. I don't have this code and even the data is limited(which is present in my original vi). So when you try to plot it, it would have same constant colors except the shape of the plot varies based on the cos and sine angles.

0 Kudos
Message 10 of 12
(765 Views)