Image processing in the spatial and frequency domain

Similar documents
Transforms and Frequency Filtering

Image Enhancement in the Spatial Domain Low and High Pass Filtering

Sharpening Spatial Filters ( high pass)

IMAGE ENHANCEMENT IN SPATIAL DOMAIN

Image acquisition. Midterm Review. Digitization, line of image. Digitization, whole image. Geometric transformations. Interpolation 10/26/2016

Midterm Review. Image Processing CSE 166 Lecture 10

Digital Image Processing

MATLAB 6.5 Image Processing Toolbox Tutorial

Fourier transforms, SIM

8. Lecture. Image restoration: Fourier domain

Digital Image Processing. Image Enhancement: Filtering in the Frequency Domain

Prof. Vidya Manian Dept. of Electrical and Comptuer Engineering

Digital Image Processing

It is the speed and discrete nature of the FFT that allows us to analyze a signal's spectrum with MATLAB.

Digital Image Processing COSC 6380/4393

Practical Image and Video Processing Using MATLAB

1.Discuss the frequency domain techniques of image enhancement in detail.

Digital Image Processing. Filtering in the Frequency Domain (Application)

Achim J. Lilienthal Mobile Robotics and Olfaction Lab, AASS, Örebro University

Subband coring for image noise reduction. Edward H. Adelson Internal Report, RCA David Sarnoff Research Center, Nov

Log Booklet for EE2 Experiments

Understanding Digital Signal Processing

The Discrete Fourier Transform. Claudia Feregrino-Uribe, Alicia Morales-Reyes Original material: Dr. René Cumplido

Fourier Transform. Any signal can be expressed as a linear combination of a bunch of sine gratings of different frequency Amplitude Phase

LABORATORY - FREQUENCY ANALYSIS OF DISCRETE-TIME SIGNALS

02/02/10. Image Filtering. Computer Vision CS 543 / ECE 549 University of Illinois. Derek Hoiem

Digital Image Processing

Reading Instructions Chapters for this lecture. Computer Assisted Image Analysis Lecture 2 Point Processing. Image Processing

Department of Electronic Engineering NED University of Engineering & Technology. LABORATORY WORKBOOK For the Course SIGNALS & SYSTEMS (TC-202)

Laboration Exercises in Digital Signal Processing

LAB MANUAL SUBJECT: IMAGE PROCESSING BE (COMPUTER) SEM VII

Electrical & Computer Engineering Technology

Lecture 3 Complex Exponential Signals

CoE4TN4 Image Processing. Chapter 3: Intensity Transformation and Spatial Filtering

The Scientist and Engineer's Guide to Digital Signal Processing By Steven W. Smith, Ph.D.

EE482: Digital Signal Processing Applications

Digital Image Processing

Advanced Audiovisual Processing Expected Background

Chapter 3 Image Enhancement in the Spatial Domain. Chapter 3 Image Enhancement in the Spatial Domain

TDI2131 Digital Image Processing

Color Space 1: RGB Color Space. Color Space 2: HSV. RGB Cube Easy for devices But not perceptual Where do the grays live? Where is hue and saturation?

Vision Review: Image Processing. Course web page:

Frequency Domain Representation of Signals

DIGITAL SIGNAL PROCESSING TOOLS VERSION 4.0

PHYS 352. FFT Convolution. More Advanced Digital Signal Processing Techniques

Frequency Domain Enhancement

LAB 2: Sampling & aliasing; quantization & false contouring

CoE4TN4 Image Processing. Chapter 4 Filtering in the Frequency Domain

Chapter 5 Window Functions. periodic with a period of N (number of samples). This is observed in table (3.1).

Image Enhancement. Image Enhancement

ECE438 - Laboratory 7a: Digital Filter Design (Week 1) By Prof. Charles Bouman and Prof. Mireille Boutin Fall 2015

Midterm is on Thursday!

Computer Vision, Lecture 3

FFT Convolution. The Overlap-Add Method

IIR Filter Design Chapter Intended Learning Outcomes: (i) Ability to design analog Butterworth filters

Part 2: Fourier transforms. Key to understanding NMR, X-ray crystallography, and all forms of microscopy

Table of contents. Vision industrielle 2002/2003. Local and semi-local smoothing. Linear noise filtering: example. Convolution: introduction

Last Lecture. Lecture 2, Point Processing GW , & , Ida-Maria Which image is wich channel?

ECEn 487 Digital Signal Processing Laboratory. Lab 3 FFT-based Spectrum Analyzer

Lecture 3, Multirate Signal Processing

Image Processing Lecture 4

Digital Filters IIR (& Their Corresponding Analog Filters) Week Date Lecture Title

DFT: Discrete Fourier Transform & Linear Signal Processing

Memorial University of Newfoundland Faculty of Engineering and Applied Science. Lab Manual

Lab 3 FFT based Spectrum Analyzer

