01-11-2022 03:00 PM
Hello,
I use AI channel to get a series DAQ data in the while loop and it can produce 1D array. I need to combine those dynamic1D array into an 2D image. Is there any way to do it without loosing much speed?
I used to initialized a 1000 by 1000 zero array and filled it point by point. The system could not catch up with it.
So I am now trying to fill an image line by line.
Thank you very much
Best regards
Yu
Solved! Go to Solution.
01-11-2022 04:40 PM
Try it out with the input of your 1D array and outputting a 2D array (drag it down to make it have 2 inputs for dimensions).
You may need to transpose the 2D output or reverse the lines or columns depending on the orientation of the data coming in to the array, but it should be faster than point-by-point.
01-11-2022 06:37 PM
I recommend to go back to the basic tutorials because most of your code makes no sense at all.
At this point I would recommend to create a simple simulation of your inner FOR loop that generates random data and fills the array (all sized to the real code!). Leave the hardware out of it. See how far you get.
01-12-2022 04:06 AM
Hello,
The array size I initialized could be changed at image size on the front panel. The saved default number is recorded as 500. When run the code, I would change it at 1000.
Shall I switch the measurement to 'Analog/Single Channel/Single Sample/DBL'? I only have one channel for analog input but many samples.
When I take several samples from the signal, I can only get one nonzero data. The rest of data was shown as zero no matter how many sample I take. So I just take one data. Is there any way to solve it?
Thank you very much
Best regards
01-12-2022 04:08 AM
Thank you
I tried the reshape function with simulated data that I generated with random numbers.
But I found if I set the image size 1000 by 1000, the code response was very very slow.
Is there any way to speed up the calculation?
Thank you very much
Best regards
01-12-2022 10:03 AM
If you want all elements of a 1000x1000 2D array, the 1D array needs to have 1M elements before reshaping. reshaping should only happen once all data is acquired.
You are not doing any "calculations" just rearranging in memory. (... and possibly thrashing memory!)
Once you can post a simple simulation as requested, we can help you. Currently, the information is way too ambiguous.
01-12-2022 10:31 AM
@Rhapsody16 wrote:
When I take several samples from the signal, I can only get one nonzero data. The rest of data was shown as zero no matter how many sample I take. So I just take one data. Is there any way to solve it?
If you only get one point per acquisition and want more than one, something is misconfigured (sorry, I don't have any drivers installed and I don't have your hardware).
If you only get one point per iteration, just autoindex to create a 1M size 1D array that you then reshape to 1000x1000. No need to jump through all these flaming hoops!
Here's one possibility (and it is nearly instantaneous!):
01-12-2022 10:36 AM
Thank you very much
Let me do the simulation data first
Best regards