LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Write File 2 (TIFF) Flips Images

Hello,

I was wondering whether someone else came across the following unexpected behavior of the IMAQ Write File 2 vi:

 

Sometimes, after rotating a Tiff image the image is saved upside down.

 

I isolated the behavior in the attached Troubleshoot Flipping Images.vi. (The VI has been taken out of context and reduced to a bare minimum to reprocuce the behavior, so no need to wonder why it is doing things the way it is doing it. In the original application, a queued up stream of frames from a camera is processed, flipped and rotated in two parallel threads, then saved in TIFF format.)

 

My observation is that if the image is flipped horizontally and rotated at angles other then 0 degrees, some of the images are saved upside down even though all the frames sent to the IMAQ Write File 2.vi are oriented correctly (see array Saved images in Troubleshoot Save Processed Frames.vi).

 

Any insight and a possible solution is greatly appreciated. Thank you in advance for your time.

 

Peter

Download All
0 Kudos
Message 1 of 4
(3,519 Views)

Does this same behavior occur with other file formats? Or only TIFF?  Also, your test code didn't work for me - I was getting a queue related error.  I would recommend stripping this away even further; your test VI should only acquire an image (or read one from file), perform a rotate, then save to file.  If that doesn't have any issues, then begin adding more functionality such as queueing and symmetrical transforms as you have now.

Cody A.
0 Kudos
Message 2 of 4
(3,495 Views)

Hello Cody A.,

Thank you for your reply and sorry for the long delay.

I observed the flipped images in both Tiff and png format. Following your instructions, I stripped the code even further and stepwise added more functionality until I observed that some of the images were flipped during saving.

Everything is fine (i.e., no flipped images) in the VIs Test 1... through Test 4a.... Once I add the queue in Test 5 Copy FlipRotate and Save 2 Loops Queue based 100x.vi, I start observing flipped images, if I have both producer loops enabled. If only one producer loop is enabled, none of the images will be flipped. Note that the "Saved Images" array does not contain any flipped images. Thus, I suspect the IMAQ Write File 2.vi to flip some of the frames.

Thanks for your help.

Peter

0 Kudos
Message 3 of 4
(3,457 Views)

It looks like you've stumbled upon an effect of one of the only non-dataflow driven elements in LabVIEW.  The IMAQ Image reference you get from the IMAQ Create function is actually a pointer to the memory location where the image is stored.  In your code, you only acquire a single image buffer for each for loop.  Since you perform some rotation and flipping on that same image reference, the same memory buffer is getting flipped and rotated on every iteration.

 

Therefore, when you actually save the image to your TIFF or PNG file, the pointer could direct LabVIEW to an image before or after all of your image manipulation, meaning you'll get some images before the flip and some after.

 

A couple ways to avoid this:

- Create an array of image references so you enqueue a different pointer each time

- Before enqueuing each image, convert it to a 2D array using IMAQ Image to Array, then convert back to IMAQ Image for saving to file

Cody A.
0 Kudos
Message 4 of 4
(3,438 Views)