MATLAB: Do I get different results using double or uint16 on an image

doubleimageuint16

Hi, I don't understand why I get different results using (for all I understand) same conversion/functions ?
my_image = imread('Segmented-AtriaWall-LA-162.tif');
my_image_DB = im2double(my_image);
Threshold = my_image_DB(my_image_DB>0);
Threshold2 = my_image(my_image>0);
SD = std(Th);
SD2 = std(double(Th));
SD3 = std(double(Th2));
Here is what I obtain :
my_image : 640*640 uint16
my_image-DB : 640*640 double
SD : 6.5656e-04
SD2 : 6.5656e-04
SD3 : 43.0275
Th : 1206*1 double
Th2 : 1206*1 uint16
Can someone explain the difference to me please ? I really don't get it
Regards,
U

Best Answer

You do not appear to use Threshold and Threshold2 so it is not clear what role they play.
You use variables Th and Th2 which you do not initialize in your code.
If we assume that Th is Threshold and Th2 is Threshold2, then im2double() applied to uint16 is going to divide by 2^16 because im2double scales to 0 to 1. That is going to give you a scaling of 2^16 on the std. 43.0275/2^16 gives 6.5655e-04, which differs only in the last digit from the other result.