Lecture 19 Chapter 13 Images continued. Outline from Chapter 12 -1 13.4 Operating on Images.

Slides:



Advertisements
Similar presentations
DCSP-3: Fourier Transform (continuous time) Jianfeng Feng
Advertisements

Guerino Mazzola (Fall 2014 © ): Introduction to Music Technology IIIDigital Audio III.6 (Fr Oct 24) The MP3 algorithm with PAC.
Time-Frequency Analysis Analyzing sounds as a sequence of frames
SOUND with MATLAB. SOUND INPUT [a, fa, na]= wavread(’mim wav') Sound data Sampling Frequency #bit representation.
CMPS1371 Introduction to Computing for Engineers PROCESSING SOUNDS.
3.1 Chapter 3 Data and Signals Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 3 Data and Signals
1 Chapter 16 Fourier Analysis with MATLAB Fourier analysis is the process of representing a function in terms of sinusoidal components. It is widely employed.
DFT/FFT and Wavelets ● Additive Synthesis demonstration (wave addition) ● Standard Definitions ● Computing the DFT and FFT ● Sine and cosine wave multiplication.
Intro to Spectral Analysis and Matlab. Time domain Seismogram - particle position over time Time Amplitude.
What is Sound? Sound is the movement of energy through substances in longitudinal (compression/rarefaction) waves. Sound is produced when a force causes.
Note To be transmitted, data must be transformed to electromagnetic signals.
1 Lecture 27 Physical Layer (Data and Signals) University of Nevada – Reno Computer Science & Engineering Department Fall 2010 CPE 400 / 600 Computer Communication.
SIMS-201 Characteristics of Audio Signals Sampling of Audio Signals Introduction to Audio Information.
IT-101 Section 001 Lecture #8 Introduction to Information Technology.
DREAM PLAN IDEA IMPLEMENTATION Introduction to Image Processing Dr. Kourosh Kiani
1 Audio Compression Techniques MUMT 611, January 2005 Assignment 2 Paul Kolesnik.
Chapter 12 Fourier Transforms of Discrete Signals.
Key Detection In Musical Signals Philip Brown, ’07 Advisor: Dr. Shane Cotter.
Lecture 12: Introduction to Discrete Fourier Transform Sections 2.2.3, 2.3.
© 2010 Pearson Education, Inc. Conceptual Physics 11 th Edition Chapter 21: MUSICAL SOUNDS Noise and Music Musical Sounds Pitch Sound Intensity and Loudness.
Digital Audio Multimedia Systems (Module 1 Lesson 1)
Basics of Signal Processing. frequency = 1/T  speed of sound × T, where T is a period sine wave period (frequency) amplitude phase.
Computer Science 121 Scientific Computing Winter 2014 Chapter 13 Sounds and Signals.
Where we’re going Speed, Storage Issues Frequency Space.
GCT731 Fall 2014 Topics in Music Technology - Music Information Retrieval Overview of MIR Systems Audio and Music Representations (Part 1) 1.
Chapter 2. Image Analysis. Image Analysis Domains Frequency Domain Spatial Domain.
Basics of Signal Processing. SIGNALSOURCE RECEIVER describe waves in terms of their significant features understand the way the waves originate effect.
Lecture # 22 Audition, Audacity & Sound Editing Sound Representation.
ACOUSTICS AND THE ELEMENTS OF MUSIC Is your name and today’s date at the top of the worksheet now?
GG 313 Lecture 26 11/29/05 Sampling Theorem Transfer Functions.
Motivation Music as a combination of sounds at different frequencies
Simple Image Processing Speaker : Lin Hsiu-Ting Date : 2005 / 04 / 27.
Preprocessing Ch2, v.5a1 Chapter 2 : Preprocessing of audio signals in time and frequency domain  Time framing  Frequency model  Fourier transform 
Electronic Communications: A Systems Approach Beasley | Hymer | Miller Copyright © 2014 by Pearson Education, Inc. All Rights Reserved Information and.
Wireless and Mobile Computing Transmission Fundamentals Lecture 2.
Chapter 3 Data and Signals
Filtering Robert Lin April 29, Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview.
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
Lecture 7: Sampling Review of 2D Fourier Theory We view f(x,y) as a linear combination of complex exponentials that represent plane waves. F(u,v) describes.
1 Introduction to Information Technology LECTURE 6 AUDIO AS INFORMATION IT 101 – Section 3 Spring, 2005.
Sound Representation Digitizing Sound Sound waves through Air Different Voltages Voltage converted to numbers.
EE 113D Fall 2008 Patrick Lundquist Ryan Wong
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Engineering Computation with MATLAB Second Edition by David M. Smith.
Fourier Transform.
Dr. Abdul Basit Siddiqui FUIEMS. QuizTime 30 min. How the coefficents of Laplacian Filter are generated. Show your complete work. Also discuss different.
Computer Graphics & Image Processing Chapter # 4 Image Enhancement in Frequency Domain 2/26/20161.
Lecture 4-1CS251: Intro to AI/Lisp II Where did that edge go? April 29th, 1999.
Design of a Guitar Tab Player in MATLAB Background Lecture
Eeng Chapter 2 Discrete Fourier Transform (DFT) Topics:  Discrete Fourier Transform. Using the DFT to Compute the Continuous Fourier Transform.
Physical characteristics of sound Amplitude – The measure of displacement of the air pressure wave Frequency – Represents the number of periods.
Ch. 2 : Preprocessing of audio signals in time and frequency domain
Fourier Series Prof. Brian L. Evans
CS 591 S1 – Computational Audio
COMPUTER NETWORKS and INTERNETS
Chapter 2 Data and Signals
III Digital Audio III.6 (Fr Oct 20) The MP3 algorithm with PAC.
MECH 373 Instrumentation and Measurements
MECH 373 Instrumentation and Measurements
CHAPTER 3 DATA AND SIGNAL
Intro to Fourier Series
Representing Sound 2.6 – Data Representation.
III Digital Audio III.6 (Mo Oct 22) The MP3 algorithm with PAC.
7.2 Even and Odd Fourier Transforms phase of signal frequencies
EEE 244-6: Fourier Transform (FFT) and Signal Processing
Lecture 2: Frequency & Time Domains presented by David Shires
COMS 161 Introduction to Computing
Govt. Polytechnic Dhangar(Fatehabad)
Lec.6:Discrete Fourier Transform and Signal Spectrum
Matlab Tutorial #2 Kathleen Chen February 13, 2018.
Presentation transcript:

Lecture 19 Chapter 13 Images continued

Outline from Chapter Operating on Images

Modifying an Image Locating an image within another image – Scene – Place an object into the scene scene = imread ('C:\Documents and Settings\All Users\Documents\My Pictures \Sample Pictures\Water lilies.jpg'); image(scene); %bumblebee? bee1 = imread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009 \bee1.jpg'); image(bee1); beeSize = 75; clippedBee1 = bee1(1:beeSize, 1:beeSize, :); image(clippedBee1); %initialize scene beeInScene = scene; beeInScene(1:beeSize, 1:beeSize, :) = clippedBee1; image(beeInScene)

Rotating an Image %rotate the bee, around the center of the image rotatedBee = clippedBee1; for theta = linspace(0,-pi/2,4) for xBee = 1:beeSize for yBee = 1:beeSize centeredX = xBee-beeSize/2; centeredY = yBee-beeSize/2; newCenteredCoordinatesBee = rotation2D(theta)*[centeredX centeredY]'; newCoordinatesBee = newCenteredCoordinatesBee + beeSize/2 newCoordinatesBee = round(newCoordinatesBee); if newCoordinatesBee(1)<1 newCoordinatesBee(1) = 1; end; if newCoordinatesBee(2)<1 newCoordinatesBee(2) = 1; end; if newCoordinatesBee(1)>beeSize newCoordinatesBee(1) = beeSize; end; if newCoordinatesBee(2)>beeSize newCoordinatesBee(2) = beeSize; end; rotatedBee(newCoordinatesBee(1,1), newCoordinatesBee(2,1), :) = clippedBee1(xBee, yBee, :); end beeInScene = scene; beeInScene(lastXlocs, lastYlocs, :) = rotatedBee; image(beeInScene) pause(.1) end

Setting a Region within an Image for time = t x = 8*time; y = 5*time; xlocations = round((1:beeSize)+x); ylocations = round((1:beeSize)+y); beeInScene = scene; beeInScene(xlocations, ylocations, :) = clippedBee1; image(beeInScene) pause(.05) lastXlocs = xlocations; lastYlocs = ylocations; end

Color Adjustment Via Mask Use the image to develop a logical array Use the logical array as a mask Update the image where mask allows

Green in Moth We can use the combination of the presence of high level of green with the lower levels of red and blue, to identify the moth, e.g., >150.

Develop the Mask mask(mothSize,mothSize,3) = 0; %establish size, mask(:,:,3) = 0; %no changes to blue, yet mask(:,:,1) = 0; %no changes to red, yet mask(:,:,2) = clippedMoth1(:,:,2)>greenThreshold... & clippedMoth1(:,:,1)<redThreshold... & clippedMoth1(:,:,3)<blueThreshold; %if the green is > threshold, and blue and red are below theirs %then allow green level at that pixel to change

Apply the Mask greenerMoth = clippedMoth1; greenerMoth(mask) = uint8(255); mask(:,:,3)=mask(:,:,2);% transfer the locations to the blue signal mask(:,:,2)= 0; %leave green alone greenerMoth(mask) = uint8(0); %no blue mask(:,:,1)=mask(:,:,3); %transfer the locations to the red signal mask(:,:,3)=0; %leave the blue alone greenerMoth(mask) = uint8(0); %no red image(greenerMoth)

Enhanced Green

Find Yellow Edges

Arithmetic with Colors yellow = gr + red; plot(red, 'r'); hold on plot(gr, 'g'); plot(bl, 'b'); plot(yellow, 'y');

More Arithmetic with Colors rat = yellow./ bl; subplot(2,1,2) plot(rat,'--k'); Maybe 2.5 has meaning as a threshold; maybe 3.5

Edge Detection in Color

Outline from Chap Physics of Sound 14.2 Recording and Playback 14.3 MATLAB Implementation 14.4 Time Domain Operations – Slicing and Concatenating Sound – Musical Background – Changing Sound Frequency Poorly – Changing Sound Frequency Well

Physics of Sound Dynamic range: soft sounds and loud sounds have significantly different levels, so a logarithmic scale is used Frequencies serve as a basis set for describing waveforms. Spectral decomposition is extremely useful.

Recording and Playback Capturing the dynamic range: many significant bits – Approximately softest sound is 10 billion times softer than the loudest comfortable sound – 16 bits is popular Capturing the high frequency content: high enough sampling rate. – Highest frequency heard said to be 20 kiloHertz – Sample at twice that suggests 40 kHz

In MATLAB -1 Read with – Wavread for.wav files – Auread for.au files – [Y,FS,NBITS]=WAVREAD(FILE) returns the sample rate (FS) in Hertz and the number of bits per sample (NBITS) used to encode the data in the file. [b16, F16, n] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\chimes.wav'); sound(b16, F16) [bb16, FF16, n] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\ding.wav'); sound(bb16, FF16) [bbb16, FFF16, n] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\tada.wav'); sound(bbb16, FFF16)

