how can normalize the data between 0 and 1??

6 vues (au cours des 30 derniers jours)
ananthi thirupathi
ananthi thirupathi le 23 Fév 2017
Commenté : Image Analyst le 20 Oct 2019
how can normalize the data between 0 and 1??(exclude 0 and 1)

Réponses (2)

Walter Roberson
Walter Roberson le 23 Fév 2017
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 commentaires
Jan
Jan le 23 Fév 2017
@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 le 23 Fév 2017
mat2gray(DATA) * (1-eps) + eps(realmin)

Connectez-vous pour commenter.


Jan
Jan le 23 Fév 2017
Modifié(e) : Jan le 23 Fév 2017
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 commentaires
Sajitha K.N.
Sajitha K.N. le 20 Oct 2019
sir,what is this x?
Image Analyst
Image Analyst le 20 Oct 2019
It's the data that you want to rescale.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by