LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimating 2D array

I am using LV 8.2, XP and would like to decimate a 2D array keeping only the odd or even columns.  I have read a couple of posts that instruct a lot of 1D decimation but was wondering how to implement this in a 2D array.  Is it possible to do this without the use of For loops?

Thanks,

Azazal
Azazel

Pentium 4, 3.6GHz, 2 GB Ram, Labview 8.5, Windows XP, PXI-5122, PCI-6259, PCI-6115
0 Kudos
Message 1 of 7
(6,325 Views)
What's wrong with FOR loops??? 😉
 
Sure there are loop-free versions, especially if the number of columns is an even number. Is it?
0 Kudos
Message 2 of 7
(6,320 Views)
Nothing is wrong with For loopsSmiley Very Happy, but my arrays are large and I have read that for loops can be computationally expensive.  So I was hoping not to use them, but I haven't been able to come up with a solution without them and was hoping one of you experts had a clever/simple solution.  Yes the number of columns will always be even.

Azazal

Message Edited by Azazel on 02-09-2007 10:26 AM

Azazel

Pentium 4, 3.6GHz, 2 GB Ram, Labview 8.5, Windows XP, PXI-5122, PCI-6259, PCI-6115
0 Kudos
Message 3 of 7
(6,316 Views)
For loops are NOT computationally expensive if you make sure that arrays don't get resized at each iteration. In this case you know the size of the final array beforehand, so everything can be done in-place. Very efficient. even the loop-free tools need to loop over the elements one way on another.
 
Anyway, here is a loop-free© version that requires that you have an even number of columns. 🙂
 
 
 

Message Edited by altenbach on 02-09-2007 08:35 AM

Message 4 of 7
(6,313 Views)
Sorry, the indicators shold of course be labeled odd/even Columns. 😉
0 Kudos
Message 5 of 7
(6,306 Views)

One little FYI to consider either now or for future reference:  The way the elements of a 2D array are stored in physical memory is like this:

| Elements 0-n of Row 0 | Elements 0-n of Row 1 | Elements 0-n of Row 2...

Individual rows already represent contiguous chunks of memory, which allows LabVIEW the opportunity to optimize row-wise operations in many cases.  Column-wise processing will require that element values get copied over into an independent chunk of memory, which can become dramatically less optimal.

Personally, I've sometimes found it better to transpose the 2D array first so that subsequent processing can be performed in the more efficient row-wise fashion, including the ability to auto-index 1 row at a time with a For loop.  The transpose operation is performed in-place without requiring a new memory buffer.

-Kevin P.

 

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 7
(6,297 Views)
Hello Kevin,

I came across your post and this sounds like a great idea but I am having some trouble creating a .vi to do this, do you have any sample .vi's that decimate the rows as you mentioned using the for loop?

Thanks,

Azazal
Azazel

Pentium 4, 3.6GHz, 2 GB Ram, Labview 8.5, Windows XP, PXI-5122, PCI-6259, PCI-6115
0 Kudos
Message 7 of 7
(6,046 Views)