Similar documents
Sampling and Interpolation. Yao Wang Polytechnic University, Brooklyn, NY11201

Sachin Patel HOD I.T Department PCST, Indore, India. Parth Bhatt I.T Department, PCST, Indore, India. Ankit Shah CSE Department, KITE, Jaipur, India

521466S Machine Vision Assignment #7 Hough transform

Signal Processing First Lab 01: Introduction to MATLAB. 3. Learn a little about advanced programming techniques for MATLAB, i.e., vectorization.


Time series analysis Matlab tutorial. Joachim Gross

Introduction to Matlab

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

SGN-1158 Introduction to Signal Processing Test. Solutions

Convolution. 1D Formula: 2D Formula: Example on the web:

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

To determine vertical angular frequency, we need to express vertical viewing angle in terms of and. 2tan. (degree). (1 pt)

Linear Filtering Part II

WEEK #3, Lecture 1: Sparse Systems, MATLAB Graphics

Image Compression through DCT and Huffman Coding Technique

Otis Photo Lab Inkjet Printing Demo

Admin stuff. 4 Image Pyramids. Spatial Domain. Projects. Fourier domain 2/26/2008. Fourier as a change of basis

Superresolution images reconstructed from aliased images

chapter Introduction to Digital Signal Processing and Digital Filtering 1.1 Introduction 1.2 Historical Perspective

3. Interpolation. Closing the Gaps of Discretization... Beyond Polynomials

CHAPTER 3: DIGITAL IMAGING IN DIAGNOSTIC RADIOLOGY. 3.1 Basic Concepts of Digital Imaging

PHOTO RESIZING & QUALITY MAINTENANCE

Understanding CIC Compensation Filters

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

Introduction to MATLAB (Basics) Reference from: Azernikov Sergei

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

Frequency Response of FIR Filters

Introduction to IQ-demodulation of RF-data

MassArt Studio Foundation: Visual Language Digital Media Cookbook, Fall 2013

Finite cloud method: a true meshless technique based on a xed reproducing kernel approximation

Introduction to Logistic Regression

Microsoft Excel 2010 Training. Use Excel tables to manage information

AC : MATHEMATICAL MODELING AND SIMULATION US- ING LABVIEW AND LABVIEW MATHSCRIPT

Fireworks CS4 Tutorial Part 1: Intro

VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

UNIVERSITY OF CALIFORNIA, SAN DIEGO Electrical & Computer Engineering Department ECE Fall 2010 Linear Systems Fundamentals

IMPROVEMENT OF DIGITAL IMAGE RESOLUTION BY OVERSAMPLING

CHAPTER 6 Frequency Response, Bode Plots, and Resonance

Lab 1. The Fourier Transform

Create a folder on your network drive called DEM. This is where data for the first part of this lesson will be stored.

0 Introduction to Data Analysis Using an Excel Spreadsheet

Video-Conferencing System

CHOOSING A COLLEGE. Teacher s Guide Getting Started. Nathan N. Alexander Charlotte, NC

WEBFOCUS QUICK DATA FOR EXCEL

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Tactile and Advanced Computer Graphics Module 5. Graphic Design Fundamentals

6.025J Medical Device Design Lecture 3: Analog-to-Digital Conversion Prof. Joel L. Dawson

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Vi, fi input. Vphi output VCO. Vosc, fosc. voltage-controlled oscillator

Computational Foundations of Cognitive Science

Manifold Learning Examples PCA, LLE and ISOMAP

(Refer Slide Time: 01:11-01:27)

Lecture 1-6: Noise and Filters

Appendix 4 Simulation software for neuronal network models

A Novel Method to Improve Resolution of Satellite Images Using DWT and Interpolation

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

6 Scalar, Stochastic, Discrete Dynamic Systems

Preparing Images for PowerPoint, the Web, and Publication

Spike-Based Sensing and Processing: What are spikes good for? John G. Harris Electrical and Computer Engineering Dept

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

Sampling Theorem Notes. Recall: That a time sampled signal is like taking a snap shot or picture of signal periodically.

High Quality Image Magnification using Cross-Scale Self-Similarity

6. Cholesky factorization

The Image Deblurring Problem

BNG 202 Biomechanics Lab. Descriptive statistics and probability distributions I

Correlation and Convolution Class Notes for CMSC 426, Fall 2005 David Jacobs

Polynomial Degree and Finite Differences

Data Analysis. Using Excel. Jeffrey L. Rummel. BBA Seminar. Data in Excel. Excel Calculations of Descriptive Statistics. Single Variable Graphs

Project 3: Image Enhancement - Spatial vs. Frequency Domain Filters. Steven Young: ECE 572

A HYBRID APPROACH FOR AUTOMATED AREA AGGREGATION

Lab 5 Getting started with analog-digital conversion

Chapter 3 SYSTEM SCANNING HARDWARE OVERVIEW

