# LabVIEW

cancel
Showing results 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

Message 1 of 9
(2,163 Views)

## Re: Can I improve my implementation of 2D LUT?

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

Message 2 of 9
(2,129 Views)

## Re: Can I improve my implementation of 2D LUT?

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

Message 3 of 9
(2,106 Views)

## Re: Can I improve my implementation of 2D LUT?

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

/Y

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 4 of 9
(2,095 Views)

## Re: Can I improve my implementation of 2D LUT?

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.

Message 5 of 9
(2,078 Views)

## Re: Can I improve my implementation of 2D LUT?

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

Message 6 of 9
(2,060 Views)

## Re: Can I improve my implementation of 2D LUT?

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

Message 7 of 9
(2,048 Views)

## Re: Can I improve my implementation of 2D LUT?

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

Message 8 of 9
(2,025 Views)

Hi ,