10-31-2017 02:21 AM
Hi,
I have written a small code that works kind of like a 2D look up table. There is a 2D array of size 255*255 which holds the values. I have 2 input array of size 150*150(each is a 2D)- Array 1 and Array 2. The value of the elements are in the range of 0 - 255. I am attaching my implementation of it. Is there a better way to implement it?
Thanks!
Aveo
10-31-2017 04:42 AM
The best optimizations are algorithmic.
It all depends on the exact situation. In your benchmark, you can precalculate the convolution matrix. That speeds up to 20% of the original. It depends on the situation if this is a fair comparison, the precalculation might be dynamic. But if the input arrays are small, it will be a slow down...
And obviously, you can do the subtract outside the loop.
If you make it a subVI, turn debugging off. Might even try if inlining helps. There are downsides to both (no debugging, no profiling).
10-31-2017 08:10 AM
I can see what you are doing, but the fact that you are asking the question makes me want to ask, "What do you want to do"? You have a square array of 255 (not 256!) entries, all 1.000, and two other (smaller) arrays, also holding Dbls. What do the two Input Arrays represent, what does the LUT Array represent, and what kind of processing do you want to do with these three arrays?
Does this have anything to do with Imaging? Might there be optimized functions in one of the LabVIEW Modules or Toolkits that "do what you are trying to do"?
Bob Schor
10-31-2017 09:09 AM
By parallellizing the outer loop (not the 1000x one) i lowered from 0,8s to 0,3s.
/Y
10-31-2017 12:06 PM
Isn't this just where Variant Attributes can be used? With the updates in the IPE structure you can probably also get some more efficient read/write operations on variants too.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-31-2017 01:45 PM
Variant attributes are a lot faster then a linear search, but array indexing is still a lot faster.
10-31-2017 02:56 PM
I think the parallel for loop trick and the precalculation trick can be combined.
How fast so you need it to be? There is a limit, and you might be getting close...
At some point a system upgrade will be cheaper then the development time...
11-01-2017 04:17 AM
Hi Bob Schor,
Thank you for the reply. You are right Sir, I am working with images. Let me explain what I am doing. I need to find whether a pixel in an image is defect or not depending on its color information(saturation and intensity). I first read a few images and select the good pixels, then read their saturation and intensity values. Lets say the saturation and intensity values for a pixel is 100,57. I put a 1 in the [100,57] location of the 2D look up table that I have created. My 2D look up table will have 256 rows and 256 column(my mistake i had put 255 in the example program). So the LUT will contain either 1 or 0.
The two smaller 2D array represent the saturation and intensity values of a test image. They will contain values in the range of 0-255. I index out the saturation and intensity at each pixel and compare its value with the look up table in a 3X3 window.
I went through the Vision Development module- there is a vi called IMAQ ColorUserLookup, however, it applies a LUT on each plane individually. My requirement is to perform LUT based on two planes. I hope I have explained it better now. Do let me know if there are any more questions.
Regards
Aveo
11-01-2017 04:23 AM
Hi Yamaeda,
Thank you for the reply.
This vi will be inside another loop which will run for several times. Is it alright to parallelize one loop inside another?
Regards
Aveo