CATIA V5 Tutorials. Mechanism Design & Animation. Release 18. Nader G. Zamani. University of Windsor. Jonathan M. Weaver. University of Detroit Mercy

Final Year Project Progress Report. Frequency-Domain Adaptive Filtering. Myles Friel. Supervisor: Dr.Edward Jones

OPTOFORCE DATA VISUALIZATION 3D

Making TIFF and EPS files from Drawing, Word Processing, PowerPoint and Graphing Programs

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Getting started in Excel

Analecta Vol. 8, No. 2 ISSN

A Short Introduction to Computer Graphics

Scientific Graphing in Excel 2010

Solving Systems of Linear Equations

Department of Electrical and Computer Engineering Ben-Gurion University of the Negev. LAB 1 - Introduction to USRP

2+2 Just type and press enter and the answer comes up ans = 4

EXPERIMENT NUMBER 5 BASIC OSCILLOSCOPE OPERATIONS

A Concrete Introduction. to the Abstract Concepts. of Integers and Algebra using Algebra Tiles

A System for Capturing High Resolution Images

Analysis/resynthesis with the short time Fourier transform

Tutorial for Assignment #2 Gantry Crane Analysis By ANSYS (Mechanical APDL) V.13.0

Lezione 6 Communications Blockset

TTT4110 Information and Signal Theory Solution to exam

The continuous and discrete Fourier transforms

Operation Count; Numerical Linear Algebra

Assessment of Camera Phone Distortion and Implications for Watermarking

Personal Identity Verification (PIV) IMAGE QUALITY SPECIFICATIONS FOR SINGLE FINGER CAPTURE DEVICES

Transition Bandwidth Analysis of Infinite Impulse Response Filters

Transcription:

DSP First Laboratory Exercise #9 Sampling and Zooming of Images In this lab we study the application of FIR ltering to the image zooming problem, where lowpass lters are used to do the interpolation needed for high quality zooming. The zooming problem is basically the same as the D-to-A reconstruction problem treated in Chapter 4. 1 Overview If you have not already done Lab 8, please read the introduction of that lab for important information on the display and printing of images. 2 Warm-up: Linear Interpolation In Section 3.2, we will be interest in image zooming which is an interpolation problem. Before processing images, however, we consider the following one-dimensional interpolation problem. (a) Generate a sequence of data samples with two zeros between each non-zero sample: xss = zeros(1,19) samp = [1 3-2 4 2-1 -3] xss(1:3:19) = samp (b) Now process this sequence through an FIR lter with \triangular" coecients. coeffs = [1/3, 2/3, 1, 2/3, 1/3] output = firfilt(xss,coeffs) What observations can you make regarding the similarities between the sequence output and the nonzero samples of the original sequence (xss)? Do you notice a relative shift between these two sequences? Measure the length of this time shift in samples. Explain why the output of the triangle FIR lter is a linearly interpolated version of the input sequence. (c) Write the dierence equation for the \triangular" lter dened by coeffs in part (b). Now calculate, by hand, the output of the lter to the input sequence x[n] = [n]+0:5[n ; 3]: (1) = 8 < : 1 when n =0 0:5 when n =3 0 else Do not use Matlab to complete this exercise. The purpose is to understand exactly how the linearly interpolated output is generated when you implement the dierence equation. Instructor Verication (separate page) In summary, we notice that linear interpolation involves two steps. The rst step is zero lling, where the number of zeros inserted between each sample determines the degree of interpolation. The second step is FIR ltering with the appropriate triangle coecients. 1 (2)

3 Lab: Sampling of Images The images that are stored on the computer have to be sampled images because they are stored in an M N array. The sampling rate in the two spatial dimensions was chosen at the time the image was digitized (in units of samples per inch if the original was a photograph). However, we can simulate a lower sampling rate by simply throwing away samples in a periodic way. If every other sample is removed, the sampling rate will be halved. Sometimes this is called sub-sampling or down-sampling. So, for example, if you have a vector x1 representing a signal such as arow of an image, we canreduce the sampling rate by a factor of 4 by simply taking every 4 th sample. In Matlab this is easy with the colon operator, i.e., xs = x1(1:4:length(x1)). The vector xs is one fourth the length of x1. An alternative sampling strategy is to take every 4 th sample, but place zeros in between. The M-le below called imsample( ) will perform this type of sampling on an image, e.g., xs = imsample(xx,4):. (a) Explain how the function imsample.m works: function yy = imsample(xx, P) %IMSAMPLE Function for sub-sampling an image % usage: yy = imsample(xx, P) % xx = input image to be sampled % P = sub-sampling period (an integer like 2,3,etc) % yy = output image % [M,N] = size(xx) S = zeros(m,n) S(1:P:M,1:P:N) = ones(length(1:p:m), length(1:p:n)) yy = xx.* S (b) Execute the statement xs = imsample(xx,4) and use show img( ) to plot the images xs and xx. From the plot you should see that imsample( ) throws away samples by setting them to zero. The samples that it keeps remain in their original spatial locations. With the zero samples included, the \sampled image" has the same spatial dimensions as the original when displayed on the screen. (c) Down-sampling throws away samples, so it will shrink the size of the image. This is what is done by the following scheme: xp = xx(1:p:m,1:p:n) One potential problem with down-sampling is that aliasing might occur. This can be illustrated in a dramatic fashion with zone plate image, or the lenna image. Now down-sample the zone plate image by a factor of 2. Notice the aliasing in the downsampled image, which is surprising since no new values are being created by the downsampling process. Describe how the aliasing appears visually. 1 1 One diculty withshowing aliasing is that we must display the pixels of the image exactly. This almost never happens because most monitors and printers will perform some sort of interpolation to adjust the size of the image to match the resolution of the device. In Matlab we can override these size changes by using the function truesize which is part of the Image Processing Toolbox. 2

