uint8 to double is converting pixel values into decimal

when I convert my image which is in uint format to double the pixel matrix values are converting into decimal values
These are uint matrix of image
181 185 165 128 109 143 163 159 160 164 182 177 179 182 185 187 193 193
and these are double values of same image
0.709803921568628 0.725490196078431 0.647058823529412 0.501960784313726 0.427450980392157 0.560784313725490 0.639215686274510 0.623529411764706 0.627450980392157 0.643137254901961
why is this happening so? whats the solution

 採用された回答

Image Analyst
Image Analyst 2017 年 3 月 17 日

0 投票

Basically it's dividing by 255 when you use im2double(). If you don't want that, then don't do it. If you want the floating point version but the values to be the same, use double() instead of im2double().

6 件のコメント

akash bais
akash bais 2017 年 3 月 17 日
i dont want that to divide by 255, I just want the original integer values of double, how can i get those?
Guillaume
Guillaume 2017 年 3 月 17 日
編集済み: Guillaume 2017 年 3 月 17 日
Hum, Image Analyst wrote: "If you want the floating point version but the values to be the same, use double() instead of im2double()".
Note that generic non-image processing functions (such as conv2) do not care about the range of values in your image matrix so will work will no problem with double values up to 255. On the other hand, a lot of image processing functions (such as imshow) will not work correctly (or rather as you may expect) if the image type is double but outside the range [0-1].
Image Analyst
Image Analyst 2017 年 3 月 17 日
True. Some work fine with whatever original range of values you're using, like functions imerode(), imdilate(), etc.
Some work with "workarounds", like imshow(dblImage, []) where you can use your original values as long as you use open/close brackets.
Some don't work like you'd expect, like imhist(), unless they're already in the range 0-1 before passing in to the function.
You just have to know what you're doing.
akash bais
akash bais 2017 年 3 月 17 日
but my query still remains un answered, or is it so that it isnt possible?
Image Analyst
Image Analyst 2017 年 3 月 17 日
Why is it unanswered? Look:
grayImage = uint8([181 185 165 128 109 143 163 159 160 164 182 177 179 182 185 187 193 193])
dblGrayImage = double(grayImage)
whos dblGrayImage
Look in the command window and you'll see
grayImage =
1×18 uint8 row vector
181 185 165 128 109 143 163 159 160 164 182 177 179 182 185 187 193 193
dblGrayImage =
181 185 165 128 109 143 163 159 160 164 182 177 179 182 185 187 193 193
Name Size Bytes Class Attributes
dblGrayImage 1x18 144 double
You have a double array with the very same values as the uint8 version. I thought that's what you said you wanted? What more do you want?
akash bais
akash bais 2017 年 3 月 18 日
okay got it, Thanks a lot sir :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by