normalization data to 0-255

6 visualizzazioni (ultimi 30 giorni)
hakan
hakan il 3 Mag 2023
Commentato: Les Beckham il 19 Mag 2023
Hello eveyone ı have dataset which is this:
ineed to normalize each data to 0 to 255 .
my code :
T = dataset;
K=[,];
N=[,];
[row,col]= size (T);
for i=1:row
for j=1:col -1
K(i,j)=(table2array(T(i,j)));
N(i,j) =uint8(255*mat2gray(K(i,j)));
j=j+1;
end
i=i+1;
end
disp(N);
but when ı try to convert witn in for loop .ı got an output like this .almost all data was converted to 255 .
thx in advance

Risposta accettata

Les Beckham
Les Beckham il 3 Mag 2023
Modificato: Les Beckham il 3 Mag 2023
format long g
A = [linspace(1, 10, 10); flip(linspace(3, 100, 10)); rand(1,10)].';
T = array2table(A, 'VariableNames', {'ID', 'air_time1', 'disp_index1'});
disp(T)
ID air_time1 disp_index1 __ ________________ __________________ 1 100 0.84937546191858 2 89.2222222222222 0.781075522933781 3 78.4444444444444 0.510734961244536 4 67.6666666666667 0.786284237473229 5 56.8888888888889 0.130286316030897 6 46.1111111111111 0.0499583876595915 7 35.3333333333333 0.602753314979179 8 24.5555555555556 0.0680553222279021 9 13.7777777777778 0.508040576553327 10 3 0.121193046028218
for iCol=1:width(T)
T(:,iCol) = T(:,iCol) - min(T(:,iCol)); % make the min value zero
columnMax = max(T(:,iCol));
columnMax = table2array(columnMax);
T(:,iCol) = T(:,iCol) .* (255 / columnMax); % make the max value 255
end
disp(T)
ID air_time1 disp_index1 ________________ ________________ ________________ 0 255 255 28.3333333333333 226.666666666667 233.213519573287 56.6666666666667 198.333333333333 146.979630592797 85 170 234.875007988193 113.333333333333 141.666666666667 25.6231976952331 141.666666666667 113.333333333333 0 170 85 176.331868564552 198.333333333333 56.6666666666667 5.7726041430836 226.666666666667 28.3333333333333 146.120169219777 255 0 22.7226043437182
  3 Commenti
hakan
hakan il 18 Mag 2023
Isolved the problem .Thanks
Les Beckham
Les Beckham il 19 Mag 2023
You are quite welcome. Thank you for accepting the answer.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by