Design of FIR Filters

Digital Image Processing. Lecture # 3 Image Enhancement

Discrete Fourier Transform (DFT)

Computer Vision. Intensity transformations

Image Processing. Chapter(3) Part 2:Intensity Transformation and spatial filters. Prepared by: Hanan Hardan. Hanan Hardan 1

Image preprocessing in spatial domain

DIGITAL SIGNAL PROCESSING WITH VHDL

30 lesions. 30 lesions. false positive fraction

OFDM Channel Modeling for WiMAX

Implementation of Image Deblurring Techniques in Java

Digital Image Processing 3/e

Filip Malmberg 1TD396 fall 2018 Today s lecture

Sante FFT Imaging Copyright 2018 Santesoft, all rights reserved

2D Discrete Fourier Transform

Fourier analysis of images

DIGITAL FILTERS. !! Finite Impulse Response (FIR) !! Infinite Impulse Response (IIR) !! Background. !! Matlab functions AGC DSP AGC DSP

FFT analysis in practice

SYLLABUS CHAPTER - 2 : INTENSITY TRANSFORMATIONS. Some Basic Intensity Transformation Functions, Histogram Processing.

ECE 421 Introduction to Signal Processing

Interference in stimuli employed to assess masking by substitution. Bernt Christian Skottun. Ullevaalsalleen 4C Oslo. Norway

Signals A Preliminary Discussion EE442 Analog & Digital Communication Systems Lecture 2

