LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D Max Values

I'll explain my application before my question. I am taking chunks (usually 15x15 elements, may change) of a picture (2D array, U32), each value is a 24 bit number in the standard RGB format. I find the top 25% of the chunk with the highest luminance values (0.33R+0.59G+0.11B), then average the R, G, and B values for those cells
 
My question is, what is the most efficient way to calculate the top 25% of luminance values then grab the R, G, and B values and average them? Initially I'm thinking to break out the R, G, and B values while still in a 2D array, then calculate the luminance using the 2D arrays, then takle chunks (15x15) and find the top 25% using something like the VI attached. Is there a better way to do this? I've been thinking maybe avoiding the Index Arrays for each R, G, and B by creating a 15x15 mask of 1's and 0's (1's corresponding to top 25% luminance values) then multiplying R, G, and B matrices by the mask, then use the sum operator and divide by the known number of cells int he top 25%. Any other insights? Efficiency is important here, the pictures can be 5MP.
 
Michael

Message Edited by miguelc on 09-18-2007 11:45 AM

0 Kudos
Message 1 of 4
(3,029 Views)

Here's one possibility. Unless all luminance values are unique, it won't give exactly the same result but is probably sufficient for this.

  1. Find the value of the 75. percentile luminance
  2. Average all RGB values that exceed it.

Here's a quick example (just a very rough draft, so check for bugs! Probably needs a few tweaks!).

 

 

0 Kudos
Message 2 of 4
(3,012 Views)

Thanks, this looks like a pretty good suggestion. I'll try it with some real data and get back to you on how it performed, along with some of my other ideas.

Michael

0 Kudos
Message 3 of 4
(3,003 Views)
The ideas that come to my mind really depend on the hardware side, and I have only LV 7.1, so I can't check with your vi's. Can you catch seperatly the R, G, B (also from application side), average each on it's own, and then find the 75 percentile? (Multiplication is slower than addition).
If you have dual/multicore available: use queues, LV will give you a good processor performance (equal load) and you're buffered against user interaction (switching to other applicaions).
Use the show buffer allocations for optimization.

Felix

Maybe you can post a picture, that would be best for me (and I am intersted in high performance picture processing).
0 Kudos
Message 4 of 4
(2,991 Views)