normalization data to 0-255
    14 次查看(过去 30 天)
  
       显示 更早的评论
    
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 个评论
采纳的回答
  Les Beckham
      
 2023-5-3
        
      编辑:Les Beckham
      
 2023-5-3
  
      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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