In MATLAB -2 Concatenation longSound = [b16; bb16; bbb16]; sound(longSound,FFF16)

In MATLAB -3 Examining the time domain waveform

In MATLAB - 4 Selecting in the time domain piece1Start = round(length(b16)*(1/4)); piece1End = round(length(b16)*(3/4)); piece1 = b16(piece1Start:piece1End,:);

Modify Frequency by Resampling Here the Resampling Is by Subset [piano, piano16, n3] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\piano.wav'); sound(piano, piano16) note = piano; half = 2^(1/12); whole = half^2; for index = 1:8 sound(note, piano16); pause(.5); if (index==3)||(index ==7) mult = half; else mult = whole; end note = note(ceil(1:mult:end)); end; File from

Frequency Domain Different from time domain Express our time waveform as a sum of other, simpler time waveforms. f(t) = sum of sin and cos functions, each with an amplitude, and a frequency. Then we can modify the amplitudes of the individual sins and cosines, where the modification depends upon the frequency, to obtain useful effects (like taking the hissy noise out of damaged records).

Waveform Composition An algorithm, the fast Fourier Transform (FFT), calculates the coefficients of the components of the decomposition of a time-domain waveform. Each frequency used in the decomposition has a coefficient. If the coefficients are plotted vs. frequency, that is a spectrum.

