MATLAB: How to change an array from grayscale to binary

arraysimage processingImage Processing Toolboxthresholdingtypes

I have a 2D array representing a grayscale image. This array is stored as doubles. When I try to use the function im2bw on the array stored as a double, I get a completely white image regardless of the threshold value. The documentation says the function accepts doubles as input. When I typecast the array to uint8 by calling converted_array = uint8(array), the im2bw function works properly.
Problem is that I'm using LabVIEW to create the 2D array and even if I typecast it in LabVIEW, MATLAB still sees the array as doubles.
Am I missing something when I'm using the im2bw function? How can I get it to work with doubles?
Edit: Some sample data from the doubles array
4294967295.00000 4278124286.00000 4210752250.00000 4278124286.00000 4210752250.00000 4294967295.00000 4244438268.00000 4193909241.00000 4261281277.00000 4294967295.00000 4278124286.00000 4294967295.00000 4193909241.00000 4294967295.00000 4294967295.00000 4278124286.00000
What the data looks like after LabVIEW converts it to U8:
255 254 250 254 250 255 251 249 253 255 255 255 249 255 255 255

Best Answer

Try
array8 = uint8(255 * mat2gray(array));
if you want a uint8 array in the range 0-255.