parallel edge detection daniel dobkin asaf nitzan

16
Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Upload: deirdre-parks

Post on 26-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Parallel Edge Detection

Daniel DobkinAsaf Nitzan

Page 2: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Introduction to Image Processing What are edges? Why do we need to find

them? How do we find them? Motivation to parallelize this process OpenMP implementation

We’ll talk about…

Page 3: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

2-D / 3-D array of pixels Color channels

RGB – 3 channels Grayscale – 1 channel

1 byte per channel values of 0-255

What is an image?

Page 4: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

A closer look at pixels

R = 225G = 157B = 168

R = 201G = 120B = 137

Page 5: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Edges

A sharp change in values of adjacent pixels

Motivation to find edges A very basic feature in image

processing

Page 6: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

First, convert image from RGB to Grayscale

Convolve the image with a special 2-D operator

A greater change in intensity indicates a more prominent edge

Sobel operator:

Finding Edges

Page 7: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

217

221

44

213

13 2

24 3 2

Finding Edges - Example

For Sobel x filter: -617 For Sobel y filter: -669

So now we have 2 numbers, now what? We calculate the magnitude and the orientation of the

gradient:

Page 8: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Large amount of computations 800 x 600 pixels = 480,000 pixels 5.5 million

additions, 2 million multiplications Especially when it comes to real-time

video… 24 fps = 11.5 million pixels 132 million

additions, 48 million multiplications…

Motivation to Parallelize

Page 9: Parallel Edge Detection Daniel Dobkin Asaf Nitzan
Page 10: Parallel Edge Detection Daniel Dobkin Asaf Nitzan
Page 11: Parallel Edge Detection Daniel Dobkin Asaf Nitzan
Page 12: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Processors access same shared memory Each processor performs the region of image

assigned to him Reduced communication - There is no need to

broadcast the pixels of the image to all other processors

openMP

Page 13: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

A

B

C

D

openMP Implementation

A

B

C

D

Master thread

Master thread

Parallel task – Sobel filtering

fork join

Multithreading Master thread forks a number of threads which

execute code in parallel

Original Image

Page 14: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Load Image from Main memoryAllocate memory to new imageSet number of threads#pragma omp parallel for \

shared(inputImage, outputImage, width, height)\private(StartPixel, NumOfThreads, Rank , xPixel, yPixel)for each Pixel in region

Convert RGB value to greyscaleCompute gradient using Sobel filter Store result in filtered image

Join all threadsStore new image to disk

Pseudocode

Page 15: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

openMP Implementation

A

B

C

D

Original ImageProcessor 1

Processor 2

Processor 3

Processor 4

Sobel

Sobel

Sobel

Sobel

A

B

C

D

Filtered Image

Main Memory

Page 16: Parallel Edge Detection Daniel Dobkin Asaf Nitzan

Speedup Graph

Linear Speedup due to low communication cost

http://www.cs.rit.edu/~ptt/courses/4003-531/