Zum Inhalt springen

Datei:Window function (rectangular).png

Seiteninhalte werden in anderen Sprachen nicht unterstützt.
Zur Beschreibungsseite auf Commons
aus Wikipedia, der freien Enzyklopädie

Originaldatei (2.500 × 1.123 Pixel, Dateigröße: 83 KB, MIME-Typ: image/png)

Diese Datei und die Informationen unter dem roten Trennstrich werden aus dem zentralen Medienarchiv Wikimedia Commons eingebunden.

Zur Beschreibungsseite auf Commons


Übertragen aus en.wikipedia nach Commons durch Tiaguito.

Beschreibung

Beschreibung rectangular window and frequency response
Datum
Quelle Eigenes Werk
Urheber Bob K (original version), Olli Niemitalo
Genehmigung
(Weiternutzung dieser Datei)
Public domain Ich, der Urheberrechtsinhaber dieses Werkes, veröffentliche es als gemeinfrei. Dies gilt weltweit.
In manchen Staaten könnte dies rechtlich nicht möglich sein. Sofern dies der Fall ist:
Ich gewähre jedem das bedingungslose Recht, dieses Werk für jedweden Zweck zu nutzen, es sei denn, Bedingungen sind gesetzlich erforderlich.
Andere Versionen
File:Window function and frequency response - Rectangular.svg ist eine vektorisierte Version dieses Bildes. Diese sollte an Stelle des Rasterbildes verwendet werden, sofern sie nicht schlechter ist.

File:Window function (rectangular).png → File:Window function and frequency response - Rectangular.svg

Für weitere Informationen siehe Help:SVG.

In anderen Sprachen
Alemannisch  العربية  беларуская (тарашкевіца)  български  বাংলা  català  нохчийн  čeština  dansk  Deutsch  Ελληνικά  English  British English  Esperanto  español  eesti  euskara  فارسی  suomi  français  Frysk  galego  Alemannisch  עברית  हिन्दी  hrvatski  magyar  հայերեն  Bahasa Indonesia  Ido  italiano  日本語  ქართული  한국어  lietuvių  македонски  മലയാളം  Bahasa Melayu  norsk bokmål  Plattdüütsch  Nederlands  norsk nynorsk  norsk  occitan  polski  prūsiskan  português  português do Brasil  română  русский  sicilianu  Scots  slovenčina  slovenščina  српски / srpski  svenska  தமிழ்  ไทย  Türkçe  татарча / tatarça  українська  vèneto  Tiếng Việt  中文  中文(中国大陆)  中文(简体)  中文(繁體)  中文(马来西亚)  中文(新加坡)  中文(臺灣)  +/−
Neue Vektorgrafik

Source code
InfoField
The script below generates these .png images:

This script has not been tested in MATLAB. See the individual file histories for the simpler MATLAB scripts that were the basis of this script.

Generation of svg files by minor modification of the script displayed visual artifacts and renderer incompatibilities that could not be easily fixed. The current script fixes the visual artifacts in the png file as a post-processing step. The script generates a semi-transparent grid by taking a weighted average of two images, one with the grid and one without.
N
 
Diese PNG-Rastergrafik wurde von Olli Niemitalo mit GNU Octave erstellt.

Matlab

