45
Image Processing Image Processing A brief introduction A brief introduction (by Edgar (by Edgar Alejandro Guerrero Arroyo) Alejandro Guerrero Arroyo)

Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Embed Size (px)

Citation preview

Page 1: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Image ProcessingImage ProcessingA brief introduction A brief introduction (by Edgar Alejandro Guerrero Arroyo)(by Edgar Alejandro Guerrero Arroyo)

Page 2: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

What is an image?What is an image?

We can think in an image as a two We can think in an image as a two dimensional array of pixels.dimensional array of pixels.

Page 3: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

What is Image Processing?What is Image Processing?

Image processing is any form of Image processing is any form of signal processing for which the signal processing for which the input is an image.input is an image.

So...is the image a signal?So...is the image a signal? Yes it is!!Yes it is!! A image can be tought as a two A image can be tought as a two

dimensional signal.dimensional signal.

Page 4: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Brief MotivationBrief Motivation

Quantization: It’s a signal process Quantization: It’s a signal process of approximating a continuous of approximating a continuous range of values by a relatively range of values by a relatively small discrete set of integer values.small discrete set of integer values.

Page 5: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Brief MotivationBrief Motivation

Image Editing: Alterating the Image Editing: Alterating the image.image.

Page 6: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Brief MotivationBrief Motivation

High dynamic range image: High dynamic range image: changing the range of luminances.changing the range of luminances.

Page 7: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Why in Parallel?Why in Parallel?

It is expensive in time.It is expensive in time. Suppose a pix max of 1024x1024 8-Suppose a pix max of 1024x1024 8-

bit pixels.bit pixels. In order to operate every pixel we In order to operate every pixel we

need to do operations!need to do operations! We can remember the example of We can remember the example of

project 1 of class.project 1 of class.

Page 8: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image ProcessingProcessing

It is natural to think about doing the It is natural to think about doing the operations in a image in a pixel level.operations in a image in a pixel level.

There are several low level operations that There are several low level operations that can be applied in images.can be applied in images.

Such operations can be divided depending Such operations can be divided depending of in what is the output based.of in what is the output based.

A single pixel: A single pixel: point processingpoint processing A goup of pixels: A goup of pixels: local operationslocal operations All the pixels in the image: All the pixels in the image: global global

operationsoperations

Page 9: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperationsThresholdingThresholding

The idea is to define a threshold The idea is to define a threshold value. value.

Later on, all the pixels with values Later on, all the pixels with values above the predetermined threshold above the predetermined threshold value are kept.value are kept.

The rest of the pixels are reduce to The rest of the pixels are reduce to 0. 0.

Page 10: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperations

Contrast StretchingContrast Stretching The range of the gray-level values The range of the gray-level values

is extended.is extended. Therefore the details are more Therefore the details are more

visible.visible. Original range Original range Contrast rangeContrast range

Page 11: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperationsHistogramsHistograms

It’s a function that shows the # of It’s a function that shows the # of pixels of an image at each gray pixels of an image at each gray level.level.

It is useful to find the variations of It is useful to find the variations of gray levels in an image.gray levels in an image.

Page 12: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperationsSmooothingSmooothing

It suppresses large fluctuations in It suppresses large fluctuations in intensity over the image area.intensity over the image area.

It could be achieved by reducing the high It could be achieved by reducing the high frequency contend.frequency contend.

It reduces the noise in the image but blurs It reduces the noise in the image but blurs it.it.

A simple technique is to take the mean of A simple technique is to take the mean of a group of pixels as the new value of the a group of pixels as the new value of the central pixel (project 1).central pixel (project 1).

Page 13: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperations

Computing the MeanComputing the Mean

Page 14: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperationsSharpeningSharpening

It accentuates the transitions It accentuates the transitions enhancing the detail.enhancing the detail.

One approach is to reduce the low One approach is to reduce the low frequence contentfrequence content

Another one isAnother one is to accentuate to accentuate changes through differentiation.changes through differentiation.

