normalization data to 0-255
조회 수: 10 (최근 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!