In MATLAB FFT operates on time domain to generate frequency component coefficients. iFFT operates on frequency domain coefficients to generate time domain representation.

Example Using FFT dt = 1/400; pts = 10000; f = 8; t = (1:pts)*dt; %sampling times x1 = sin(2*pi*f*t); x2 = 3*sin(2*pi*5*f*t); x3 = 7*sin(2*pi*11*f*t); x=x1+x2+x3; subplot (3,1,1) plot(t(1:end/25),x(1:end/25)); title('Time Domain Sine Waves'); ylabel('Amplitude'); xlabel('Time (Sec)'); Y =fft(x); %Y gets the coefficients df = 1/ t(end); %the frequency spacing fmax = df * pts /2; f = (1:pts)*2*fmax/pts; %frequencies subplot(3,1,2); plot(f, real(Y)); title('Real Part'); xlabel('Frequency (Hz)'); ylabel('Energy'); subplot(3,1,3); plot(f, imag(Y)); title('Imaginary Part'); xlabel('Frequency (Hz)'); ylabel('Energy');

Comparing the Timbre of Instruments

Code for Previous disp('starting timbre') [trumpet, F16, n1] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\trumpet.wav'); sound(trumpet, F16) %F16 ptsTrumpet = length(trumpet); [cello, FF16, n2] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\cello.wav'); sound(cello, FF16) %FF16 ptsCello = length(cello); [piano, FFF16, n3] = wavread('C:\Documents and Settings\therese\My Documents\CSE1100summer2009\piano.wav'); sound(piano, F16) %FFF16 ptsPiano = length(piano); dtTrumpet = 1/F16; dtCello = 1/FF16; dtPiano = 1/FFF16; f = 8; tTrumpet = (1:ptsTrumpet)*dt; %sampling times tCello = (1:ptsCello)*dt; %sampling times tPiano = (1:ptsPiano)*dt; %sampling times pause(tcello(ptsCello)); subplot (3,1,1) plot(tTrumpet(1:round(end/25)),trumpet(1:round(end/25)),' y'); hold on plot(tCello(1:round(end/25)),cello(1:round(end/25)),'r'); plot(tPiano(1:round(end/25)),piano(1:round(end/25)),'g'); title('Time Domain Trumpet'); ylabel('Amplitude'); xlabel('Time (Sec)'); Ytrumpet =fft(trumpet); %Y gets the coefficients Ycello = fft(cello); Ypiano = fft(piano); dfTrumpet = 1/ tTrumpet(end); %the frequency spacing dfCello = 1/ tCello(end); %the frequency spacing dfPiano = 1/ tPiano(end); %the frequency spacing fmaxTrumpet = dfTrumpet * ptsTrumpet /2; fmaxCello = dfCello * ptsCello /2; fmaxPiano = dfPiano * ptsPiano /2; fTrumpet = (1:ptsTrumpet)*2*fmaxTrumpet/ptsTrumpet; %frequencies fCello = (1:ptsCello)*2*fmaxCello/ptsCello; %frequencies fPiano = (1:ptsPiano)*2*fmaxPiano/ptsPiano; %frequencies subplot(3,1,2); plot(fTrumpet, real(Ytrumpet),'y'); hold on plot(fCello, real(Ycello),'r'); plot(fPiano, real(Ypiano),'g'); title('Real Part'); xlabel('Frequency (Hz)'); ylabel('Energy');

More Code subplot(3,1,3); plot(fTrumpet, imag(Ytrumpet)); hold on plot(fCello, imag(Ycello),'r'); plot(fPiano, imag(Ypiano),'g'); title('Imaginary Part'); xlabel('Frequency (Hz)'); ylabel('Energy');