normalization data to 0-255
13 views (last 30 days)
Show older comments
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

0 Comments
Accepted Answer
Les Beckham
on 3 May 2023
Edited: Les Beckham
on 3 May 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)
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)
3 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!