function plotWindowLayer (w, N, gridded, wname, wspecifier)
 
  M=32;
  k=0:N-1;
  dr = 120;

  H = abs(fft([w zeros(1,(M-1)*N)]));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
 
  figure('Position',[1 1 1200 520])
  subplot(1,2,1)
  set(gca,'FontSize',28)
  area(k,w,'FaceColor', [0 1 1],'edgecolor', [1 1 0],'linewidth', 2)
  xlim([0 N-1])
  if (min(w) >= -0.01)
    ylim([0 1.05])
    set(gca,'YTick', [0 : 0.1 : 1])
    ylabel('amplitude','position',[-16 0.525 0])
  else
    ylim([-1 5])
    set(gca,'YTick', [-1 : 1 : 5])
    ylabel('amplitude','position',[-16 2 0])
  endif
  set(gca,'XTick', [0 : 1/8 : 1]*(N-1))
  set(gca,'XTickLabel',[' 0'; ' '; ' '; ' '; ' '; ' '; ' '; ' '; 'N-1'])
  grid(gridded)
  set(gca,'LineWidth',2)
  set(gca,'gridlinestyle','-')
  xlabel('samples')
  if (strcmp (wspecifier, ""))
    title(cstrcat(wname,' window'))
  else
    title(cstrcat(wname,' window (', wspecifier, ')'))
  endif
  set(gca,'Position',[0.08 0.11 0.4 0.8])
  set(gca,'XColor',[1 0 1])
  set(gca,'YColor',[1 0 1])
  
  subplot(1,2,2)
  set(gca,'FontSize',28)
  h = stem(([1:M*N]-1-M*N/2)/M,H,'-');
  set(h,'BaseValue',-dr)
  ylim([-dr 6])
  set(gca,'YTick', [0 : -10 : -dr])
  set(findobj('Type','line'),'Marker','none','Color',[0 1 1])
  xlim([-M*N/2 M*N/2]/M)
  grid(gridded)
  set(findobj('Type','gridline'),'Color',[.871 .49 0])
  set(gca,'LineWidth',2)
  set(gca,'gridlinestyle','-')
  ylabel('decibels')
  xlabel('bins')
  title('Frequency response')
  set(gca,'Position',[0.59 0.11 0.4 0.8])
  set(gca,'XColor',[1 0 1])
  set(gca,'YColor',[1 0 1])

endfunction

function plotWindow (w, wname, wspecifier = "", wfilespecifier = "")

  if (strcmp (wfilespecifier, ""))
    wfilespecifier = wspecifier;
  endif

  N = size(w)(2);
  B = N*sum(w.^2)/sum(w)^2   % noise bandwidth (bins), set N = 4096 to get an accurate estimate
  
  plotWindowLayer(w, N, "on", wname, wspecifier);  % "gridded" = "on"
  print temp1.png -dpng "-S2500,1165"
  close
  plotWindowLayer(w, N, "off", wname, wspecifier);  % "gridded" = "off"
  print temp2.png -dpng "-S2500,1165"
  close
% I'm not sure what's going on here, but it looks like the author might have been able
% to save himself some time by using set(gca,"Layer","top") and set(gca,"Layer","bottom").
  I = imread ("temp1.png");
  J = imread ("temp2.png");
  info = imfinfo ("temp1.png");
  w = info.Width;
  c = 1-(double(I(:,1:w/2,1))+2*double(J(:,1:w/2,1)))/(255*3);
  m = 1-(double(I(:,1:w/2,2))+2*double(J(:,1:w/2,2)))/(255*3);
  y = 1-(double(I(:,1:w/2,3))+2*double(J(:,1:w/2,3)))/(255*3);
  c = ((c != m) | (c != y)).*(c > 0).*(1-m-y);
  I(:,1:w/2,1) = 255*(1-c-m-y + 0*m + 0*y + 0*c);
  I(:,1:w/2,2) = 255*(1-c-m-y + 0*m + 0*y + 0.4*c);
  I(:,1:w/2,3) = 255*(1-c-m-y + 0*m + 0*y + 0.6*c);
  c = 1-(double(I(:,w/2+1:w,1))+2*double(J(:,w/2+1:w,1)))/(255*3);
  m = 1-(double(I(:,w/2+1:w,2))+2*double(J(:,w/2+1:w,2)))/(255*3);
  y = 1-(double(I(:,w/2+1:w,3))+2*double(J(:,w/2+1:w,3)))/(255*3);
  c = ((c != m) | (c != y)).*c;
  I(:,w/2+1:w,1) = 255*(1-c-m-y + 0*m + 0*y + 0.8710*c);
  I(:,w/2+1:w,2) = 255*(1-c-m-y + 0*m + 0*y + 0.49*c);
  I(:,w/2+1:w,3) = 255*(1-c-m-y + 0*m + 0*y + 0*c);
  if (strcmp (wfilespecifier, ""))
    imwrite (I, cstrcat('Window function and frequency response - ', wname, '.png'));
  else
    imwrite (I, cstrcat('Window function and frequency response - ', wname, ' (', wfilespecifier, ').png'));
  endif
  
