Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayToImage not producing an Image

I'm writing a VI to evaluate max value of each 2x2 block of pixels in an image and output an image comprised of the resulting 1x1 evaluations. The issue is ArrayToImage is outputting a blank image (no pixels). I'm using IMAQ Block Statistics to evaluate the input image and combining the resulting array with Reshape Array. The matrix incoming to the ArrayToImage block are correct after some spot checking with probes and I've tried using a source image of the final image resolution to no avail.

0 Kudos
Message 1 of 4
(2,200 Views)

This is a "Matlab way" to write the code. the result matrix should be smaller then the original image. 

Number of blocks in your case is Width / 2 x High / 2.

You need to allocate a target buffer and write the result image to the target buffer.

On another notes.

If the same calculation can be done by running filters it would run the code more efficient. For example to calculate the mean in 2x2 you can run averaging filter of 2x2 and then run IMAQ extract to extract the raw / columns of interest. 

This code will run much faster and more efficient.

Image to Array usually use a lot of memory that is not released. Could be an issue on large image.

 

 

Amit Shachaf
0 Kudos
Message 2 of 4
(2,189 Views)

Amit, thanks for the reply and the note on efficiency. Is there a way to know where data is being addressed? So far I only know to use the probe tool for debugging but it only showing the node data without an address.

0 Kudos
Message 3 of 4
(2,158 Views)

Be sure that your destination image is Float-point (SGL).

It works in such way:

Screenshot 2019-01-17 18.06.58.jpg

Doing this with array is not very efficient way as mentioned above (but it depends from size and your performance requirements).

 

with best regards,

 

Andrey.

 

0 Kudos
Message 4 of 4
(2,154 Views)