Down-sample the lenna image by a factor of 2. Notice that this image seems to be relatively unaected by the down-sampling by 2 process, what can you say about the frequency content of the lenna image as opposed to the zone plate image? 3.1 Reconstruction of Images When an image has been sampled, we can ll in the missing samples by doing interpolation. For images, this would be analogous to the examples shown in Chapter 4 for sine-wave interpolation which is part of the reconstruction process in a D-to-A converter. We could use a \square pulse" or a \triangular pulse" or other pulse shapes. For these reconstruction experiments, use either the tools image or the lenna image. It would be wise to put the original image and all the ltered reconstructions on the screen in dierent gure windows for easy comparison. (a) The simplest interpolation would be the square pulse which produces a \zero-order hold." We could ll in the gaps between samples in each row with the following statement: xs = imsample(xx,4) bs = ones(1,4) yhold = conv2(xs,bs) Try this and plot the result yhold. %--- Length-4 square pulse %--- 2-D FIR filtering (horizontally) (b) Now lter the columns of yhold to ll in the missing points in each column and compare the result to the original image xx. (c) Linear interpolation: Now use what you learned about linear interpolation in the warm-up section to determine an FIR lter that will perform linear interpolation on the rows and columns of the sub-sampled (by 4)signal. This lter must have coecients fb k g that follow a triangle shape, and the order must be M =6. (d) Carry out the linear interpolation operations using Matlab's conv2 function. Call the interpolated output ylin. Compare ylin to the original image xx and to the square pulse interpolated image. Comment on the visual appearance of the two \reconstructed" images. (e) Compute the frequency response of your linear interpolator used in the previous part. Only the 1-D FIR lter that acts on the rows must be analyzed. Plot its magnitude (frequency) response for ; ^!. (f) Smoothing via Lowpass Filtering: At this point, you should be thinking that interpolation is very similar to lowpass ltering. To test this hypothesis, create a lowpass ltered version xs_filt of the sampled image by ltering the rows and columns with a 23-point FIR lter, whose coecients are given by a modied \sinc" formula: b k = sin((k ; 11)=4) w k (k ; 11)=4 k =0 1 2 ::: 22 where w k is given by: 2k 0:54 ; 0:46 cos k =0 1 2 ::: 22 22 Remember that Matlab will have problems evaluating b 11 because the sinc function is an indeterminate form when k =11. You will have to compute b 11 yourself and include it at the proper location in the vector b k. Compare xs_filt to the original image. In addition, plot the magnitude of the frequency response for this FIR lter. 3

3.2 Zooming for an Image Zooming in on a section of an image is very similar to the D-to-A reconstruction process because it also requires interpolation. The three interpolation systems (zero-order hold, linear interpolation, and lowpass ltering) developed in the previous section, can be applied to do zooming by a factor of four. (a) Take a small patch of an image (about 50 50) where there is some interesting detail (e.g., the eye or feather of lenna). There are several ways to produce a larger image that appears zoomed. One way is to simply repeat pixel values. So in order to zoom a 50 50 section up to 200 200, you would repeat each pixel four times in each direction. Display a zoomed portion of an image by repeating pixel values. (b) Another way to produce a larger image is to insert zeros between the existing samples. In other words, you must produce an image that is 200 200 with data values only in rows or columns whose index is a multiple of four. Consider the following code that does this for a 1-D vector. L = length(xx) yy = zeros(1,4*l) yy(4:4:4*l) = xx Generalize this idea to write a function that will insert zeros in the rows and columns of a 2-D image. (c) Now lter the image from part (b) to do the interpolation. Use both the linear and the \sinc" function interpolators. (d) Comment on the ability of all three zooming operators to preserve detail and edges in the image while expanding the size of details. Try to explain your observations by considering the frequency content of the \zoomed" image. (e) Matlab has a zoom command in the Image Processing Toolbox. The function is called imzoom. If this is available on your system, try to determine what sort of interpolation scheme it is using. 4

Lab 9 Instructor Verication Sheet Staple this page to the end of your Lab Report. Name: Date: Part 2 Perform linear interpolation by hand: Veried: 5