在学习matlab过程中,发现没有找到tofloat函数,于是自己在网上找到一个,测试可用:
function [out, revertclass]=tofloat(in) %tofloat convert image to floating point identity=@(x) x; tosingle=@im2single; table={ 'uint8', tosingle, @im2uint8 'uint16', tosingle, @im2uint16 'int16', tosingle, @im2int16 'logical', tosingle, @logical 'double', identity, identity 'single', identity, identity}; classIndex= find(strcmp(class( in), table(:, 1))); if isempty(classIndex) error( 'Unsupported inut image class.') end out= table{classIndex, 2}( in); revertclass= table{classIndex, 3};