LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scale/Bin a 2-D Array

Highlighted
Has anyone scaled or binned a 2-D array before?  If so, could you give some information on your method?
 
Example of problem:
                                    initial array                 scaled array (skipped every other)
scale array by 50%:    1   1   2   2                   1   2
                                    1   1   2   2                   3   4
                                    3   3   4   4
                                    3   3   4   4
 
                                    initial array                 binned array (averaged in quads)
bin by 2 array:             1   2   2   3                   2.5   3.5
                                    3   4   4   5                   4.5   5.5
                                    3   4   4   5
                                    5   6   6   7
 
Thanks!
0 Kudos
Message 1 of 7
(1,228 Views)

You could probably use the image resizing VI found here for the scaling (note that it gets slow for large arrays).

For the averaging, you can probably do something similar to what I demonstrated in the "Test.vi" in the attachment here.


___________________
Try to take over the world!
0 Kudos
Message 2 of 7
(1,218 Views)

2D bin data.png

 

"Decimate (single shot).vi" will give you a binning in one dimension if you set the "averaging" to TRUE. So you can run this on all of the rows, then on the resultant columns.

0 Kudos
Message 3 of 7
(201 Views)

(Wow, this was an very old thread (>>10 years!)  you revived here! :D)

 

Here's what I would probably do (but probably more scalable so a reduction factor is an input and sanity checks are performed if the input sizes are not correctly divisible).

 

DecimateOrAverage2D.png


LabVIEW Champion. It all comes together in GCentral GCentral
Message 4 of 7
(187 Views)

I like your solution.  Should be faster.

0 Kudos
Message 5 of 7
(149 Views)

@D* wrote:

 

"Decimate (single shot).vi" will give you a binning in one dimension if you set the "averaging" to TRUE. So you can run this on all of the rows, then on the resultant columns.


scale_binning_2d-array.png

For the "Input bin" and averaging=false you will get the same result, as for averaging=true.

 

But, for the "Input averaging" and averaging=false you will get different results.

 

 

0 Kudos
Message 6 of 7
(137 Views)
0 Kudos
Message 7 of 7
(137 Views)