Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [alfabeto] = pl1_histograma(fonte)
- disp('Histrogram Function')
- [filepath,name,ext] = fileparts(fonte); %ext = extension of given file
- %fonte audio (de 0 a 1)
- if (ext=='.wav')
- [fontefinal, Fs] = audioread(fonte); %le informacao da fonte: sampled data in fontefinal, sample rate in Fs(never used)
- info = audioinfo(fonte);
- bits = info.BitsPerSample;
- bits = 2.^bits;
- delta = 2/bits;
- alfabeto = (-1:delta:1-delta);
- display(alfabeto)
- x = histcounts(fontefinal, alfabeto);
- bar(x)
- %fonte img(de 0 a 255)
- elseif(ext=='.bmp')
- fontefinal = imread(fonte);
- info = imfinfo(fonte);
- bits = info.BitDepth;
- bits =2.^bits;
- alfabeto = (1:bits);
- display(alfabeto)
- figure()
- x = histcounts(fontefinal, alfabeto)
- bar(x)
- %fonte texto
- elseif(ext== '.txt')
- alfabeto = ['A':'Z','a':'z']
- fontefinal = fopen(fonte, 'r'); %este nao esta a funcionar. acho que o problema e nao estar a ler bem o ficheiro de texto.
- x = histcounts(fontefinal, double(alfabeto))
- bar(x)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement