LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I improve my implementation of 2D LUT?

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

0 Kudos
Message 1 of 9
(2,156 Views)

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).

0 Kudos
Message 2 of 9
(2,122 Views)

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

0 Kudos
Message 3 of 9
(2,099 Views)

By parallellizing the outer loop (not the 1000x one) i lowered from 0,8s to 0,3s.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(2,088 Views)

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.

0 Kudos
Message 5 of 9
(2,071 Views)

Variant attributes are a lot faster then a linear search, but array indexing is still a lot faster.

Message 6 of 9
(2,053 Views)

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

0 Kudos
Message 7 of 9
(2,041 Views)

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

0 Kudos
Message 8 of 9
(2,018 Views)

Hi ,

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

0 Kudos
Message 9 of 9
(2,014 Views)