%% median filtering >> j = imread('eight.jpg'); >> subplot(1,3,1); >> imshow(j) >> k = imnoise(j , 'salt & pepper'); >> subplot(1,3,2); >> imshow(k); >> r = rgb2gray(k); >> c = medfilt2(r, [3 3]); >> subplot(1,3,3); >> imshow(r) %% mean convolution >> j = imread('cameraman.jpg'); >> imshow(j); >> h = [1 1 1;1 1 1;1 1 1] / 9 ; >> c = imfilter(j,h); >> imshow(c) %% connected component I = imread('grains2.jpg'); >> imshow(I) >> j = rgb2gray(I); >> j2 = ThresholdingFirst(j); >> cc = bwconncomp(j,8); >> n = cc.NumObjects; %% edge detection (sobel) >> j = imread('cameraman.jpg'); >> r = rgb2gray(j); >> h = [1 0 -1;2 0 -2;1 0 -1] >> c = imfilter(r,h); >> imshow(c) >> %% edge detection (canny) BW = edge(r , 'canny'); imshow(BW) %% fourier series of a square wave syms n t >> w0 = pi; >> T0 = 2; >> n = 1:5; >> a0 = (1/T0) * int(1,t,0,1) an = (2/T0) * int(cos(n*w0*t),t,0,1) bn = (2/T0) * int(sin(n*w0*t),t,0,1) %% fourier transformation Fs = 1000; %% sampling frequency >> Ts = 1/Fs; %% sampling period >> dt = 0:Ts:2-Ts ; % signal duration >> >> f1 = 10; >> f2 = 30; >> f3 = 70; >> >> y1 = 10 * sin(2*pi*f1*dt); >> y2 = 10 * sin(2*pi*f2*dt); >> y3 = 10 * sin(2*pi*f3*dt); >> >> y = y1+y2+y3 ; >> >> subplot(4,1,1) ; plot(dt,y1,'r'); >> subplot(4,1,2) ; plot(dt,y2,'r'); >> subplot(4,1,3) ; plot(dt,y3,'r'); >> subplot(4,1,4) ; plot(dt,y,'r');