LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Anyone know how to fill an array faster?

Solved!
Go to solution

Hey everyone,

 

I created a program which displays an intensity graph, as well as a histogram of the intensity values on a 1024x1024 chip (X-Y dimension). Currently, the program works fine, but the histogram takes FOREVER to complete, and I was wondering if there's a way to increase the speed of this while including all of the 1024x1024=1048576 data points. Thanks!

0 Kudos
Message 1 of 17
(3,604 Views)

Please attach the actual VI. A code image is pretty useless.

 

Keep the histogram in a shift register as a 1D array of a sufficient number of elements. In any case, try to autonidex over the 2D array using two stacked FOR loops and built the histogram using the inplace element structure and using the value (Or something derived from it) as index. How many bins do you want? Your values are U16, so using a histogram with 2^16 elements is not out of the question.

 

Also don't use express VIs and don't update the graph with every iteration of the inner loop. Indicators belong after the FOR loops.

 

Your current shift registers are useless. You get the same value from the iteration terminal, right?

 

Why do you reset the histogram at the last iteration of the outer loop, throwing away all data processed until then????

 

 

Message 2 of 17
(3,589 Views)

Well you could start by calling the histogram function ONCE with a 2D array input.Smiley Wink  getting the data from the image pixel by pixel (and then not wiring it to the histogram) is probably the hard way around the problem.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 17
(3,583 Views)
Solution
Accepted by BoilerUp81

I realize filling the array pixel by pixel is not the best route, but I am unsure as to how to take the 2-D array and use the intensity from each (x,y) point in a histogram.

 

Thanks, for pointing out that I don't need to call the histogram function every time (rookie mistake), but like I said, I am still unsure as to how to put the 2-D array into the histogram.

 

And I reset the histogram after it finishes filling because I need it to reset to see the changes for when I change the camera exposure time (if necessary). I have also attached my code.

0 Kudos
Message 4 of 17
(3,564 Views)

Also if I can use the 2-D array, then there is no need for the FOR loops, and I can just use the getarray.vi

0 Kudos
Message 5 of 17
(3,561 Views)

BoilerUp81 wrote:

And I reset the histogram after it finishes filling because I need it to reset to see the changes for when I change the camera exposure time (if necessary). I have also attached my code.



Please run your code until the "Image display" contains data. Stop the VI, right click the "image display" terminal and select "change to constant". Save (under a new name) and attach the VI once more. This way we have some typical data to work with. 

0 Kudos
Message 6 of 17
(3,560 Views)

I hope this is what you're looking for, I appreciate the help

0 Kudos
Message 7 of 17
(3,540 Views)

try this (LabVIEW 8.2)

 

(sorry, no in place element structure, here is a better downconversion)

Message 8 of 17
(3,536 Views)

The while loop can be removed to speed it up even more (no optomizer to remove it from the compiled code in 8.2)


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 17
(3,533 Views)

@Jeff Bohrer wrote:

The while loop can be removed to speed it up even more (no optomizer to remove it from the compiled code in 8.2)



I already uploaded a corrected version. (Forgot about the in place element structure missing from 8.2)

0 Kudos
Message 10 of 17
(3,527 Views)