10-11-2012 12:29 PM
At a point in my program I want to make a 1D array of arrayelements selected from a 2d array input.
When i run my program now you just get one ellement in my indicator, but I need to get all the elements stored in an array so I can work on whit this 1D array...
Vi will show my problem..
Solved! Go to Solution.
10-11-2012 12:34 PM
(Posting by phone, cannot see your code)
To get a row or column from a 2D array, use "index array" with one index unwired.
10-11-2012 12:45 PM - edited 10-11-2012 01:01 PM
It looks like you're trying to get all the elements in each 3x3 section of the larger array? Is that right?
Anyway, your reshape array (with size = row x column) after your array subset will give you all 9 elements. I have no idea what you're trying to accomplish indexing index 5 from the array. (indexing a 1d array is going to give you a scalar every time)
Aside: Why aren't you using auto indexing, instead of wiring 255 to N? Why are you using 255 if your arrays are 256x256?
10-11-2012 12:54 PM - edited 10-11-2012 01:03 PM
use reshape array and # of elements for dimension size..in your case 2D of 255x255 and a 1D reshape of 65025 # of elements. you were almost there...i re modded your vi.
10-11-2012 01:09 PM - edited 10-11-2012 01:11 PM
Seems you want to get a list of all medians from all 3x3 subsections.
First of all, your output array should probably be slightly smaller, because there are only 254 3x3 section in each dimensions.
Since you know the size of the final 1D array, you should initialize a 1D array of the correct size, then replace elements in the order they are generated. Here's a simple example (LV 2010):
10-11-2012 03:00 PM - edited 10-11-2012 05:39 PM
Note that my above code cannot be parallelized because the shift register configuration is not a know reduction.
Quote from "tools...find parallelizable loops":
This For Loop is not safe to parallelize. Error(s):
- The iterations of the For Loop may depend on each other through Shift Registers, and the computation is not a recognized reduction.
- Multiple iterations of the For Loop may access the same array element, and at least one access may write to the element.
A simple change (see below) allows full parallelization of both loops (I only recommend to parallelize the outermost loop for obvious reasons ;)). This will speed up your code proportional to the number of CPU cores in your hardware.
10-11-2012 04:52 PM
Indeed, I want to get the medians of the 3-3 array bloks of my input array.
I indeed also have a few other problems ready to solve in connection with the smaller sizes,..
Hopefully I will find them.
Great guys, my problem is temporarily solved, ready to move on!
Appreciate you quickly help!