Page 15: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperationsSharpeningSharpening

Page 16: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperations

Noise ReductionNoise Reduction It suppresses a noise signal present It suppresses a noise signal present

in the image.in the image. The noise signal itself may be a The noise signal itself may be a

random signal completely random signal completely uncorrelated with the image signal.uncorrelated with the image signal.

One way to reduce this last is One way to reduce this last is capturating the image several times capturating the image several times and taking the averange of each and taking the averange of each pixel.pixel.

Page 17: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperations

Noise ReductionNoise ReductionLuminance fluctuations along thin blue and Luminance fluctuations along thin blue and

red strips of pixels in the top and the red strips of pixels in the top and the bottom images respectively.bottom images respectively.

Page 18: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Low Level Image Low Level Image OperationsOperations

Noise ReductionNoise Reduction

Page 19: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

The idea of identify objects from The idea of identify objects from other is clearly quite important.other is clearly quite important.

What is an edge?What is an edge? It’s a significant change in the gray It’s a significant change in the gray

level intensity.level intensity.

Page 20: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Gradient and MagnitudeGradient and Magnitude Let f(x) be a one-dimentional gray Let f(x) be a one-dimentional gray

level function.level function. f '(x) measures the gradient of the f '(x) measures the gradient of the

transition.transition. f ''(x) helps to identify the exact f ''(x) helps to identify the exact

position of transition. position of transition.

Page 21: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Gradient and MagnitudeGradient and Magnitude

Page 22: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

But an image is a two dimensional But an image is a two dimensional discretized gray level function discretized gray level function f(x,y).f(x,y).

The norm of the gradient can be The norm of the gradient can be aproximated to reduce aproximated to reduce computations.computations.

Page 23: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Edge Detection Using MasksEdge Detection Using Masks The idea is to use the partial The idea is to use the partial

derivates of the function, (discrete).derivates of the function, (discrete). In this way we can know the In this way we can know the

difference between neighbouring difference between neighbouring pixel gray levels in a row and in a pixel gray levels in a row and in a column.column.

Page 24: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

ExampleExample

(Done in class)(Done in class)

Page 25: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Prewitt OperatorPrewitt Operator As always, using more points we As always, using more points we

get better results. (Example)get better results. (Example)

Page 26: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Sobel OperatorSobel Operator Both edge detection and Both edge detection and

Smoothing.Smoothing.

Page 27: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Sobel OperatorSobel Operator

Page 28: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Sobel OperatorSobel Operator

Page 29: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Laplace OperatorLaplace Operator If the first derivate is good, the second is If the first derivate is good, the second is

better. better. After it, it’s good to apply an edge After it, it’s good to apply an edge

detection operator, (threshold is detection operator, (threshold is prefered), to get either black or white prefered), to get either black or white pixels.pixels.

Page 30: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Edge DetectionEdge Detection

Laplace OperatorLaplace Operator

Page 31: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

The Hough TransformThe Hough Transform

It ‘s useful to find the parameters of It ‘s useful to find the parameters of equations of lines that most likely fit the equations of lines that most likely fit the sets of pixels in an image.sets of pixels in an image.

The proporse of use this is because is The proporse of use this is because is cheaper than using a edge detector in cheaper than using a edge detector in simple lines, (straight lines, circles, etc).simple lines, (straight lines, circles, etc).

Page 32: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

The Hough TransformThe Hough Transform

Example (Done in class)Example (Done in class)Consider the problem of find the line that Consider the problem of find the line that

contains 3 given points.contains 3 given points. For each data point, a number of lines For each data point, a number of lines

are plotted going through it, all at are plotted going through it, all at different angles.different angles.

For each solid line a line is plotted which For each solid line a line is plotted which is perpendicular to it and which is perpendicular to it and which intersects the origin.intersects the origin.

The length and angle of each dashed line The length and angle of each dashed line is measured. is measured.

This is repeated for each data point.This is repeated for each data point.

Page 33: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

The Hough TransformThe Hough Transform

Example contExample cont

