the rang of unit 8 is 0-255 But im2double convert the range to [0, 1] instead of [0, 255]. please anyone explain it????

6 views (last 30 days)
the rang of unit 8 is 0-255 But im2double convert the range to [0, 1] instead of [0, 255]. please anyone explain it????

Accepted Answer

Stephen23
Stephen23 on 26 May 2015
Edited: Stephen23 on 26 May 2015
This is the expected (although not clearly explained) behavior of im2double: the function scales any integer image values to the range [0,1], as well as converting to class double.
If you want to simply convert an integer to the equivalent double value, then use double instead.
It is important to note that many MATLAB image processing functions use the normalized range of [0,1], and it would likely make your own life much easier if you stick with using the standard range of values.

More Answers (1)

David Young
David Young on 26 May 2015
It's very helpful to have a standard range of values for images. The convention used in MATLAB toolbox functions is that images represented as double should have values in the range 0 to 1. Then it doesn't matter whether the original image was uint8, uint16 or some other type.
im2double makes it easy to adopt the convention for images read in from a variety of sources. If you want to retain the range 0 to 255 for your images, just use double instead of im2double. However, I recommend that you stick with the 0 to 1 convention - it will be simpler in the end.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!