MATLAB: Mask

Image Processing ToolboxmaskMATLAB

I have a image which is uint16, when I take an 'imrect' and create a mask I loose the range of pixel values. They change from 0-65535 to 0-1. How do I specify when creating the mask that it is not binary?
H =imrect;
mask = H.createMask();
rect = uint16(mask);
D = sqrt(0.5);
Dev = std2(rect);
RMS = Dev/D;
Mean = mean2(rect);}
Thanks

Best Answer

A "mask" is binary in Matlab. It is the mask only! If you want to get the pixel values inside the mask, you either multiply the mask with the image matrix (size remians the same) or use the mask for indexing (result is the masked rectangle only).
Please post your code and explain, what you want to achieve.