02-24-2009 07:20 AM
Hi i have had a thought, is it possible to carry out a 2d boxcar smoothing?
as in is it possble to have a shifting average of a number of values around the current point?
for a 2d array with number of values x and y where the avarage is true over say x=y=3 say:
1 2 2 5 6
1 8 6 4 3
2 6 7 3 9
2 2 3 4 6
1 1 9 9 0
so if you took the center point '7' it would be replaced with an approximated value from the numbers surounding it.
is that possible, also can the edges be acconted for? and the average modified for this situation?
I would post a VI but the principle will work if it can work for any 2d array.
help!!
02-24-2009 08:28 AM
02-24-2009 09:42 AM
I've not got a piece of code, i have no idea where to start, i'm guessing using shift registers, with a loop within a loop?
or i guess it could be made using mathscript.
Also i'm using lv 8.2, just incase!
02-24-2009 09:58 AM
i've muddles something together that does a star one up and one down (badly)
but i think it can be done nearly as simply but better somehow.
02-24-2009 10:01 AM
Hi John,
you can use the "Array Subset" function combined with the "multiply array elements" function.
Mike
02-24-2009 10:20 AM
ah ha! great, one minor edit to your suggetion, it works better with 'add array elements'
also i've added a vi with the basic idea,
i think it could do with playing with.
02-25-2009 07:52 AM
Hi, i've got a better one, but i now suffer from the problem that it won't let me overlap on the starting edge, as in it defalts to row 0 or line 0, if i want it to start with that line.
so i can't get it to start on the top line,
if you run the VI you'll see what i mean, has anyone got any suggestions as it overlaps on the far edge happliy.
I've included the VI for peopel to look at and edit as they need to.
Help!
02-25-2009 11:43 AM - edited 02-25-2009 11:48 AM
http://forums.ni.com/ni/board/message?board.id=170&message.id=384559&query.id=131409#M384559
It's a slightly different problem, but very similar.
My second to last post in that thread is my solution.
The block diagram is here
http://forums.ni.com/ni/attachments/ni/170/386040/1/smooth.PNG
The mathscript node does the same computation as the rest of the code, but takes a lot longer so I rewrote it in LabVIEW. that's what the rest is doing.
This VI takes a "circle" of points with radius 3. I also have one that takes a radius of 2.
02-26-2009 11:33 AM
hmmm, if the promlem is only on the top and left edges, it 'could' possibly be solved by flipping the matrix top to bottom and left to right carrying out the averageing twice and then align the two results and then create one set of results?
Or is that going to cause more problems.....
I'm going to give it a try and report back.
02-26-2009 12:48 PM
Yeah, that's similar to what I did. I wanted two of the edges (left and right, say) to loop to each other. The other two I didn't.
How I solved this was by taking the last columns and copied them to the front. I also took the first columns and put them on the end. For the sides I didn't want to loop, I simply copied them and padded the top and bottom. This skews the data a little bit, but not very much, so I decided it was a fair trade.