Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function [alfabeto] = pl1_histograma(fonte)
  2.  
  3. disp('Histrogram Function')
  4. [filepath,name,ext] = fileparts(fonte); %ext = extension of given file
  5.  
  6. %fonte audio (de 0 a 1)
  7. if (ext=='.wav')
  8. [fontefinal, Fs] = audioread(fonte); %le informacao da fonte: sampled data in fontefinal, sample rate in Fs(never used)
  9. info = audioinfo(fonte);
  10. bits = info.BitsPerSample;
  11. bits = 2.^bits;
  12. delta = 2/bits;
  13. alfabeto = (-1:delta:1-delta);
  14. display(alfabeto)
  15.  
  16. x = histcounts(fontefinal, alfabeto);
  17. bar(x)
  18.  
  19. %fonte img(de 0 a 255)
  20. elseif(ext=='.bmp')
  21. fontefinal = imread(fonte);
  22. info = imfinfo(fonte);
  23. bits = info.BitDepth;
  24. bits =2.^bits;
  25. alfabeto = (1:bits);
  26. display(alfabeto)
  27.  
  28. figure()
  29.  
  30. x = histcounts(fontefinal, alfabeto)
  31. bar(x)
  32.  
  33. %fonte texto
  34. elseif(ext== '.txt')
  35. alfabeto = ['A':'Z','a':'z']
  36. fontefinal = fopen(fonte, 'r'); %este nao esta a funcionar. acho que o problema e nao estar a ler bem o ficheiro de texto.
  37.  
  38. x = histcounts(fontefinal, double(alfabeto))
  39. bar(x)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement