MATLAB Answers

can any one tell me how to convert an image of type 'unit8' to the image of type 'float'.basicaly i am following a book of 'Digial Image Processing Using Matlab' where they try to enhance a gray image .following is the code.thanks in advance

34 views (last 30 days)
%as we get only a possitve image so he first try to convert the image type from 'unit8'to 'float'.so he write like this%
%at here i am getting an error as [UNDEFINED FUNCTION OR METHOD 'tofloat' FOR INPUT ARGUMENTS OF TYPE 'unit8'].at this stage i could not understand what to do.%
%forther code is writen like this %
%then he subtract the images like%

Accepted Answer

Walter Roberson
Walter Roberson on 10 Mar 2013
f2 = single(f); %if you want the data type that is most commonly called "float"
f2 = double(f); %if you want the "natural" floating point data type
f2 = im2double(f); %if you also want the uint8 values rescaled to 0-1 range
Image Analyst
Image Analyst on 12 Mar 2013
Do nothing. It's just saying that it's zooming your picture so that it will fit onto your screen and you can see the whole image instead of just a small part of it. Don't worry about it. If you want, you can suppress the warning with this code:
% Turn off this warning "Warning: Image is too big to fit on screen; displaying at 33% "
% To set the warning state, you must first know the message identifier for the one warning you want to enable.
% Query the last warning to acquire the identifier. For example:
% warnStruct = warning('query', 'last');
% messageID = warnStruct.identifier
% messageID =
% MATLAB:Images:initSize:adjustingMag
warning('off', 'Images:initSize:adjustingMag');

Sign in to comment.

More Answers (3)

Steve Eddins
Steve Eddins on 11 Mar 2013
tofloat is a function provided with the book you are reading. You can find it in Appendix C on page 806.

Sign in to comment.

Kiranraddi morab
Kiranraddi morab on 13 Mar 2013
hello sir i'm too getting the same error how to use [f,revertclass]=tofloat(f)... Undefined function 'tofloat' for input arguments of type 'uint8'. MATLAB has this function or what is the problem please help me out

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by