05-01-2017 11:43 AM
I'm altering/adding to LabVIEW code used to save/view images obtained by a camera. The system's design is such that one of the processing steps for the produced images requires the subtraction of two separate images. Normally this is done by hand out of LabVIEW, in Matlab, but I wanted to incorporate it into LabVIEW to save some time.
I did some research and it seems like shift registers are/were my best bet, but I'm having some trouble understanding them. I've attached an example snippet (just a .png; no code snippet--the whole program is kind of a bird's nest, not accounting for my modifications.)
Let's say I have a set of images labeled 1 2 3 4 5 6 and need to subtract such that my new images are 1-2, 3-4, 5-6.
Shift registers only retain a value b/t loops until overwritten, right? So if I implemented a shift register to do the above steps, my images would be 1-2, 2-3, 3-4, 4-5, 5-6?
If this is truly the case, is there a way to toss out every other image generated here? This is intended to be a near real time playback, so I'd prefer to not have those images displayed--they won't contain anything of value to me.
On the other hand, is there a better method doing this sort of thing? These arrays are kind of big (2048 x 2048, 16 bit values.) I've tried simply saving the images and then doing the subtraction with a matlab node but the node takes ages to get going.
Solved! Go to Solution.
05-01-2017 12:13 PM - edited 05-01-2017 12:15 PM
Shift registers are your "best bet". You just need another one that has an alternating boolean. Every other iteration, subtract the arrays and pass the result into a conditional auto-indexed tunnel. On the opposite iterations, do nothing except pass the image thru to the shift register.
Edit: There are other methods using producer/consumer that may actually be better so that your subtraction is done in a different process from your acquisition.
05-01-2017 01:29 PM
Do I actually need a second set of registers for the arrays? Or would something like the attached picture work? The false value in that case structure is simply empty so that when an image is in the shift register but has been used in a subtraction, it's just not displayed.
Thanks for your feedback!
05-01-2017 01:36 PM - edited 05-01-2017 01:37 PM
You can re-size shift registers by just dragging down on it. It will keep values from iteration...
i-1, i-2, i-3...
There is also the option of a fixed-sized queue and using "Preview queue" to get at the elements.
Ben
05-01-2017 01:37 PM
You're almost there. The output tunnel for the arrays will still include an extra entry for when the boolean is false, which you presumably don't want. Right click the output tunnel and set it to be a conditional tunnel and use your boolean to tell it when to index a value (only on TRUE).
05-01-2017 01:44 PM
So I would simply just wire that conditional output to what controls the case structure? When turned conditional, the output tunnel by default only works on true, correct?
05-01-2017 01:46 PM
@vomojo wrote:
So I would simply just wire that conditional output to what controls the case structure? When turned conditional, the output tunnel by default only works on true, correct?
Correct.
05-01-2017 01:49 PM
Alright. Thanks for your help!
05-01-2017 02:50 PM - edited 05-01-2017 02:59 PM
Instead of the boolean and associated shift register, etc., You could just check if the iteration terminal is odd.
You could also do a stacked loop with an inner FOR loop fixed at two iterations and containing the acquisition. You'll get two arrays out which you can unconditionally subtract in the outer loop:
05-01-2017 03:11 PM
Wouldn't two iterations of the inner loop result in a (first image - nothing) and (2nd -1st)? I assume I'd have to add that odd iteration check you mentioned?
Thanks!