how can normalize the data between 0 and 1??

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 2 月 23 日

0 投票

mat2gray() would normalize to exactly 0 to exactly 1.
But what value do you want instead of 0? Should the smallest values be mapped to eps(realmin), which is about 1E-324 ?

3 件のコメント

ananthi thirupathi
ananthi thirupathi 2017 年 2 月 23 日
the value should be more then zero but not exactly 0 and less than one. it may take any value as you said eps(realmin) also fine
Jan
Jan 2017 年 2 月 23 日
@ananthi: Accepting an answer means, that the problem is solved. Then most readers will not care about the thread anymore. Is the problem solved?
Walter Roberson
Walter Roberson 2017 年 2 月 23 日
mat2gray(DATA) * (1-eps) + eps(realmin)

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

Jan
Jan 2017 年 2 月 23 日
編集済み: Jan 2017 年 2 月 23 日

0 投票

A cheap adjustment of the edges:
x = randn(100, 1);
xn = (x - min(x)) / (max(x) - min(x));
xn(xn == 0) = eps; % Or: eps(realmin)
xn(xn == 1) = 1 - eps;
Or consider the limits during the normalization: [EDITED, first version failed]
xmin = min(x);
xmax = max(x);
range = (xmax - xmin) + eps(xmax - xmin);
xn = (x - (xmin - eps(xmin))) / range;
% Or:
% xn = (x - (xmin - eps(xmax - xmin))) / range;

4 件のコメント

ananthi thirupathi
ananthi thirupathi 2017 年 2 月 23 日
thank you jan simon.. this logic is working
Ss
Ss 2018 年 4 月 17 日
Hi can I ask what is the function of eps(xmax-xmin)
Sajitha K.N.
Sajitha K.N. 2019 年 10 月 20 日
sir,what is this x?
Image Analyst
Image Analyst 2019 年 10 月 20 日
It's the data that you want to rescale.

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

カテゴリ

タグ

質問済み:

2017 年 2 月 23 日

コメント済み:

2019 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by