Topic 6. The Digital Fourier Transform. (Based, in part, on The Scientist and Engineer's Guide to Digital Signal Processing by Steven Smith)

ACM Fast Image Convolutions. by: Wojciech Jarosz

Chapter 2 Fourier Integral Representation of an Optical Image

Lec 05 - Linear Filtering & Edge Detection

Digital Signal Processing ETI

Filtering. Image Enhancement Spatial and Frequency Based

Digital Signal Processing ETI

The Fourier Transform

CSE 564: Scientific Visualization

Notes on Fourier transforms

Examples of image processing

Signal Processing for Speech Applications - Part 2-1. Signal Processing For Speech Applications - Part 2

DISCRETE FOURIER TRANSFORM AND FILTER DESIGN

Graphs of sin x and cos x

Transcription:

Digital Media Lab 2014-01-28 Applied physics and electronics Ulrik Söderström Image processing in the spatial and frequency domain Fourier transform, Filtering and Image enhancement

Part 1. The Fourier Transform 1.1. Fourier analysis in two dimensions We are going to look at some simple signals in both the spatial- and the frequency domain. In this exercise we are using gray scale images with the size 64 x 64 pixels. Each pixel has a value between 0 and 1. Sometimes you have to rescale the resulting image to come back to values between one and zero. One way to get information about pixel values is the function "hist", which calculates the frequency for each pixel value. Let's start with a "one dimensional" sine wave. In the following code a 64 x 64 pixel image with two periods of a horizontal sine wave is created. The image is shown with "imshow", so we have to rescale the values to lie between 0 and 1 before displaying it. The signal is centred on the x-axis before the Fourier transform is calculated. (fft, fft2, fftshift) clear; %the image will be in format Q x Q Q =64; %number of periods period=2; %orginal image for m=1:1:q for n=1:1:q orig_image(m,n)=0.5+0.5.*sin(2.*pi.*(n./(q./period))); %the "0.5" constants give values between 0 and 1 for use with "imshow" subplot(1,2,1),imshow(orig_image);title('original image'); %delete the added scaling values before FFT, gives values symmetrically around the x- axis A=orig_image-.5; B=abs(fftshift(fft2(A))); subplot(1,2,2),imshow(b);title('magnitude of FFT'); 1.1.1 Try to explain the result! 1.1.2 What happens with the spectrum is the sine wave is vertical? 1.1.3 Create a black image of size 64 x 64 with a 9 x 9 white square in the middle! In this case you might have to rescale the frequency image before you show the result. Try to use a log-transform (log(abs(fftshift(fft2(bild)))+1)), or rescale the image with the formula (bild2=(bildmin(min(bild)))./(max(max(bild))-min(min(bild)))). Is the spectrum looking like you expected? Describe the result. 1.1.4 Repeat the previous experiment but start with an image with zeros all over except one pixel with value 1.

1.2. The importance of object size Go back to problem 1.1.3 but make the square 15 x 15 instead of 9 x 9. 1.2.1 How is spectrum changed? Explain the correspondence between size in spatial and frequency plane. 1.2.2 Fetch a "real" image (you can find smregit.bmp on the home page) and show the corresponding frequency domain image. Try to explain the result! (imread, ind2gray)

Part 2 - Filtering 2.1. Convolution (filtering in the spatial domain) If the filtering function is known and you want to calculate a specific out-signal from the in-signal, you can use two methods. In the spatial domain convolution is used. You apply convolution to the insignal and the impulse response of the filter. Usually the in-signal is a long sequence and the impulse response is a short sequence - usually called the convolution kernel. (conv, conv2) Create an image with a 15 x 15 square in the middle, like the one used in 1.2. Create the following convolution kernel with the code below: 1 1 1 1 1 1 1 1 1 /9 filter1=ones(3, 3)./9; Calculate the output image through convolution. 2.1.1 How is the image changed in the filtering process? Compare the spectra for the images! 2.1.2 Change the size of the filter to size 7 x 7. This is a mean filter, remember to divide each pixel in the filter with the sum of ones in the kernel. Repeat the previous exercise and compare the result! What importance does the size of the kernel have? 2.1.3 The following filter is a Laplace filter: 0 1 0 1-4 1 0 1 0 filter2=[0 1 0; 1-4 1; 0 1 0]; How is the image and its spectrum affected by this kind of filter? 2.2. Filtering in the frequency domain The other method of filtering is filtering in the frequency domain. The transform of the image is multiplied with a filter that attenuates certain frequencies. The filter can either be created directly in the frequency domain or be the transform of a filter created in the spatial domain. In this case the Fourier transform of the image is multiplied with the Fourier transform of the impulse response - the transfer function. Transform both the image and the 3x3 averaging filter to the frequency domain: [M1 N1]=size(bild); [M2 N2]=size(filter); M=M1+M2-1; %The images has to be zero-padded to this size! N=N1+N2-1;

fftbild=fftshift(fft2(bild, M, N)); % calculate the FFT, fftfilter=fftshift(fft2(filter, M, N)); %automatic zero-pad B1=log(abs(fftbild)+1); B1=(B1-min(min(B1)))./(max(max(B1))-min(min(B1))); C1=log(abs(fftfilter)+1); C1=(C1-min(min(C1)))./(max(max(C1))-min(min(C1))); figure subplot(1,2,1),imshow(b1);title('original'); subplot(1,2,2),imshow(c1);title('filter'); A new, filtered, image (in the frequency domain) is created through multiplication: nybild=fftbild.*fftfilter; %element wise multiplication D1=log(abs(nybild)+1); D1=(D1-min(min(D1)))./(max(max(D1))-min(min(D1))); figure subplot(1,2,1),imshow(d1);title('filtered image, magnitude as a function of frequency'); The last step is to do the inverse transform: nybild=fftshift(nybild); %shift back recreate=ifft2(nybild); subplot(1,2,2),imshow(recreate);title('filtered image'); 2.2.1 Describe the function of the filter. How is the image affected? 2.2.2 Compare with the result in 2.1.1 What is the difference? 2.2.3 See also what happens with a 7 x 7 filter. Compare with 2.1.2! 2.2.4 Change the kernel to a Laplace filter and repeat the filtering. Compare with 2.1.3. 2.2.5 Create a filter directly in the frequency domain. For example, you can create an ideal low pass filter: [M, N]=size(fftbild); radius=15; filter=zeros(m, N); for i=1:m for j=1:n if (((i-(m+1)/2).^2+(j-(n+1)/2).^2).^0.5)<=radius filter(i,j)=1; Remember to do the zero-padding (double the size of the image in the transformation process). After the filtering you can go back to the original size with "imcrop". Try the filter above. What happens if the radius of the filter is changed? As you see - ideal filter will produce ripple.

2.2.6 Change the filter to get the "opposite" effect! If you have used the filter above, change it to a highpass filter. Describe the effect of this filter. 2.2.7 Discuss advantages and disadvantages with filtering in spatial and i frequency domain. You can get some hints on page 166 in the book

Part 3 - Image enhancement 3.1.Sharpening of images With a high pass filter it is possible to emphasize the contour of an object. This is usually a useful first step in further automatic manipulations of the image, but the result does not look "better" for the human eye. It is more common that you want to "sharpen" the image by enhancing its contours. This can be done by combining the original image with a high pass filtered version of it. On the home page you can find the image "debbie4.bmp" (imread, ind2gray). A high pass filter can be combined with the original image through the following filter: 0-1 0 0-1 0 0 0 0-1 5-1 = -1 4-1 + 0 1 0 0-1 0 0-1 0 0 0 0 3.1.1 Convolute the image with the filter. Show the result and describe the effect. 3.2. Histogram equalization An ATM machine in Umeå has been busted and a lot of money has been stolen. An image of the thief was captured by the surveillance system, but unfortunately it was damaged when the film was developed. The image seems to see totally gray ("robber.bmp"). A policeman interested in image processing suggests that histogram equalization should help in identifying the thief. Help the police (histeq) 3.2.1 Show the result - is it possible to identify the thief? Report A report should be written and it shall contain: Task description Solution Answer to all the questions and the choices you have made based on these answers Figures Code Reflections on the task