why we need to convert the uint8 to double

4 views (last 30 days)
double()
  1 Comment
Stephen23
Stephen23 on 7 Feb 2016
Edited: Stephen23 on 7 Feb 2016
We only "need to convert the uint8 to double" if an operation requires this. You have not told us what operations you are doing, so we cannot tell you why you "need" to convert to double.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 7 Feb 2016
Most images are uint8, and this limits most operations to 8-bit precision, if they can be done at all. (Many functions accept only double-precision arguments.) You need to convert them to double to perform certain calculations on them such as fft2, fftn, or other such operations.
  2 Comments
Walter Roberson
Walter Roberson on 7 Feb 2016
In particular if you want to do image subtraction then you need to convert to a data type that supports signed values.
Also if you want to calculate ratios then you need a floating point data type as ratios of integers immediately rounds to 0 or 1.
Image Analyst
Image Analyst on 7 Feb 2016
conv2() is also a really common image processing routine that requires doubles. Summing also would if you would exceed the max value allowable for that integer type.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!