www.gusucode.com > IPCV_Eval_Kit_R2019a_0ce6858工具箱源码程序matlab > IPCV_Eval_Kit_R2019a_0ce6858/code/demo_files/I1_00_MATLAB_intro_audio_img.m

    %% 惓尫攇僨儌
% 弶婜壔
clear;clc;close all;imtool close all

%% 暥朄偺婎杮
t = 0:10             % 儀僋僩儖偺嶌惉丄曄悢愰尵晄梫丅僗僋儕僾僩尵岅
a = t+1              % 儀僋僩儖傗懡師尦攝楍偺傑傑寁嶼丅
b = sin(t)

%% 惓尫攇偺昤夋 (婎杮憖嶌)
t = 0:0.1:1          % 帪娫儀僋僩儖
y = sin(2 * pi * 1 * t)  % 惓尫攇偺惗惉 sin(2兾ft): 儀僋僩儖偺傑傑寁嶼
       % 壜帇壔婡擻丗僾儘僢僩 plot(t,y)   僾儘僢僩Tab偐傜

%% 崅僒儞僾儕儞僌廃攇悢偺惓尫攇惗惉丒壒惡嵞惗 %%%%%%%%%%%%%%%%%%%%%%%
Fs = 44100;                   % 僒儞僾儕儞僌廃攇悢 (44.1kHz)
t  = 0 : 1/Fs : 1;            % 1昩娫暘偺帪娫儀僋僩儖

%% 440Hz偺惓尫攇偺惗惉膼
tone1 = sin(2 * pi * 440  * t);
figure; plot(t, tone1);
xlim([0 0.02]);          
sound(tone1,Fs);                  % 壒惡嵞惗

%% 4184Hz偺惓尫攇偺惗惉膼
tone2 = sin(2 * pi * 4184 * t);   % 4184Hz
figure; plot(t, tone2); xlim([0 0.02]);
sound(tone2,Fs);

%% 2偮偺惓尫攇偺崌惉
tone3 = tone1 + tone2;            % 440Hz + 4184Hz 
figure; plot(t, tone3); xlim([0 0.02]);
sound(tone3,Fs);

%% fft : 廃攇悢幉僾儘僢僩 (僙僋僔儑儞幚峴)
nfft    = 2^16;                         % fft億僀儞僩
f       = 0 : Fs/nfft : Fs - Fs/nfft;   % 廃攇悢儀僋僩儖
TONES    = fft(tone3, nfft); % 帪娫幉偐傜廃攇悢幉偵曄姺 (2^16 FFT億僀儞僩)
TONESpow   = abs(TONES);
figure; plot(f, TONESpow);xlim([0 5000]);

%% 僼傿儖僞偺嶌惉
% 僂傿儞僪僂 儀乕僗偺桳尷僀儞僷儖僗墳摎僼傿儖僞乕偺學悢偺寁嶼
%   B(z)=b(1) + b(2)z-1 + .... + b(n+1)z-N
[num, den] = fir1(20, 1000/(Fs/2))       % 僼傿儖僞揱払娭悢愝寁  20師   僇僢僩僆僼1000Hz
fvtool(num,den);

%% 僼傿儖僞儕儞僌媺蕰\帵
tone3_f  = filter(num, den, tone3);
subplot(2,1,1); plot(t, tone3  ); xlim([0 0.02]); %尦攇宍昞帵
subplot(2,1,2); plot(t, tone3_f); xlim([0 0.02]);

%% 僼傿儖僞儕儞僌慜屻偺壒偺嵞惗
sound(tone3  , Fs);      % 僼傿儖僞傪妡偗傞慜偺壒
sound(tone3_f, Fs);      % 僼傿儖僞傪妡偗偨屻偺壒

%% 夋憸張棟






%% 夋憸曄姺 %%%%%%%%%%
load clown                % MAT僼傽僀儖偐傜丄夋憸僨乕僞'X'丄僇儔乕儅僢僾map偺撉崬傒
figure;imshow(X,map);     % 昞帵
[x,y,z]=cylinder;         % 墌拰嵗昗惗惉
figure;mesh(x,y,z,'edgecolor',[0 0 0]);axis square;  %嵗昗昞帵
warp(x,y,z,flipud(X),map);axis square;shg  %僥僋僗僠儍儅僢僺儞僌

%% 暔懱擣幆 %%%%%%%%%%%
RGB = imread('tape.png');      %夋憸撉崬傒
figure;imshow(RGB);            %夋憸昞帵

%% 墌専弌
[center, radius] = imfindcircles(RGB,[60 100],'Sensitivity',0.9) %墌専弌

%% 寢壥傪昤夋
viscircles(center,radius);
hold on; plot(center(:,1),center(:,2),'yx','LineWidth',4);hold off; % 拞怱揰昞帵
message = sprintf('The estimated radius is %2.1f pixels', radius);
text(15,300,sprintf('radius : %2.1f', radius), 'Color','y','FontSize',20);shg

%%
% Copyright 2014 The MathWorks, Inc.