Jump to content

IMAQ image pixel pointer to array


bna08

Recommended Posts

I have an IMAQ image and I obtain the address of its pixels via IMAQ GetImagePixelPtr VI (see below). This address is passed to my .NET DLL which copies the pixel values to memory area starting at this address. 

Afterwards, I can access the IMAQ image directly in LabVIEW. However, I also want to access the image pixel values for direct processing. This could be achieved by calling IMAQ ImageToArray VI which is unfortunately quite slow (around 5-10ms on my 12-core Xeon CPU). Since we already have the pixel pointer address provided by GetImagePixelPtr VI, is there any way how this address could be cast directly to a LabVIEW array? 

Basically, I want to be able to convert (cast) this address to a LabVIEW array of UNS16:

image.png.57c5c6700b7d680819309e2caa317ede.png

 

Is there any way how it could be done? I would like to avoid copying the values in any way which is what IMAQ ImageToArray does.

 

EDIT: I am starting to realize that LabVIEW array is not really just a plain array of bytes/shorts etc. but a more complex data structure (holding the information about the array length etc.). Thus, simple C/C++ array pointer casting to a LabVIEW array is not possible. Am I correct? 

Edited by bna08
Link to comment
24 minutes ago, dadreamer said:

If you are using VDM, you should already have the basic example on how to manipulate the IMAQ image in a shared library: IMAQ GetImagePixelPtr Example Don't know, if you will gain anything in terms of performance, but worth a try at least.

This is what I am actually doing already. The question is if IMAQ Image pixels pointed to by the pointer obtained from IMAQ GetImagePixelPtr can be cast to a LabVIEW array.

Link to comment

I'm afraid, no way around that. I mean, without A LOT of low-level hackery. IMAQ images have borders 3 pixels wide by default, whereas LabVIEW arrays don't have those. And not every VI from the Array palette works in-place, not producing a copy. Of course, you may read/write pixels data by its pointer using MoveBlock. Like this:

2023-04-19_21-00-21.jpg.0013634d54c82c9d73aaf6d2c3fbb624.jpg

2023-04-19_21-00-46.jpg.b824d1b5626b15879cf68e561cd33438.jpg

But I wouldn't expect more than that. You can always move the image processing into your DLL/SO and write everything in pure C/C++, C# et cetera.

  • Thanks 1
Link to comment
  • 2 weeks later...
On 4/19/2023 at 3:55 PM, bna08 said:

This is what I am actually doing already. The question is if IMAQ Image pixels pointed to by the pointer obtained from IMAQ GetImagePixelPtr can be cast to a LabVIEW array.

Daddreamer is correct. An IMAQ image is NOT a LabVIEW array, not even by a very very long stretch. There is simply no way to treat it as such without copying the data around anyhow!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.