Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted

07-11-2019 04:37 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Labels:

Dear All,

I have an 2D array and I would like to average every two values in each line.

For example an incoming array (sizeX=16,sizeY=8) will result into an outcoming array of 8x8.

I have implemented this already, but I was wondering whether you could suggest me a faster way of doing so?

In the Example below the incoming 2D array has a dimension of 768x1536 and the out coming 2D array has a dimension of 768x768.

Thanks a lot!

Solved! Go to Solution.

Highlighted
Options

Solution

Accepted by Kenai23

07-11-2019 05:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

You can try something like this if you have an even number of points in each row.

mcduff

Highlighted
Options

07-11-2019 08:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Highlighted
Options

07-11-2019 10:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

First, two comments on your description of your problem and your code:

- It is not clear if you are averaging along rows or along columns or along both or along either. Your original description says an incoming 16 x 8 array results in an 8 x 8 array (so you are averaging pairs of
__rows__), but your example says a 768 x 1536 array results in a 768 x 768 array (averaging pairs of__columns)__. Please clarify. - I was wondering about the adding of 0.5 after the average (why not use the Mean VI on the Math Palette?). Then I realized you were just doing "rounding" (which would happen automatically when you changed from Float to Integer, or you could use one of the three explicit Rounding functions from the Numeric Palette and make your intention clear).

I think McDuff's suggestion of using Decimate and Average is a good one, but (again) you need to clarify if you are combining __rows__ or __columns__ (McDuff's code combines columns, of course). And don't "hide" the rounding function.

Bob Schor

Highlighted
Options

07-22-2019 12:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks a lot for your solution. It was very helpful.