フィルターのクリア

All result is integer instead double

3 ビュー (過去 30 日間)
Dani D
Dani D 2016 年 4 月 25 日
回答済み: Walter Roberson 2016 年 4 月 25 日
Hello, Why all result after divide isn't double? Just zero or one :( Thanks
input = imread('cameraman.tif');
B = 2;
L = 256;
[m , n] = size(input);
output = zeros(m,n);
output = double(output);
min = min(input(:));
max = max(input(:));
for i = 1 : m
for j = 1 : n
Xmn = double(input(i,j));
output(i,j) = (Xmn - min )/(max - min);
end
end
  1 件のコメント
John D'Errico
John D'Errico 2016 年 4 月 25 日
It is a REALLY, REALLY, REALLY bad idea to write lines like this:
min = min(input(:));
max = max(input(:));
Note that once you do that, the functions min and max will no longer work properly! So the second time you try to run that code, it will now fail.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 25 日
The variables you name "min" and "max" are the same data type as your input. If your input is uint8 then min and max are uint8. When you do an operation involving double and uint8, the result is always uint8.

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by