endfunction

N=128;
k=0:N-1;

w = 0.42 - 0.5*cos(2*pi*k/(N-1)) + 0.08*cos(4*pi*k/(N-1));
plotWindow(w, "Blackman")

w = 0.355768 - 0.487396*cos(2*pi*k/(N-1)) + 0.144232*cos(4*pi*k/(N-1)) -0.012604*cos(6*pi*k/(N-1));
plotWindow(w, "Nuttall", "continuous first derivative")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.032*cos(8*pi*k/(N-1));
plotWindow(w, "Flat top")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.028*cos(8*pi*k/(N-1));
plotWindow(w, "SRS flat top")

w = ones(1,N);
plotWindow(w, "Rectangular")

w = (N/2 - abs([0:N-1]-(N-1)/2))/(N/2);
plotWindow(w, "Triangular")

w = 0.5 - 0.5*cos(2*pi*k/(N-1));
plotWindow(w, "Hann")

w = 0.53836 - 0.46164*cos(2*pi*k/(N-1));
plotWindow(w, "Hamming", "alpha = 0.53836")

alpha = 0.5;
w = ones(1,N);
n = -(N-1)/2 : -alpha*N/2;
L = length(n);
w(1:L) = 0.5*(1+cos(pi*(abs(n)-alpha*N/2)/((1-alpha)*N/2)));
w(N : -1 : N-L+1) = w(1:L);
plotWindow(w, "Tukey", "alpha = 0.5")

w = sin(pi*k/(N-1));
plotWindow(w, "Cosine")

w = sinc(2*k/(N-1)-1);
plotWindow(w, "Lanczos")

w = ((N-1)/2 - abs([0:N-1]-(N-1)/2))/((N-1)/2);
plotWindow(w, "Bartlett")

sigma = 0.4;
w = exp(-0.5*( (k-(N-1)/2)/(sigma*(N-1)/2) ).^2);
plotWindow(w, "Gaussian", "sigma = 0.4")

w = 0.62 -0.48*abs(k/(N-1) -0.5) +0.38*cos(2*pi*(k/(N-1) -0.5));
plotWindow(w, "Bartlett–Hann")

alpha = 2;
w = besseli(0,pi*alpha*sqrt(1-(2*k/(N-1) -1).^2))/besseli(0,pi*alpha);
plotWindow(w, "Kaiser", "alpha = 2")

alpha = 3;
w = besseli(0,pi*alpha*sqrt(1-(2*k/(N-1) -1).^2))/besseli(0,pi*alpha);
plotWindow(w, "Kaiser", "alpha = 3")

tau = N-1;
epsilon = 0.1;
t_cut = tau * (0.5 - epsilon);
T_in = abs(k - 0.5 * tau);
z_exp = ((t_cut - 0.5 * tau) ./ (T_in - t_cut) + (t_cut - 0.5 * tau) ./ (T_in - 0.5 * tau));
sigma =  (T_in < 0.5 * tau) ./ (exp(z_exp) + 1);        
w = 1 * (T_in <= t_cut) + sigma .* (T_in > t_cut);
plotWindow(w, "Planck-taper", "epsilon = 0.1")

w = 0.35875 - 0.48829*cos(2*pi*k/(N-1)) + 0.14128*cos(4*pi*k/(N-1)) -0.01168*cos(6*pi*k/(N-1));
plotWindow(w, "Blackman-Harris")

