フィルターのクリア

Checking my image is double or not

2 ビュー (過去 30 日間)
Newman
Newman 2015 年 6 月 26 日
コメント済み: Newman 2015 年 6 月 27 日
pls tell me whether i am checking whether the image is double or not in a correct manner:
| | | *If the image is not double then i want to make it double* | | |
t = isa(Il,'double');%Il=imread("left.png");
if t ==0
Il = double(Il);
end
t = isa(Ir,'double');%Ir=imread("right.png");
if t ==0
Ir = double(Ir);
end

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 26 日
No, if you want to make the image double, then use im2double(). What you are doing is making an arbitrary data array double in a way that can prevent MATLAB from interpreting it as an image. Images that are represented as double need to be in the range 0.0 to 1.0, not 0.0 to 255.0
There are reasons to convert uint8 arrays to double for computation purposes, creating the floating point equivalent of the integers, but the result of doing that is not an image.
  3 件のコメント
Stephen23
Stephen23 2015 年 6 月 27 日
編集済み: Stephen23 2015 年 6 月 27 日
@Antariksha Kar: Don't make code more complicated than it needs to be. The documentation for im2double states "If the input image is of class double, then the output image is identical", which means that you do not need to check first if it of class double, because whatever input it has the output will be double. Just do this, without the if's:
Il = im2double(Il);
Ir = im2double(Ir);
Newman
Newman 2015 年 6 月 27 日
@Stephen Cobeldick thank u!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および 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