contour_plot_itd.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. % Run this script either after HRIR_Berechnung or after loading one of the
  2. % results files that were saved by HRIR_Berechnung
  3. % Berechnung aller ITDs
  4. ITDs = nan(numel(azimuths),numel(elevations));
  5. for i = 1:numel(azimuths)
  6. for j = 1:numel(elevations)
  7. xc = xcorr( squeeze(hrir_l(i,j,:)), squeeze(hrir_r(i,j,:)), 'coeff');
  8. [corr_max,g] = max(xc);
  9. ITDcorrsamples = size(hrir_l,3)-g;
  10. ITDcorr = ITDcorrsamples/samplingrate;
  11. ITDs(i,j) = -ITDcorr;
  12. end
  13. end
  14. figure
  15. hold on
  16. contourf(azimuths, elevations, 1e6*ITDs', -300:10:300)
  17. contour(azimuths, elevations, 1e6*ITDs', -1000:50:1000, 'LineWidth', 3, 'Color', 'k')
  18. contour(azimuths, elevations, 1e6*ITDs', -1000:1000:1000, 'LineWidth', 5, 'Color', 'r', 'linestyle', ':')
  19. [~, max_I] = max(ITDs(:));
  20. [max_I_row, max_I_col] = ind2sub(size(ITDs), max_I);
  21. line([0, 0] + azimuths(max_I_row), [-3, +3] + elevations(max_I_col), 'linewidth', 1, 'color', 'r')
  22. line([-3, +3] + azimuths(max_I_row), [0, 0] + elevations(max_I_col), 'linewidth', 1, 'color', 'r')
  23. viscircles([azimuths(max_I_row), elevations(max_I_col)], 3, 'linewidth', 1);
  24. % plot(azimuths(max_I_row), elevations(max_I_col), '+r');
  25. % plot(azimuths(max_I_row), elevations(max_I_col), 'or');
  26. [~, min_I] = min(ITDs(:));
  27. [min_I_row, min_I_col] = ind2sub(size(ITDs), min_I);
  28. line([-3, +3] + azimuths(min_I_row), [0, 0] + elevations(min_I_col), 'linewidth', 1, 'color', 'r')
  29. viscircles([azimuths(min_I_row), elevations(min_I_col)], 3, 'linewidth', 1);
  30. colorbar
  31. set(gca, 'xtick', (-180:30:180))
  32. set(gca, 'ytick', (-180:30:180))
  33. set(gca, 'xlim', [-180 180])
  34. set(gca, 'ylim', [-90 90])
  35. set(gca, 'DataAspectRatio', [1 1 1])
  36. grid
  37. title('ITD')