w = 0.3635819 - 0.4891775*cos(2*pi*k/(N-1)) + 0.1365995*cos(4*pi*k/(N-1)) -0.0106411*cos(6*pi*k/(N-1));
plotWindow(w, "Blackman-Nuttall")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.032*cos(8*pi*k/(N-1));
plotWindow(w, "Flat top")

tau = (N/2);
w = exp(-abs(k-(N-1)/2)/tau);
plotWindow(w, "Exponential", "tau = N/2", "half window decay")

tau = (N/2)/(60/8.69);
w = exp(-abs(k-(N-1)/2)/tau);
plotWindow(w, "Exponential", "tau = (N/2)/(60/8.69)", "60dB decay")

alpha = 2;
w = 1/2*(1 - cos(2*pi*k/(N-1))).*exp(alpha*abs(N-2*k-1)/(1-N));
plotWindow(w, "Hann-Poisson", "alpha = 2")

Quelltext
InfoField

Octave

Source code
function plotWindowLayer (w, N, gridded, wname, wspecifier)
 
  M=32;
  k=0:N-1;
  dr = 120;

  H = abs(fft([w zeros(1,(M-1)*N)]));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
 
  figure('Position',[1 1 1200 520])
  subplot(1,2,1)
  set(gca,'FontSize',28)
  area(k,w,'FaceColor', [0 1 1],'edgecolor', [1 1 0],'linewidth', 2)
  xlim([0 N-1])
  if (min(w) >= -0.01)
    ylim([0 1.05])
    set(gca,'YTick', [0 : 0.1 : 1])
    ylabel('amplitude','position',[-16 0.525 0])
  else
    ylim([-1 5])
    set(gca,'YTick', [-1 : 1 : 5])
    ylabel('amplitude','position',[-16 2 0])
  endif
  set(gca,'XTick', [0 : 1/8 : 1]*(N-1))
  set(gca,'XTickLabel',[' 0'; ' '; ' '; ' '; ' '; ' '; ' '; ' '; 'N-1'])
  grid(gridded)
  set(gca,'LineWidth',2)
  set(gca,'gridlinestyle','-')
  xlabel('samples')
  if (strcmp (wspecifier, ""))
    title(cstrcat(wname,' window'))
  else
    title(cstrcat(wname,' window (', wspecifier, ')'))
  endif
  set(gca,'Position',[0.08 0.11 0.4 0.8])
  set(gca,'XColor',[1 0 1])
  set(gca,'YColor',[1 0 1])
  
  subplot(1,2,2)
  set(gca,'FontSize',28)
  h = stem(([1:M*N]-1-M*N/2)/M,H,'-');
  set(h,'BaseValue',-dr)
  ylim([-dr 6])
  set(gca,'YTick', [0 : -10 : -dr])
  set(findobj('Type','line'),'Marker','none','Color',[0 1 1])
  xlim([-M*N/2 M*N/2]/M)
  grid(gridded)
  set(findobj('Type','gridline'),'Color',[.871 .49 0])
  set(gca,'LineWidth',2)
  set(gca,'gridlinestyle','-')
  ylabel('decibels')
  xlabel('bins')
  title('Frequency response')
  set(gca,'Position',[0.59 0.11 0.4 0.8])
  set(gca,'XColor',[1 0 1])
  set(gca,'YColor',[1 0 1])

endfunction

function plotWindow (w, wname, wspecifier = "", wfilespecifier = "")

  if (strcmp (wfilespecifier, ""))
    wfilespecifier = wspecifier;
  endif

  N = size(w)(2);
  B = N*sum(w.^2)/sum(w)^2   % noise bandwidth (bins), set N = 4096 to get an accurate estimate
  
  plotWindowLayer(w, N, "on", wname, wspecifier);  % "gridded" = "on"
  print temp1.png -dpng "-S2500,1165"
  close
  plotWindowLayer(w, N, "off", wname, wspecifier);  % "gridded" = "off"
  print temp2.png -dpng "-S2500,1165"
  close
