11-28-2011 12:36 PM
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
11-29-2011 07:37 AM - edited 11-29-2011 07:38 AM
Here is a little bit more detail on what I am doing:
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.
11-29-2011 05:27 PM
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.
11-30-2011 09:09 AM
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.
12-01-2011 04:48 PM
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.
12-02-2011 06:02 AM
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
12-05-2011 03:12 PM
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.
12-06-2011 10:14 AM
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.
12-06-2011 10:18 AM