Επεξερασία εικόνας Μιχάλης ρακόπουλος Υπολογιστική Επιστήµη & Τεχνολογία, #9
Επεξεργασία ήχου Βασικό ανάγνωσµα: Οι ενότητες 3. και 3.2 από το ϐιβλίο των Van Loan και Fan. Επεξεργασία ήχου Μ. ρακόπουλος 2 Ενα ακουστικό σήµα Το Big Ben σηµαίνει η ώρα.6.4.2 Amplitude.2.4.6.8 2 4 6 8 2 4 6 8 2 Time (sec) Επεξεργασία ήχου Μ. ρακόπουλος 3 2
Ψηφιοποίηση ακουστικών σηµάτων.4.2 Amplitude.2.4.245.246.247.248.249.25.25.252.253.254.255 Time (sec).4.2 Amplitude.2.4.245.246.247.248.249.25.25.252.253.254.255 Time (sec) Επεξεργασία ήχου Μ. ρακόπουλος 4 Κωδικοποίηση wav Περιγράφεται από: ρυθµός δειγµατοληψίας (sampling rate) # δειγµάτων ανά sec (σε Hz). ποιότητα ήχου (τηλέφωνο: 8Hz, MP3: 44Hz, HD: 924Hz) διάνυσµα τιµών των δειγµάτων της ηχογράφησης. αριθµός bit (bit rate) ακρίβεια αναπαράστασης κάθε δείγµατος. Η τιµή κάθε δείγµατος ακέραιος στο [ 28, 27] ανάγεται στο [, ] στο MATLAB. Στο MATLAB [OneOclock, rate, nbits] = wavread( BigBen.wav ); Επεξεργασία ήχου Μ. ρακόπουλος 5 3
Το Big Ben στο MATLAB [OneOclock, rate] = wavread( BigBen.wav ); n = length(oneoclock); % ιάρκεια ηχογράφησης σε sec T = (n-)/rate; % ειγµατοληπτικοι χρόνοι tvals = linspace(, T, n); % Γραφική παράσταση plot(tvals, OneOclock) xlabel( Time (sec) ); ylabel( Amplitude ); Αναπαραγωγή του ήχου: sound(oneoclock, rate) Επεξεργασία ήχου Μ. ρακόπουλος 6 Μια εφαρµογή Το Big Ben σηµαίνει η ώρα.6.4.2 Amplitude.2.4.6.8 2 4 6 8 2 4 6 8 2 Time (sec) Επεξεργασία ήχου Μ. ρακόπουλος 7 4
% Read in the O clock sound file... fname = BigBen.wav ; [OneOclock,rate] = wavread(fname); n = length(oneoclock); % Display the wave form and click in between % the Chimes portion and the Gong portion... plot(oneoclock) title( Click at the beginning of the gong. ) [m,y] = ginput(); m = round(m); Chimes = OneOclock(:m); Gong = OneOclock(m+:n); % For each hourly strike, create a.wav file. % Name them BigBen, BigBen2,...,BigBen2. F = Chimes; for k=:2 F = [F; Gong]; fname = [ BigBen num2str(k).wav ]; wavwrite(f,rate,8,fname) end % Play back a chosen subset of the soundtracks... PlayList = [2 3]; for k = PlayList fname = [ BigBen num2str(k).wav ]; [Oclock,rate] = wavread(fname); sound(oclock) end Επεξεργασία ήχου Μ. ρακόπουλος 8 Στοιχειώδεις ηµιτονοειδείς συναρτήσεις y(t) = sin(2πωt).5.5 ω = 4.2.4.6.8 ω = 8.5.5.2.4.6.8 5
Επεξεργασία ήχου Μ. ρακόπουλος 9 Συνδυασµός ηµιτονοειδών συναρτήσεων y = a sin(2π ω t) + a 2 sin(2π ω 2 t).8.6.4.2.2.4.6.8.2.4.6.8 a =.6, ω = 4, a 2 =.2, ω 2 = 3 Επεξεργασία ήχου Μ. ρακόπουλος 6
Πλήκτρα και συχνότητες 697 ABC 2 DEF 3 77 GHI 4 JKL 5 MNO 6 852 PQRS 7 TUV 8 WXYZ 9 94 * # 29 336 477 Επεξεργασία ήχου Μ. ρακόπουλος 7
Πλήκτρα και συχνότητες (συνεχ.) y(t) = 2 sin(2πω rowt) + 2 sin(2πω colt) Button 2.5.5 2 3 4 5 Button 6 x 3.5.5 2 3 4 5 x 3 Επεξεργασία ήχου Μ. ρακόπουλος 2 function [tvals,y] = MakeShowPlay(i,j) % i (<=i<=4) and j (<=j<=3) are integers for row and column. % Displays the associated wave form and plays the tone. % The sample times and signal are returned in tvals and y. % The touchpad frequencies for the rows and columns... fr = [ 697 77 852 94]; fc = [ 29 336 477]; % Sampling rate. This many numbers/sec in the digital signal: Fs = 32768; % Duration of the tone is.25 sec. tvals = (:(/Fs):.25) ; % Sample the signal sin(2*pi*fr(i)*t) + sin(2*pi*fc(j)*t) at times % specified by tvals... yr = sin(2*pi*fr(i)*tvals); yc = sin(2*pi*fc(j)*tvals); y = (yr + yc)/2; % Display a representative part of the waveform... m = 3; plot((:m),y(:m),(:m),zeros(,m), -r ) title(sprintf( Original Signal( Row = %d, Col = %d ),i,j)) Επεξεργασία ήχου Μ. ρακόπουλος 3 8
Σήµα χωρίς ϑόρυβο Original Signal( Row = 2, Col = 3 ).5.5 5 5 2 25 3 Επεξεργασία ήχου Μ. ρακόπουλος 4 function ynoisy = SendNoisy(tVals,y) % Adds noise to the signal y. % Displays and plays the resulting signal ynoisy n = length(y); % Add noise... A =.5; ynoisy = y + A*randn(n,); % Display a representative part of the sinusoid... m = 3; plot((:m),ynoisy(:m),(:m),zeros(m,), -r ) title( Received Signal ) Σε ποιό πλήκτρο αντιστοιχεί? Επεξεργασία ήχου Μ. ρακόπουλος 5 Σήµα µε ϑόρυβο 3 Received Signal 2 2 3 5 5 2 25 3 Επεξεργασία ήχου Μ. ρακόπουλος 6 9
Συσχέτιση διανυσµάτων x T y cos xy = x y function c = cos_xy(x,y) % x and y are column n-vectors % c is the cosine of the angle between them c = abs(x *y)/(norm(x)*norm(y)); Επεξεργασία ήχου Μ. ρακόπουλος 7 function ShowCosines(y) % Shows the cosine that signal y makes with each of the 4 perfect row % signals and each of the three perfect column signals. % Set up the perfect signal matrices... Fs = 32768; tvals = :(/Fs):.25; tau = 2*pi*tVals ; fr = [697 77 852 94]; truer = [sin(tau*fr()) sin(tau*fr(2)) sin(tau*fr(3)) sin(tau*fr(4))]; fc = [29 336 477]; truec = [sin(tau*fc()) sin(tau*fc(2)) sin(tau*fc(3))]; % Compute the row and column cosines... for i=:4 rowcosine(i) = cos_xy(y,truer(:,i)); end for i=:3 colcosine(i) = cos_xy(y,truec(:,i)); end % Display... subplot(,2,); bar(rowcosine); title( Row Cosines ) subplot(,2,2); bar(colcosine); title( Column Cosines ) Επεξεργασία ήχου Μ. ρακόπουλος 8
% Examines the Touch-tone system in the presence of noise. for Trial = : end % Choose a button at random... i = ceil(rand*4); j = ceil(rand*3); % Generate and the tone... [tvals,y] = MakeShowPlay(i,j); % "Send" a noisy version... y = SendNoisy(tVals,y); % "Receive" and decipher... ShowCosines(y) pause(2) Επεξεργασία ήχου Μ. ρακόπουλος 9 Αναγνώριση πλήκτρου.5.5.5.5.6.4.2 Original Signal( Row = 2, Col = 3 ) 5 5 2 25 3 Received Signal Row Cosines Column Cosines.4.2 2 3 4 2 3 Επεξεργασία ήχου Μ. ρακόπουλος 2