% I'm not sure what's going on here, but it looks like the author might have been able
% to save himself some time by using set(gca,"Layer","top") and set(gca,"Layer","bottom").
  I = imread ("temp1.png");
  J = imread ("temp2.png");
  info = imfinfo ("temp1.png");
  w = info.Width;
  c = 1-(double(I(:,1:w/2,1))+2*double(J(:,1:w/2,1)))/(255*3);
  m = 1-(double(I(:,1:w/2,2))+2*double(J(:,1:w/2,2)))/(255*3);
  y = 1-(double(I(:,1:w/2,3))+2*double(J(:,1:w/2,3)))/(255*3);
  c = ((c != m) | (c != y)).*(c > 0).*(1-m-y);
  I(:,1:w/2,1) = 255*(1-c-m-y + 0*m + 0*y + 0*c);
  I(:,1:w/2,2) = 255*(1-c-m-y + 0*m + 0*y + 0.4*c);
  I(:,1:w/2,3) = 255*(1-c-m-y + 0*m + 0*y + 0.6*c);
  c = 1-(double(I(:,w/2+1:w,1))+2*double(J(:,w/2+1:w,1)))/(255*3);
  m = 1-(double(I(:,w/2+1:w,2))+2*double(J(:,w/2+1:w,2)))/(255*3);
  y = 1-(double(I(:,w/2+1:w,3))+2*double(J(:,w/2+1:w,3)))/(255*3);
  c = ((c != m) | (c != y)).*c;
  I(:,w/2+1:w,1) = 255*(1-c-m-y + 0*m + 0*y + 0.8710*c);
  I(:,w/2+1:w,2) = 255*(1-c-m-y + 0*m + 0*y + 0.49*c);
  I(:,w/2+1:w,3) = 255*(1-c-m-y + 0*m + 0*y + 0*c);
  if (strcmp (wfilespecifier, ""))
    imwrite (I, cstrcat('Window function and frequency response - ', wname, '.png'));
  else
    imwrite (I, cstrcat('Window function and frequency response - ', wname, ' (', wfilespecifier, ').png'));
  endif
  
endfunction

N=128;
k=0:N-1;

w = 0.42 - 0.5*cos(2*pi*k/(N-1)) + 0.08*cos(4*pi*k/(N-1));
plotWindow(w, "Blackman")

w = 0.355768 - 0.487396*cos(2*pi*k/(N-1)) + 0.144232*cos(4*pi*k/(N-1)) -0.012604*cos(6*pi*k/(N-1));
plotWindow(w, "Nuttall", "continuous first derivative")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.032*cos(8*pi*k/(N-1));
plotWindow(w, "Flat top")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.028*cos(8*pi*k/(N-1));
plotWindow(w, "SRS flat top")

w = ones(1,N);
plotWindow(w, "Rectangular")

w = (N/2 - abs([0:N-1]-(N-1)/2))/(N/2);
plotWindow(w, "Triangular")

w = 0.5 - 0.5*cos(2*pi*k/(N-1));
plotWindow(w, "Hann")

w = 0.53836 - 0.46164*cos(2*pi*k/(N-1));
plotWindow(w, "Hamming", "alpha = 0.53836")

alpha = 0.5;
w = ones(1,N);
n = -(N-1)/2 : -alpha*N/2;
L = length(n);
w(1:L) = 0.5*(1+cos(pi*(abs(n)-alpha*N/2)/((1-alpha)*N/2)));
w(N : -1 : N-L+1) = w(1:L);
plotWindow(w, "Tukey", "alpha = 0.5")

w = sin(pi*k/(N-1));
plotWindow(w, "Cosine")

w = sinc(2*k/(N-1)-1);
plotWindow(w, "Lanczos")

w = ((N-1)/2 - abs([0:N-1]-(N-1)/2))/((N-1)/2);
plotWindow(w, "Bartlett")

