Sie sind auf Seite 1von 19

EDGE DETECTION ON FPGA

A
MAJOR PROJECT REPORT

OF

BACHELOR OF TECHNOLGY
IN
ELCTRONICS AND COMMUNICATION ENGINEERING

SUBMITTED
BY

HARNOOR KAUR BHATIA (13104057)


&
TASLIM JAMAL ARIF (13104079)
&
AJAY KUMAR SAINI (13104027)

Supervisor
Dr. Ashish Raman
Assistant Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


Dr. B. R. AMBEDKAR NATIONAL INSTITUTE OF TECHNOLOGY,
JALANDHAR
May 2017
Dr BR Ambedkar National Institute of Technology, Jalandhar

CERTIFICATE

We hereby certify that the work which is being presented in this report
entitled, EDGE DETECTION ON FPGA in partial fulfillment of the
requirement for the award of Degree of Bachelor of Technology
(Electronics and Communication Engineering) submitted in the
Department of Electronics and Communication Engineering of Dr B R
Ambedkar National Institute of Technology, Jalandhar is a record of our
work carried out during 2016-17 under the supervision of Dr. Ashish
Raman. The matter presented in this report has not been submitted in part
or full to any other University or Institute for the award of any Degree.
Signature of Candidates:

Harnoor Kaur Bhatia Taslim Jamal Arif Ajay Kumar Saini


(13104057) (13104079) (13104027)

This is to certify that the above statement made by candidates is correct to


the best of my/our knowledge.

Signature of Supervisor(s):
Name of Supervisor: Dr. Ashish Raman
Designation: Assistant Professor
ACKNOWLEDGEMENT

I deem it as a proud privilege to express my sincerest regards and gratitude to Dr.


Ashish Raman (Assistant Professor), Department of Electronics and Communication
for providing me this valuable opportunity to pursue this work.

Also I would like to thank faculty from NIT Jalandhar for providing me the opportunity
for working on this project.

Finally, I am thankful to all those who directly or indirectly helped me during this
training.

Harnoor Kaur Bhatia Taslim Jamal Arif Ajay Kumar Saini


(13104057) (13104079) (13104027)
ABSTRACT

The image processing algorithms has been limited to software implementation which is
slower due to the limited processor speed. The implementation of image edge detection
on hardware is important for increasing processing speed of image processing systems.
So a dedicated processor for edge detection is required which was not possible until
advancements in VLSI technology.

The proposed work presents FPGA based architecture for Edge Detection using Sobel
operator. Sobel operator is chosen due to its property of less deterioration in high levels
of noise.Edge information for a particular pixel is obtained by exploring the brightness
of pixels in the neighborhood of that pixel. Measuring the relative brightness of pixels
in a neighborhood is mathematically analogous to calculating the derivative of
brightness. The pixel information extracted is transferred from the computer to the field
programmable gate array device. Sobel edge detection operations are performed on the
data and the processed data is sent back to the computer. The transfer of data is done
using parallel port interface operating in bidirectional mode. All the digital logic
implemented and verified on the field programmable gate array kit is described using
the Very High Speed Integrated Circuit Hardware Description Language (VHDL) and
the target ISs Xilinx Spartan 3 Family device XC3S400.
1. Introduction

1.1Aim
The aim of this project is to implement the Sobel Edge detection Operator on Hardware
(Field Programmable Gate Array).

1.2 Edge Detection Theory


An edge can be defined as an abrupt change in brightness as we move from one pixel to
its neighbour in an image. In digital image processing, each image is quantized into
pixels. With gray-scale images, each pixel indicates the level of brightness of the image
in a particular spot: 0 represents black, and with 8-bit pixels, 255 represent white. An
edge is an abrupt change in the brightness (gray scale level) of the pixels. Detecting
edges is an important task in boundary detection, motion detection/estimation, texture
analysis, segmentation, and object identification.

Edge information for a particular pixel is obtained by exploring the brightness of pixels
in the neighbourhood of that pixel. If all of the pixels in the neighbourhood have almost
the same brightness, then there is probably no edge at that point. However, if some of
the neighbours are much brighter than the others, then there is a probably an edge at
that point.

Measuring the relative brightness of pixels in a neighbourhood is mathematically


analogous to calculating the derivative of brightness. The Figure 1 illustrates an
example of Hard and Soft Edges on an image. Brightness values are discrete, not
continuous, so we approximate the derivative function. Different edge detection
methods (Prewitt, Laplacian, Roberts, Sobel and Canny) use different discrete
approximations of the derivative function. For example consider a random discrete 9 x
9 pixel image.

Figure 1 Discrete Pixel Image

X difference is calculated as | I (i+1, j) - I (i,j)|


Y difference is calculated as | I (i, j+1) - I (i,j)|
Where I denotes the intensity values [0-255]
1.2.1 Various Types of Edges[9]

Various physical actions like discontinuity in object boundary, surface direction and in
geometry cause changes in intensity. Edges can be shaped according to their amplitude
changes as follows:

Step Edge: The intensity of the image suddenly varies from one value to one side of
the breakage to a different value on the other side.

