How to use tofloat ?

When I use this code: g=abs(imfilter(tofloat(gray),w));
This error is shown: Undefined function 'tofloat' for input arguments of type 'uint8'.
Then this suggestion appears: Did you mean: >> g=abs(imfilter(float(gray),w));
When I try to apply this, then also there is an error which goes as: Error using float (line 46) The input argument to float was not a supported type. The only recognized strings are 'single' and 'double'. The input type was 'uint8'.

3 comentarios

Amrinder Brar
Amrinder Brar el 29 de Mzo. de 2015
Can anybody please answer ? I need it ASAP.
Star Strider
Star Strider el 29 de Mzo. de 2015
If you want to convert a uint8 variable to double-precision (floating point) variable, use the double function.
Stephen23
Stephen23 el 30 de Mzo. de 2015
Editada: Stephen23 el 30 de Mzo. de 2015
MATLAB supports two (industry standard) floating point number classes: double and single. The function tofloat is not a standard MATLAB function.

Iniciar sesión para comentar.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 29 de Mzo. de 2015

0 votos

Amrinder - I don't think that tofloat is a built-in function of MATLAB (for the base version or any of its toolboxes). Is your above code copied from a text book that makes use of this function? A similar question has been asked and answered at http://www.mathworks.com/matlabcentral/answers/66558-can-any-one-tell-me-how-to-convert-an-image-of-type-unit8-to-the-image-of-type-float-basicaly-i.
If you want to convert your uint8 gray array to floats (or doubles) then consider using the im2double function (provided your version of MATLAB has it).

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Mzo. de 2015

Editada:

el 30 de Mzo. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by