final project matlab session 2

34
Final Project Part II MATLAB Session ES 156 Signals and Systems 2007 SEAS Prepared by Frank Tompkins

Upload: rana-ahtisham-ali

Post on 16-Sep-2015

17 views

Category:

Documents


1 download

DESCRIPTION

Image transmission

TRANSCRIPT

  • Final Project Part IIMATLAB SessionES 156 Signals and Systems 2007

    SEAS

    Prepared by Frank Tompkins

  • Outlinefreqz() commandStep by step through the communication systemExplanation of new concepts and new MATLAB functionsHigh-level view of flow through the systemNext week we talk in more detail about implementationEye diagrams

  • Start Early!Project is complexNot something you can do in one dayLess hand-holding than MATLAB exercises in homeworkMore like real-life projectsExtra office hours possibleEmail us if you have questions/problems

  • freqz()Same inputs as filter()Plots frequency response

    Outputs frequency responsechannelFilterTaps = [1 0 -1/2 3/8 zeros(1,28)];freqz(channelFilterTaps, 1);channelFilterTaps = [1 0 -1/2 3/8 zeros(1,28)];H = freqz(channelFilterTaps, 1, 256); % evaluate H(ejw) at 256 points

  • Overall IdeaWant to transmit a digital image from point A to point B using radio waves, etc.We wont actually build antennas/wiresSimulate the whole thing in MATLABHave to convert digital image to a wave that can travel through the air, a wire, etc. at point AThen convert wave back to a digital image at point BWell transmit DCTs instead of actual image pixels, as is often done in real life applications

  • Image Pre-ProcessingBreak image into 8 pixel by 8 pixel blocks and take DCT of each blockQuantize DCT coefficients into 256 levels by representing them as 8-bit unsigned numbers

  • blkproc()MATLAB command for applying a function in blocks to a matrixExample: apply DCT in 8 by 8 blocksI = imread(myimage.tif');fun = @dct2;J = blkproc(I, [8 8], fun);

  • QuantizationApproximate a continuous range of values by a set of discrete values

  • QuantizationIn MATLAB uint8()

    For images, we have to scale to [0,1] before quantizing with im2uint8()

    x = 5.7; % x is double precision (32-bit floating point)xq = uint8(x); % xq is an 8-bit unsigned integerxscaled = (1.4 - x) / (1.4 - 6.3); % x is an image matrixxq = im2uint8(xscaled);

  • Conversion to a bit streamUsing reshape()and permute()Arrange 8 x 8 DCT blocks into groups of N blocks eachReshape each block into a vector (length 8*8*N) to be transmitted laterConvert each pixel in vector to a binary number

  • Conversion

  • reshape()Takes elements columnwise>> x = [1 2 3; 4 5 6; 7 8 9]'x = 1 4 7 2 5 8 3 6 9>> reshape(x,1,9)ans = 1 2 3 4 5 6 7 8 9

  • permute()>> x = rand(1,2,2)x(:,:,1) = 0.4565 0.0185x(:,:,2) = 0.8214 0.4447>> permute(x,[2 1 3])ans(:,:,1) = 0.4565 0.0185ans(:,:,2) = 0.8214 0.4447

  • de2bi()>> x = [4; 212; 19]x = 4 212 19>> de2bi(x)ans = 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0 0 0

  • ModulationModulate each bit by a sine wave and put into the channelImplementation details are up to youWhat is written in the PDF file is a suggestionWe will however take off points if you use more than one for loop in your codeThat one should loop over the N-sized block groups to send each one through the channel in turn

  • Pulse Amplitude ModulationPAM for shortWe will use a specific simple type: half-sine pulseTo send a bitFor a 1 send sin(t)For a 0 send sin(t)

  • Modulated [1 0 0 1]

  • ChannelAtmosphere, telephone wire, coaxial cableWe model it as an LTI systemImpulse response h(t)In using MATLAB, must approximate by discrete time system h[n]

  • NoiseWe will use zero mean AWGNAdditive White Gaussian NoiseAdd an independent Gaussian random variable to each sample passed through the channel

  • AWGNnoisePower = 2; % variance of Gaussian random variableresult = signalFromChannel + sqrt(noisePower) * randn(rows, cols);>> randn(2,3)ans = -0.4326 0.1253 -1.1465 -1.6656 0.2877 1.1909y[n] = h[n] * x[n] + noise[n]

  • [1 0 0 1] After Channel and Noise

  • Receiver EqualizationAttempt to undo distortion of modulated signal (sine wave) due to channel and noiseWe will try two equalizing filtersZero Forcing (ZF)Minimum Mean Square Error (MMSE)

  • Zero Forcing (ZF) FilterJust the inverse of the channel responseIf H(ejw) is the response of the channel, then the ZF filter has response 1 / H(ejw)Clearly if there were no noise, ZF filter would perfectly recover modulated signalBut since ZF doesnt take noise into account at all, it will perform very badly if noise is strong

  • MMSE FilterTakes noise into accountDerived by minimizing the average errorWell just take it on faithIf H(ejw) is the response of the channel, then the MMSE filter has response

  • DetectionExamine equalized signal to determine whether a 1 or a 0 was sent over channelOptimal detector is a thresholder

  • Threshold DetectorIntegrate (sum) the transmitted and equalized half-sine pulseIf integral (sum) < 0, decide a 0 was sentElse decide a 1 was sent

  • Conversion to an ImageAfter receiving all block groups, use reshape()and permute() to rebuild the block DCT image

  • Conversion to an Image

  • Image Post-ProcessingUse blkproc() to compute inverse block DCTThats it!

  • Things To Play WithNoise PowerIncreasing noise power will cause more distortion in received imageZF/MMSE EqualizersSince MMSE handles noise, it should perform better than ZFEye DiagramsComing up nextDifferent ChannelsOptional

  • Eye DiagramsUsed to visualize how waveforms used to send (modulate) multiple bits of data can lead to detection errorsThe more open the eye, the lower the probability of errorConsider modulated half-sine pulses for four subsequent transmitted bits

  • Modulated [1 0 0 1]

  • [1 0 0 1] After Channel and Noise

  • [1 0 0 1] Eye DiagramsBefore Channel After Channel