# LabVIEW

cancel
Showing results for
Did you mean:

## Scale/Bin a 2-D Array

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!
Message 1 of 7
(1,229 Views)

## Re: Scale/Bin a 2-D Array

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!
Message 2 of 7
(1,219 Views)

## Re: Scale/Bin a 2-D Array

"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.

Message 3 of 7
(202 Views)

## Re: Scale/Bin a 2-D Array

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

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

## Re: Scale/Bin a 2-D Array

I like your solution.  Should be faster.

Message 5 of 7
(150 Views)

## Re: Scale/Bin a 2-D Array

@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.

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.

Message 6 of 7
(138 Views)

Message 7 of 7
(138 Views)