02-04-2009
11:42 AM
- last edited on
01-05-2010
11:49 AM
by
Support
Hi everyone. I'm writing a VI that takes a 2D array (generally 283x130) and performs a certain smoothing function on the data. I take the average of 25 points around a radius (illustrated by the image attached). Also, on 2 of the edges of the array I want to wrap around and take the points from the opposite edge. I have an algorithm to do this that is very slow. Does anyone know of a similar labview function to do this? There are oodles of signal processing vi's, but I don't know what any of them mean.
Thanks,
Tim
02-04-2009 11:58 AM
Can you attach some data and the expected result?
Have you tried doing this as a simple 2D circular convolution?
02-05-2009 02:24 PM
Hey,
I have some data, but the files are huge so I'll just post a picture of what I want the algorithm to do. (Or something similar)
Supposing each block in the grid above is a single data point, I want to take each point and find the average of it and it's neighbors. In the image above, I want to make the middle red point the average of all of the red points. Simlarly for the green and for the yellow blocks. I want to do this for every data point in the set.
Like I said, I have written this algorithm, but it is intolerably slow.
02-05-2009 07:30 PM - edited 02-05-2009 07:33 PM
Well, this is pretty trivial. 🙂
Without the y wrapping it would be a near atomic operation (simply select "output size=x" for the convolution). Since you want to wrap only in the x direction, things need a few tweaks. Here's a quick demo, see if it makes sense to you.

This would have saved you tons of time and many useless lines of mathscript code. Right? 😉
Of course it would be easy to change the "broadener" to anything else, e.g. a normalized 2D gaussian, for example.
02-06-2009 10:49 AM
02-06-2009 11:23 AM
elset191 wrote:
At the top and bottom of the Y axis there is something undersirable going on, which can be seen in the attached pictures.
I patched my algorithm together from scratch in literally minutes, so there are probably of couple of rough edges ot polish up. It is by no means release quality. 😉
Are your dimensions even or odd numbers?
Would it be possible for you to attach a dataset that shows the problem?
What are the actual values along the faulty edge?
Just curious, what are the speed differences between the two solutions?
02-06-2009 02:56 PM - edited 02-06-2009 03:06 PM
My dimensions are arbitrary. For the examples I've been talking about they are odd, though.
Attached are files containing raw data, as well as the 2 methods we've been discussing.
The speed difference is substantial. Your algorithm runs in <1second and mine takes between 90 and 120 seconds
02-11-2009 12:27 PM - edited 02-11-2009 12:28 PM
02-11-2009 03:06 PM - edited 02-11-2009 03:09 PM
Sorry, I got side-tracked with other issues and did not have time to look into this. Seems you solved your problem. 🙂
One minor comment: you should really eliminate the local variables and wire from the plain terminal.
(Still, I have the nagging feeling that there are more elegant ways to do all this. 😉 Can you attach the actual VI containing some typical data in the three controls (Make current values default before saving))
02-11-2009 03:09 PM