Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Block Statistics - NaN for Standard Deviation for U16 image data

Hi Folks -

 

I am getting a lot of NaN values for standard deviation using the IMAQ Block Statistics function when I have U16 image data. The Mean Value is computing just fine.

 

Not seeing this problem with U8 data, and conversion of U16 image to 2-d array followed by using LabVIEW Std Deviation and Variance.vi works just fine.

 

Anyone else run into this? It may be a bug that needs to be corrected.

 

Don

0 Kudos
Message 1 of 9
(3,795 Views)

Here is a little bit more detail on what I am doing:

 

Block Statistics.PNG

 

I am using the whole U16 image as the block.  I have about 3M points in the image (~ 1700 x 1700). I am pretty sure there is some overflow that must be occurring during the calculation of standard deviation.

0 Kudos
Message 2 of 9
(3,786 Views)

What version of LabVIEW are you using?  There were some issues with U16 images and standard deviation calculations in previous versions, but they should have all been fixed in 2011. It is still possible that there is a bug in the calculation though.  If the U16 values are being saved in another format before the standard deviation calculation is made, then we may be coming up with a negative number somehow and trying to take the square root of it.  That's about the only thing I can think of that would lead to the NaN result.  Could you please attach one of the image files you are using and I will try and duplicate it on my end.  If it is a bug then I will file a CAR (corrective action report) on it and submit it to R&D.

Regards,

Chris L
Applications Engineer
National Instruments

Certified LabVIEW Associate Developer
0 Kudos
Message 3 of 9
(3,777 Views)

This is Vision 2011, the latest version (although I am using 64-bit version).

 

The image is too large to attach.  I will put it in the ftp://ftp.ni.com/incoming with the same name as you see in the path constant below.

 

Here is a VI to read it.  The workaround is to convert to SGL Float image.  Then the standard deviation computes fine.  if you pull out the Cast function, you will get a NaN for standard deviation.

 

Block Statistics.PNG

 

 

0 Kudos
Message 4 of 9
(3,772 Views)

Don,

 

I have been able to reproduce the same behavior you are seeing.  I am going to speak with one of our R&D engineers about this, because it was my understanding that all of the bugs related to the standard deviation calculations had been fixed in 2011.  I will post an update when I have more information for you.  Thank you for bringing this to our attention.

Regards,

Chris L
Applications Engineer
National Instruments

Certified LabVIEW Associate Developer
0 Kudos
Message 5 of 9
(3,762 Views)

Chris -

 

Thanks.   I think you have similar issues related to U8/U16 vs. SGL for the IMAQ Unwrapper function.

 

Take a look at this thread

 

http://forums.ni.com/t5/Machine-Vision/Subpixel-image-shift/m-p/1793610#M33755

 

particulary the last post after I converted to SGL which finally gave me the correct image.

 

Sincerely,

 

Don

0 Kudos
Message 6 of 9
(3,756 Views)

Don,

 

I was able to confirm that this is a bug in the IMAQ Block Statistics.VI.  From what it looks like, the data needs to be converted to 32 bit before the standard deviation calculation is made.  If not, then it gets converted halfway through the calculation and the VI tries to take the square root of a negative number, resulting in the not a number result.  I'm going to put together a very simple VI based off of what you sent me and file a corrective action report (CAR) on this issue.  Once I have done this I will post both the CAR number and the VI to this forum. 

Regards,

Chris L
Applications Engineer
National Instruments

Certified LabVIEW Associate Developer
0 Kudos
Message 7 of 9
(3,739 Views)

Don,

 

I have filed a CAR with R&D under request number 327954.  Attached is the VI I sent R&D which will allow them to duplicate this issue.  This issue applies to both supported image types (BMP, JPG, TIF, PNG, etc) and un-supported types such as your .rec file.  I have also made R&D aware of the workaround you came up with so we can provide a solution to others facing this same problem.  Thank you for being such an active member of our online community and providing great feedback to other forum users as well as back to us hear at NI.  We really do appreciate it.

Regards,

Chris L
Applications Engineer
National Instruments

Certified LabVIEW Associate Developer
0 Kudos
Message 8 of 9
(3,732 Views)
Thanks for your attention to this. I hope you can also address the analogous situation with the Imaq Unwrap function.

Don
0 Kudos
Message 9 of 9
(3,730 Views)