(Done in class)(Done in class)

Page 34: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

The Hough TransformThe Hough Transform

Example cont. (Done in class)Example cont. (Done in class)

Page 35: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fourier SeriesFourier Series

Joseph Fourier, Joseph Fourier, (1768-1830), (1768-1830), found found that every function can be that every function can be expressed as an infinite sum of expressed as an infinite sum of Sines and Cosines.Sines and Cosines.

Page 36: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fourier TransformationFourier Transformation

The Fourier transform is an The Fourier transform is an application that sends a complex application that sends a complex function f into an “scary” function g function f into an “scary” function g as follow:as follow:

Brief explanation. (Done in class)Brief explanation. (Done in class)

Page 37: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Discrete Fourier TransformDiscrete Fourier Transform The sequence of The sequence of NN complex numbers complex numbers XX00, ..., , ..., XXNN−1−1 is transformed into the is transformed into the sequence of sequence of NN complex numbers complex numbers XX00, ..., , ..., XXNN−1−1 by the DFT according to the by the DFT according to the formula: formula:

where is a primitive N'th root of unity.where is a primitive N'th root of unity. Calculate sequentialy this serie will cost Calculate sequentialy this serie will cost

N xN products and N sums => O(N^2) N xN products and N sums => O(N^2)

Page 38: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Discrete Fourier TransformDiscrete Fourier Transform

The Fourier Transform is used if we The Fourier Transform is used if we want to access the geometric want to access the geometric characteristics of a spatial domain characteristics of a spatial domain image. image.

In the image we can calculate a two In the image we can calculate a two dimensional Fourier Transformation dimensional Fourier Transformation (!!!).(!!!).

But instead, we can calculate the But instead, we can calculate the Fourier transformation of rows and Fourier transformation of rows and columns separately (clever).columns separately (clever).

Page 39: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Discrete Fourier TransformDiscrete Fourier Transform The kth element of the DFT is given by:The kth element of the DFT is given by:

Then, the vector result can be seen as the dot product of Then, the vector result can be seen as the dot product of a matrix and a vector.a matrix and a vector.

Page 40: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Discrete Fourier TransformDiscrete Fourier Transform

Therefore, since the DFT can be Therefore, since the DFT can be computed as a matrix product, we computed as a matrix product, we can apply a numerical algorithm to can apply a numerical algorithm to achieve this, (maybe with our achieve this, (maybe with our project 3). project 3).

Page 41: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fast Fourier TransformFast Fourier Transform This method allows us to find the DFT in O(NLogN), in This method allows us to find the DFT in O(NLogN), in

sequential time, instead of (N^2).sequential time, instead of (N^2).

Page 42: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fast Fourier TransformFast Fourier Transform

Binary AlgorithmBinary Algorithm

Page 43: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fast Fourier TransformFast Fourier Transform

Binary Algorithm AnalisisBinary Algorithm Analisis Computation: Computation: Given P processors and N Given P processors and N

points, at each steap each processor will points, at each steap each processor will calculate N/P points, (1 sum and 1 calculate N/P points, (1 sum and 1 product). That’s it O(NLogN).product). That’s it O(NLogN).

Communication: Communication: if P = N, then if P = N, then communication occurs at each step, one communication occurs at each step, one data. That’s it O(N). If P < N, then data. That’s it O(N). If P < N, then communication occurs only the first Log communication occurs only the first Log P steaps. That’s it O(LogP).P steaps. That’s it O(LogP).

Page 44: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

Fast Fourier TransformFast Fourier Transform The image before and after Fourier Transformation. We The image before and after Fourier Transformation. We

take the logarithm after FT, otherwise we will only see a take the logarithm after FT, otherwise we will only see a point.point.

Page 45: Image Processing A brief introduction (by Edgar Alejandro Guerrero Arroyo)

BibliographyBibliography

Wikipedia.comWikipedia.com Parallel Programing, Wilkinson & Parallel Programing, Wilkinson &

Allen.Allen. InternetInternet