Ramp Edge: When the intensity change is not spontaneous and appears over a limited
distance then step edges become ramp edges

Ridge/Line Edge: The intensity of an image suddenly changes values and then returns
to the initial point within short distance.

Roof Edge: When the intensity change is not spontaneous and appears over a finite
distance usually generated by connectivity of surfaces then line edges become roof
edges.

1.2.2 Categories of Edge Detection

Edge detection is most common approach for finding discontinuities in amplitude


values. By applying first and second order derivatives, these discontinuities can be
identified. The edge detection can be categorized in two different parts as follows:

Gradient Edge Detection: Gradient is the first order derivative used in digital image
processing. Edges are detected by looking for the maximum and minimum value in the
first derivative of the image. eg. Sobel, Robert.

Laplacian Edge Detection: The second order derivatives in image processing are
generally computed using Laplacian. To find the edges in an image, the laplacian
method looks for zero crossings (i.e. places where the sign of Laplacian changes) in the
second order derivative. An edge is the one-dimensional ramp shaped and the position
of edge can be identified by computing the second order derivative of the image.
Steps in Edge Detection

Edge detection contains mainly four steps which are depicted in following fig

Figure 2 Flow Diagram for Edge Detection

These steps in edge detection are described as follows:

Filtering: Images are generally distorted by some haphazard variations in intensity


values, known as noise. Various types of noise like Gaussian, impulse, salt and pepper
noise frequently occur in an image. Filtering or smoothing suppress as much noise as
possible, without destroying the edges.

Enhancement: Enhancement emph- -asizes upon pixels where there is a significant


variations in local intensity values and is generally done by calculated the magnitude of
gradient vector.

Detection: It detects the edges by using the thresholding criteria that which edge
pixels should be discarded as noise and which should be retained.

Localization: It identifies the proper position of an edge in an image. Edge linking


and edge thinning are usually essential in localization.
1.3 Sobel Edge Detection Operator

The Sobel Edge Detection Operator is a 3x3 Spatial mask. It is based on the differential
operation [1 0 -1] and an averaging operator [1 2 1], Convolving these operators we get
the 3x3 spatial mask for sobel:

-1 0 1 Horizontal Gradient Operator


-2 0 2
-1 0 1

-1 -2 -1 Vertical Gradient Operator


0 0 0
1 2 1

The Spatial mask is convolved over the image to obtain the edge or high passed image.
The figure 2 shows the convolution mask working over an image. The mask is
convolved and the center element is replaced as the mask operates on the image. The
borders of the images are usually blacked out, since they cannot be computed with a
3x3 mask, or partially computed.

Gx[i, j] = Im[i+1, j-1] + 2*Im[i+1, j] + Im(i+1, j+1)


{ Im[i-1, j-1] + 2*Im[i-1, j] + Im(i-1, j+1) }

Gy[i, j] = Im[i-1, j+1] + 2*Im[i, j+1] + Im(i+1, j+1)


{ Im[i-1, j-1] + 2*Im[i, j-1] + Im(i+1, j-1) }
Figure 3 Sobel Detection Algorithm

1.4 C.R.T. Interfacing [8]

VGA DISPLAY PORT:

The Spartan-3E FPGA Starter Kit board includes a VGA display port via a
DB15 connector. Connect this port directly to most PC monitors or flat-panel
LCDs using a standard monitor cable. As shown in Figure the VGA connector is
the left-most connector along the top of the board. The Spartan-3E FPGA
directly drives the five VGA signals via resistors. Each colour line has a series
resistor, with one bit each for VGA_RED, VGA_GREEN, and VGA_BLUE.

The series resistor, in combination with the 75 termination built into the VGA
cable, ensures that the colour signals remain in the VGA-specified 0V to 0.7V
range. The VGA_HSYNC and VGA_VSYNC signals using LVTTL or
LVCMOS33 I/O standard drive levels. Drive the VGA_RED, VGA_GREEN,
and VGA_BLUE signals High or Low to generate the eight colours.
Figure 4 DB 15 Connector

Figure 5 Explanation of VGA Screen


Figure 6 Formation of colours

Figure 7 Traversing of screen


SIGNAL FPGA PIN

Red(R) R12

Green(G) T12

Blue(B) R11

Horizontal Sync R9
(HS)
Vertical Sync T10
(VS)

Table 1 Connections with FPGA

1.5 Relevance of Project

Edge detection is a very complex process affected by deterioration due to different level
of noise. A number of operators are defined to solve the problem of edge detection.
They are effective for certain classes of images, but not suitable for others. Edge
detection is a crucial step in digital image processing. It has found application in
artificial intelligence systems, forensic science and also in digital multimedia for
creating image dazzling effect. Currently the image processing algorithms has been
limited to software implementation which is slower due to the limited processor speed.
So a dedicated hardware for edge detection has been required which was not possible
until the advancements in VLSI technology.