sigma = 0.4;
w = exp(-0.5*( (k-(N-1)/2)/(sigma*(N-1)/2) ).^2);
plotWindow(w, "Gaussian", "sigma = 0.4")

w = 0.62 -0.48*abs(k/(N-1) -0.5) +0.38*cos(2*pi*(k/(N-1) -0.5));
plotWindow(w, "Bartlett–Hann")

alpha = 2;
w = besseli(0,pi*alpha*sqrt(1-(2*k/(N-1) -1).^2))/besseli(0,pi*alpha);
plotWindow(w, "Kaiser", "alpha = 2")

alpha = 3;
w = besseli(0,pi*alpha*sqrt(1-(2*k/(N-1) -1).^2))/besseli(0,pi*alpha);
plotWindow(w, "Kaiser", "alpha = 3")

tau = N-1;
epsilon = 0.1;
t_cut = tau * (0.5 - epsilon);
T_in = abs(k - 0.5 * tau);
z_exp = ((t_cut - 0.5 * tau) ./ (T_in - t_cut) + (t_cut - 0.5 * tau) ./ (T_in - 0.5 * tau));
sigma =  (T_in < 0.5 * tau) ./ (exp(z_exp) + 1);        
w = 1 * (T_in <= t_cut) + sigma .* (T_in > t_cut);
plotWindow(w, "Planck-taper", "epsilon = 0.1")

w = 0.35875 - 0.48829*cos(2*pi*k/(N-1)) + 0.14128*cos(4*pi*k/(N-1)) -0.01168*cos(6*pi*k/(N-1));
plotWindow(w, "Blackman-Harris")

w = 0.3635819 - 0.4891775*cos(2*pi*k/(N-1)) + 0.1365995*cos(4*pi*k/(N-1)) -0.0106411*cos(6*pi*k/(N-1));
plotWindow(w, "Blackman-Nuttall")

w = 1 - 1.93*cos(2*pi*k/(N-1)) + 1.29*cos(4*pi*k/(N-1)) -0.388*cos(6*pi*k/(N-1)) +0.032*cos(8*pi*k/(N-1));
plotWindow(w, "Flat top")

tau = (N/2);
w = exp(-abs(k-(N-1)/2)/tau);
plotWindow(w, "Exponential", "tau = N/2", "half window decay")

tau = (N/2)/(60/8.69);
w = exp(-abs(k-(N-1)/2)/tau);
plotWindow(w, "Exponential", "tau = (N/2)/(60/8.69)", "60dB decay")

alpha = 2;
w = 1/2*(1 - cos(2*pi*k/(N-1))).*exp(alpha*abs(N-2*k-1)/(1-N));
plotWindow(w, "Hann-Poisson", "alpha = 2")

Kurzbeschreibungen

Ergänze eine einzeilige Erklärung, was diese Datei darstellt.

In dieser Datei abgebildete Objekte

Motiv

image/png

Dateiversionen

Klicke auf einen Zeitpunkt, um diese Version zu laden.

Version vomVorschaubildMaßeBenutzerKommentar
aktuell18:48, 9. Feb. 2013Vorschaubild der Version vom 18:48, 9. Feb. 20132.500 × 1.123 (83 KB)Olli NiemitaloAntialiasing, layout changes, larger font
23:07, 17. Dez. 2005Vorschaubild der Version vom 23:07, 17. Dez. 20051.038 × 419 (7 KB)Tiaguito~commonswikifile size. color source: http://en.wikipedia.org/wiki/Window_Function
22:48, 17. Dez. 2005Vorschaubild der Version vom 22:48, 17. Dez. 20051.038 × 419 (8 KB)Tiaguito~commonswikisource: http://en.wikipedia.org/wiki/Window_Function author: http://en.wikipedia.org/wiki/User:Bob_K

Keine Seiten verwenden diese Datei.

Globale Dateiverwendung

Die nachfolgenden anderen Wikis verwenden diese Datei: