how to find features from '.txt' files?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
santhosh kumar buddepu
le 26 Oct 2021
Commenté : santhosh kumar buddepu
le 26 Oct 2021
initially my data is like this :
Hy_r=h5read('D:\PSNR_survey\Plastic_tiffin_box_eps9\Plastic_tiffin_box_antennaX_Ey_eps9_merged.out','/rxs/rx1/Ey');
after some steps I have used:
imwrite (mat2gray(Gxx_t2), 'NEW IMAGE.png');
[X_raw,map] = imread ('NEW IMAGE.png');
m=mean(X_raw');
m=uint8(m);
X_avg=X_raw-m'; % removal of direct path or clutter removal done
imagesc(X,z_depth,X_avg)
The values X_avg are saved in excel sheet as ' text (tab delimited)'.
now I can recall X_avg directly by using:
y=dlmread('X_avg.txt', '\t', 0, 0);
figure,imagesc(X,z_depth,X_avg)
I need to use dlmread to read the data and i need to use imagesc instead of imread and imshow.
Like this I have created a database of around 40 text files for metal pipe, steel box, plastic box. I want to extract statistical features from all the files for that I have calculated mean, variance, skew, kurtosis for single file.
[pixelCounts GLs] = imhist(X_avg); % GL-gray levels
% Get the number of pixels in the histogram.
numberOfPixels = sum(pixelCounts);
% Get the mean gray lavel.
meanGL = sum(GLs .* pixelCounts) / numberOfPixels
% Get the variance, which is the second central moment.
varianceGL = sum((GLs - meanGL) .^ 2 .* pixelCounts) / (numberOfPixels-1)
% Get the standard deviation.
sd = sqrt(varianceGL);
% Get the skew.
skew = sum((GLs - meanGL) .^ 3 .* pixelCounts) / ((numberOfPixels - 1) * sd^3)
% Get the kurtosis.
kurtosis = sum((GLs - meanGL) .^ 4 .* pixelCounts) / ((numberOfPixels - 1) * sd^4)
How to calculate these features for all files using single code and how to store these features?
0 commentaires
Réponse acceptée
KSSV
le 26 Oct 2021
Modifié(e) : KSSV
le 26 Oct 2021
txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
meanGL= zeros(N,1);
varianceGL = zeros(N,1) ;
sd = zeros(N,1) ;
skew = zeros(N,1);
kurtosis = zeros(N,1) ;
for i = 1N
y=dlmread(txtFiles(i).name, '\t', 0, 0);
figure,imagesc(X,z_depth,X_avg)
[pixelCounts GLs] = imhist(X_avg); % GL-gray levels
% Get the number of pixels in the histogram.
numberOfPixels = sum(pixelCounts);
% Get the mean gray lavel.
meanGL(i) = sum(GLs .* pixelCounts) / numberOfPixels
% Get the variance, which is the second central moment.
varianceGL(i) = sum((GLs - meanGL) .^ 2 .* pixelCounts) / (numberOfPixels-1)
% Get the standard deviation.
sd(i) = sqrt(varianceGL);
% Get the skew.
skew(i) = sum((GLs - meanGL) .^ 3 .* pixelCounts) / ((numberOfPixels - 1) * sd^3)
% Get the kurtosis.
kurtosis(i) = sum((GLs - meanGL) .^ 4 .* pixelCounts) / ((numberOfPixels - 1) * sd^4)
end
5 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!