Edge detection becomes a more complicated task when using much improved edge
detection masks. Moreover the process becomes lengthier when it operates on an image
of very high resolution. Most hardware implementations are faster than its
corresponding software implementations. So implementing edge detection in hardware
will be more efficient. Since FPGA have got the added feature of parallelism, the edge
detection can be effectively implemented.

During the recent years, field programmable gate arrays (FPGA) have become the
dominant form of programmable logic. In comparison to previous programmable
devices like programmable array logic (PAL) and complex programmable logic devices
(CPLD), FPGA can implement far larger logic functions. FPGA supports sufficient
logic to implement complete systems and sub-systems. FPGA provides designers with
reconfigurable logic that can be reprogrammed on application-specific basis. This
drastically increases flexibility in the design process.

Any edge detection masks when operated on a group on 9 pixels, there will be 12
multiplications. So while processing an image of size n x n, there will be a total of 12 x
(n-2)2 multiplications. The total number of multiplications can be reduced to 2 x (n-2)2
(i.e. reduced about 6 times) by using Sobel edge detection operator because it has got
mask values which does not require any multiplication at all. Moreover the
multiplication by 2 can be implemented easily using a shift operation instead of
implementing a multiplier.

The choice of Sobel edge detection operator is also motivated by the fact that they
incorporate both the edge detection as well as smoothing operator so that they have
good edge detection capability in noisy conditions. Sobel operator is less deteriorated in
high levels of noise.

Figure 8 Grey Scale Image


Figure 9 Detection of Edges
2. Objective
The main objective of the project is to detect the edges of an image using hardware [7].
We are using Field Programmable Gate Array (FPGA). Hardware based detection is
done to reduce the processing speed i.e. to do the computation faster. Also we are using
the Sobel operator for the computation of the edges.

The proposed work presents FPGA based architecture for Edge Detection using Sobel
operator. Sobel operator is chosen due to its property of less deterioration in high levels
of noise. Edge information for a particular pixel is obtained by exploring the brightness
of pixels in the neighbourhood of that pixel. Measuring the relative brightness of pixels
in a neighbourhood is mathematically analogous to calculating the derivative of
brightness. The pixel information extracted is transferred from the computer to the field
programmable gate array device. Sobel edge detection operations are performed on the
data and the processed data is sent back to the computer. The transfer of data is done
using parallel port interface operating in bidirectional mode. All the digital logic
implemented and verified on the field programmable gate array kit is described using
the Very High Speed Integrated Circuit Hardware Description Language (VHDL) and
the target ISs Xilinx Spartan 3 Family device XC3S400.
3. Methodology

The hardware implementation on FPGA requires raw pixel information[5].


Therefore we have to convert a standard image format (such as JPEG, PNG, and
BMP) to a raw image. In this format, we use 8 bits to represent a pixel, i.e.,
00000000 represents a pixel which is completely black, while 11111111
represents a pixel which is completely white. The extracted image is represented
as a 2-dimensional array of integer values ranging from 0 to 255 corresponding
to the individual pixels of the image. For colour images the raw data requires
three 8-bit data corresponding to each of the primary colours Red, Green and
Blue and will have to be processed one by one in the FPGA.
First of all the coloured image is converted into grey scale image[4] because if
coloured image is used directly, FPGA has to compute more data due to which
processing time may increase.
After that the grey scale image is converted into the raw data i.e. in the form of
pixels. Each pixel indicates the level of brightness of the image in a particular
spot: 0 represents black, and with 8-bit pixels, 255 represent white.
In the next step the raw data i.e. the data in the form of pixels is sent to the
FPGA through computer where the edges are computed using the Sobel
detector.
The detected edges in the form of pixels are sent back to the computer which are
displayed on the monitor by CRT Interfacing.
4. Work done till date

1. Coloured image converted to greyscale.[4]

Figure 10 Coloured Image


Figure 11 Grey Scale Image

2. The greyscale image is converted into raw data (in pixel form) using MATLAB.
The file is a plain text file (not binary, for readability) format used for our raw
image format is as follows:
Width Height Number of Colours (1 or 3)
Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data
Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data
Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data
....
....
Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data

Pixel Data is a 3 digit integer < 255 if Number of Colours is 1 i.e.


Monochrome or 3, 3 digit number < 255.
3. VHDL code for CRT Interfacing i.e. for displaying an image on the VGA screen
is developed.
5. References

1. Circuit Design with VHDL by Volnei A. Pedroni


2. Implementation of SOBEL Edge Detection on FPGA
3. G. Anusha, Dr.T. JayaChandra Prasad, Dr.D. Satya Narayana
4. www.mathworks.com
5. http://research.ijcaonline.org/volume91/number12/pxc3895208.pdf

6. http://pnrsolution.org/Datacenter/Vol3/Issue1/161.pdf

7. http://www.ugcfrp.ac.in/images/userfiles/59187-837.pdf
8. https://www.xilinx.com/support/documentation/data_sheets/ds312.pdf
9. https://www.academia.edu/5380026/PERFORMANCES_ANALYSIS_OF_DIF
FERENT_EDGE_DETECTION_METHODS_ON_ROAD_IMAGES

Das könnte Ihnen auch gefallen