取消
显示结果 
搜索替代 
您的意思是: 

Anyone know how to fill an array faster?

已解决!
转到解答

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 项奖励
1 条消息(共 17 条)
4,552 次查看

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????

 

 

2 条消息(共 17 条)
4,537 次查看

Well you could start by calling the histogram function ONCE with a 2D array input.眨眼表情  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 项奖励
3 条消息(共 17 条)
4,531 次查看
解答
接受人 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 项奖励
4 条消息(共 17 条)
4,512 次查看

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 项奖励
5 条消息(共 17 条)
4,509 次查看

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 项奖励
6 条消息(共 17 条)
4,508 次查看

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

0 项奖励
7 条消息(共 17 条)
4,488 次查看

try this (LabVIEW 8.2)

 

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

8 条消息(共 17 条)
4,484 次查看

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 项奖励
9 条消息(共 17 条)
4,481 次查看

@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 项奖励
10 条消息(共 17 条)
4,475 次查看