LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save 12bit image <with> imaq

Solved!
Go to solution

Following a previous question I made here, I found out that I'm able to install and use IMAQ.

 

So I can try to do what I need, that is to save a grayscale 12bit image with IMAQ.

I read somewhere here that the nearer I can go is to save it as 16bit - I hope it wont create problems in the final image...

 

anyway, this is how far I was able to go - trying to understand how IMAQ works:

problem imaq.png

 

(sorry for the confusion - the lower left part deals with it without imaq, the relevant part is to the right)

running this, I get an "error -1074396154 occurred at IMAQ WritePNGFile - possible reason(s): IMAQ Vision: the image is not large enough for the operation" 

- yet just for that reason I inserted an IMAQ SetImageSize!

 

any hint?

 

thanks for any help...

 

alessandro

0 Kudos
Message 1 of 7
(4,318 Views)
Solution
Accepted by topic author alzyx

I don't have imaq/vas/vdm installed anymore, so I'm going from memory here but

 

1) you're going to run into a lot of trouble with memory. you are creating a new image each loop iteration and never deleting it. At the very least put a destroy image after the imaq functions. The way I've always done things is to create the image once and then just re-use it before destroying it once at the end.

 

2) I think your issue may be the fact that you need to explicity set the image type to grayscale 16 on the imaq create functions, but I'm not positive

 

This article references

 

http://digital.ni.com/public.nsf/allkb/B51CCE62D00112B68625735C0000DDCF

 

these

 

http://www.ni.com/example/28120/en/

 

examples which might help you out more

Message 2 of 7
(4,295 Views)

Please do not attach pictures of your VIs, but attach the (entire) VI, itself.  What you want to do is very simple, but I can't see the "camera" functions in your code, so can't see if you are doing it right or not.

 

Some IMAQ concepts:

  • An "Image" (IMAQ Create) can be thought of as a "buffer", a memory location where Image data are stored.  You need one of these for the Camera to save the images it acquires (if you are taking videos, you may need a buffer space of multiple Images).
  • When you do an IMAQ Create, you must name the Image (it's a "rule") and also designate a standard format for it.  In your case, Grayscale (U16) sounds appropriate.
  • Almost all of the IMAQ and IMAQdx functions require one or more Images.  Functions that manipulate Images often require two, a Source and a Destination.  Passing an Image into, say, an IMAQ "Snap" function will give you "an Image in the Image Buffer" that you can visualize by routing the Image (wire) to an IMAQ Display Indicator.
  • The IMAQ Write PNG File also takes an Image and a File Path and does what you'd expect.
  • Read the Help for any function you don't understand.

Bob Schor

0 Kudos
Message 3 of 7
(4,287 Views)

 

 

thank you for your answer Bob...

I'm sorry the image bothers you - since the VI I'm working on is large, I thought it a good idea to attach the whole VI, and to include the screenshot of the problematic part. If I dont do it this way, how can I expect people to find the problem I'm having?

 

The image data arrives to "IMAQ ArrayToImage" from the ReshapeArray box, which produces the 2D array of pixels (and those I probed, the image is there all right).

 

I certainly intend to move the CreateIMAQ outside the loop as OEM_Dev suggested (thank you!), but I dont think that's the problem, since the error pops up immediately, it's not out of memory related...

Instead the prblem could be as you suggested that I didnt identify the Image Type. And damn, I knew it was probably that, because I saw it done this way in some VI, but I cannot find a way to specify it!

 

 

0 Kudos
Message 4 of 7
(4,281 Views)

... nope, it didnt work:

problem imaq 2.png

 

(the modified VI is again attached)

 

- I set the create IMAQ image outside the loop

- I intentionally created it bigger: it should be 1392x1040 - but I read about borders needed by IMAQ - so I put it at 1400x1400

- I set the type to 7 (grayscale unsigned )

 

 

... same error as before!

 

0 Kudos
Message 5 of 7
(4,273 Views)

Look at the help for array to image

 

"Image Pixels (U16) is a 2D array of unsigned 16-bit integers containing the pixel values that comprise the image. The first index corresponds to the vertical axis and the second index corresponds to the horizontal axis. The VI resizesImage to be the same size as Image Pixels. Use this input only when Image is an unsigned 16-bit image."

 

I've never needed to resize to save personally. Looking at it further, I'm wonder if you are getting errors you aren't seeing further up. Try connecting all the imaq functions with error wires and see what happens.

0 Kudos
Message 6 of 7
(4,267 Views)

sorry for my mistake - my last attempt did indeed succeed, but Labview for some reason kept giving me the old error...

I needed to arrive this morning and do a fresh restart of everything to notice that the error is gone, and the images are saved!

 

So I'd say that what saved the day was correctly set the image type (7 for grayscale U16) - not even the resize was necessary!

 

The images are good grayscale 16 bit instead of 12, but it doesnt matter.

 

thank you all...

 

alessandro

0 Kudos
Message 7 of 7
(4,236 Views)