02-17-2009 10:18 AM
Hello everyone,
I am trying to write code that gives the brightest pixel per row of an image and set that to 255, and all others to 0. I have code that does this, but it is extremely slow(260 - 300 ms per frame!). The way I have done it is to change it to an array and do a couple for loops with some logic.... I was hoping for some suggestions for a better way. I have tried the threshold vi with a small range, but it will set all the pixels in the that range to white, not just the first brightest pixel. Any ideas?
Thank you
Matt
Solved! Go to Solution.
02-17-2009 10:50 AM - edited 02-17-2009 10:51 AM
Hi Matt,
you say you changed the data to an array. In which form is your original data?
Once you have an array (2D I guess) you could just loop through the rows and for each row use the Min/Max, multiply the array with 0 and set the pixel at the Max index to 255. See image.
Hope this helps,
Daniel
02-17-2009 11:16 AM
See Attachment. Last one is quickest
02-17-2009 11:19 AM
@JCC: nice examples, I also thought about in place operations. But your examples don't set all other values (except for the max) to 0.
02-17-2009 12:15 PM
You could initialize another array with all zeros and replace the appropriate elements of that with 255. This means having space allocated for two arrays in memory, but that did not seem to be a problem since some versions probably had at least two copies anyway.
Lynn
02-19-2009 12:02 AM
Dan,
Thanks a lot!! That was a very simple and effective way to do this. I have to make it more complicated, but at least you got me started. I was doing it in a far less effiecient way. You rule!
Matt
02-19-2009 02:03 AM
Matt,
I'm glad I could help. Happy wiring!
Daniel
02-19-2009 02:29 AM
This is faster!!!
Try this 🙂
02-20-2009 02:29 PM
What is that big one? Is that something in 8.6? I have 8.2, so that is totally alien to me. wish I knew.
Matt
02-21-2009 04:41 PM