LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d smoothing

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

 

Message Edited by Support on 01-05-2010 11:49 AM
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 1 of 10
(5,990 Views)

Can you attach some data and the expected result?

 

Have you tried doing this as a simple 2D circular convolution?

Message 2 of 10
(5,986 Views)

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.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 10
(5,961 Views)

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.

 

Message Edited by altenbach on 02-05-2009 05:33 PM
Download All
Message 4 of 10
(5,947 Views)
Thanks.  There is one thing though.  At the top and bottom of the Y axis there is something undersirable going on, which can be seen in the attached pictures.  The convolution method produces lips on the side of the graph, where my (much worse algorithm) is smooth all the way across.  Is this something inherent to your method, or are the edges not being done properly.

Also, I have no idea what is going on in the heart of the code.  I've never learned about convolutions, so I'll look those up and then try to follow the code so I actually understand what's happening.

That aside, thank you very much.  Your help is greatly appreciated.
--
Tim Elsey
Certified LabVIEW Architect
Download All
0 Kudos
Message 5 of 10
(5,910 Views)

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?

0 Kudos
Message 6 of 10
(5,900 Views)

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

Message Edited by elset191 on 02-06-2009 03:06 PM
--
Tim Elsey
Certified LabVIEW Architect
Download All
0 Kudos
Message 7 of 10
(5,880 Views)
I rewrote my mathscript in LabVIEW code, and it runs almost instantly now.  I'm shocked that Mathscript is so slow.  For the sake of comparison I've attached a picture of the block diagram.  It's kind've a lot of code, but it was worth writing.
Message Edited by elset191 on 02-11-2009 12:28 PM
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 8 of 10
(5,825 Views)

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))

 

Message Edited by altenbach on 02-11-2009 01:09 PM
Message 9 of 10
(5,809 Views)
I'm sure there are.  I just know how to program though.  I don't know anything about signal analysis at all.  Smiley Indifferent oh well.  I'm still keeping an eye open though.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 10 of 10
(5,805 Views)