Edge detection1 (3)

84
ABSTRACT This project report presents a kind of parallel processing construction of the edge detection enhancement algorithm. This can quickly get the result of one pixel in only one accurately and less sensitive to noise. As the data of edge detection is very large the speed of the image processing is a difficult problem. To upgrade this problem the parallel processing algorithm is designed with a FPGA chip called XC3S200-5ft256. Field programmable gate array is an effective device to realize the real-time parallel processing of vast amount of video data because of the fine-grain reconfigurable structures. This FPGA can process 1024x1024x8 Gray scale image successfully. The design can locate the edge of the gray image quickly and efficiently.

Transcript of Edge detection1 (3)

Page 1: Edge detection1 (3)

ABSTRACT

This project report presents a kind of parallel processing construction of the edge detection

enhancement algorithm. This can quickly get the result of one pixel in only one accurately and

less sensitive to noise.

As the data of edge detection is very large the speed of the image processing is a difficult

problem. To upgrade this problem the parallel processing algorithm is designed with a FPGA

chip called XC3S200-5ft256.

Field programmable gate array is an effective device to realize the real-time parallel

processing of vast amount of video data because of the fine-grain reconfigurable structures. This

FPGA can process 1024x1024x8 Gray scale image successfully. The design can locate the edge

of the gray image quickly and efficiently.

Page 2: Edge detection1 (3)

Chapter 1

INTRODUCTION

1.1 Introduction

The edges of image are considered to be the most important image attributes that provide

valuable information for human image perception. The edge detection is a terminology in image

processing, particularly in the areas of feature extraction, to refer to algorithms which aim at

identifying points in a digital image at which the image brightness changes sharply. The data of

edge detection is very large, so the speed of image processing is a difficult problem. FPGA can

overcome it. Sobel operator is commonly used in edge detection. Sobel operator has been

researched for parallelism, but Sobel operator can’t locates complex edges accurately, so it has

been studied for the Sobel enhancement operator in order to locate the edge of an image more

accurately and less sensitive to noise, but the software cannot meet the real-time requirements.

For this reason, a FPGA implementation of edge detection enhancement algorithm has proposed

in this paper, it not only meets the real-time requirements, but also locates the image edge

accurately.

Page 3: Edge detection1 (3)

Chapter 2

IMAGE TECHNIQUES

2.1 Image

An image is a two-dimensional picture, which has a similar appearance to some subject usually a

physical object or a person. Image is a two-dimensional, such as a photograph, screen display,

and as well as a three-dimensional, such as a statue. They may be captured by optical devices

such as cameras, mirrors, lenses, telescopes, microscopes, etc. and natural objects and

phenomena, such as the human eye or water surfaces.

The word “image” is also used in the broader sense of any two-dimensional figure such

as a map, a graph, a pie chart, or an abstract painting. In this wider sense, images can also be

rendered manually, such as by drawing, painting, carving, rendered automatically by printing or

computer graphics technology, or developed by the combination of methods, especially in a

pseudo-photograph.

Figure- 2.1: Conversion of real image to pseudo-image

Page 4: Edge detection1 (3)

Image is a rectangular grid of pixels. It has a definite height and a definite width counted

in pixels. Each pixel is square and has a fixed size on a given display. However different

computer monitors may use different sized pixels. The pixels that constitute an image are

ordered as a grid (columns and rows); each pixel consists of numbers representing magnitudes of

brightness and color.

Figure- 2.2: Pixel representation of the Image

Each pixel has a color. The color is a 32-bit integer. The first eight bits determine the

redness of the pixel, the next eight bits the greenness, the next eight bits the blueness, and the

remaining eight bits the transparency of the pixel.

Figure- 2.3: Bitwise representation of color pixel

Page 5: Edge detection1 (3)

2.1.1 Image File Formats

Image file formats are standardized means of organizing and storing images. This entry is about

digital image formats used to store photographic and other images. Image files are composed of

either pixel or vector (geometric) data that are rasterized to pixels when displayed (with few

exceptions) in a vector graphic display. Including proprietary types, there are hundreds of image

file types. The PNG, JPEG, and GIF formats are most often used to display images on the

Internet.

Figure- 2.4: Image file format

In addition to straight image formats, Metafile formats are portable formats which can

include both raster and vector information. The metafile format is an intermediate format. Most

Windows applications open metafiles and then save them in their own native format.

2.1.2 Raster Formats

These formats store images as bitmaps (also known as pixmaps).

JPEG/JFIF

JPEG (Joint Photographic Experts Group) is a compression method. JPEG compressed images

are usually stored in the JFIF (JPEG File Interchange Format) file format. JPEG compression is

lossy compression. Nearly every digital camera can save images in the JPEG/JFIF format, which

supports 8 bits per color (red, green, blue) for a 24-bit total, producing relatively small files.

Photographic images may be better stored in a lossless non-JPEG format if they will be re-edited,

or if small "artifacts" are unacceptable. The JPEG/JFIF format also is used as the image

compression algorithm in many Adobe PDF files.

Page 6: Edge detection1 (3)

EXIF

The EXIF (Exchangeable image file format) format is a file standard similar to the JFIF format

with TIFF extensions. It is incorporated in the JPEG writing software used in most cameras. Its

purpose is to record and to standardize the exchange of images with image metadata between

digital cameras and editing and viewing software. The metadata are recorded for individual

images and include such things as camera settings, time and date, shutter speed, exposure, image

size, compression, name of camera, color information, etc. When images are viewed or edited by

image editing software, all of this image information can be displayed.

TIFF

The TIFF (Tagged Image File Format) format is a flexible format that normally saves 8 bits or

16 bits per color (red, green, blue) for 24-bit and 48-bit totals, respectively, usually using either

the TIFF or TIF filename extension. TIFFs are lossy and lossless. Some offer relatively good

lossless compression for bi-level (black & white) images. Some digital cameras can save in TIFF

format, using the LZW compression algorithm for lossless storage. TIFF image format is not

widely supported by web browsers. TIFF remains widely accepted as a photograph file standard

in the printing business. TIFF can handle device-specific color spaces, such as the CMYK

defined by a particular set of printing press inks.

PNG

The PNG (Portable Network Graphics) file format was created as the free, open-source successor

to the GIF. The PNG file format supports true color (16 million colors) while the GIF supports

only 256 colors. The PNG file excels when the image has large, uniformly colored areas. The

lossless PNG format is best suited for editing pictures, and the lossy formats, like JPG, are best

for the final distribution of photographic images, because JPG files are smaller than PNG files.

PNG, an extensible file format for the lossless, portable, well-compressed storage of raster

images. PNG provides a patent-free replacement for GIF and can also replace many common

uses of TIFF. Indexed-color, grayscale, and true color images are supported, plus an optional

alpha channel. PNG is designed to work well in online viewing applications, such as the World

Page 7: Edge detection1 (3)

Wide Web. PNG is robust, providing both full file integrity checking and simple detection of

common transmission errors.

GIF

GIF (Graphics Interchange Format) is limited to an 8-bit palette, or 256 colors. This makes the

GIF format suitable for storing graphics with relatively few colors such as simple diagrams,

shapes, logos and cartoon style images. The GIF format supports animation and is still widely

used to provide image animation effects. It also uses a lossless compression that is more effective

when large areas have a single color, and ineffective for detailed images or dithered images.

BMP

The BMP file format (Windows bitmap) handles graphics files within the Microsoft Windows

OS. Typically, BMP files are uncompressed, hence they are large. The advantage is their

simplicity and wide acceptance in Windows programs.

2.1.3 Vector Formats

As opposed to the raster image formats above (where the data describes the characteristics of

each individual pixel), vector image formats contain a geometric description which can be

rendered smoothly at any desired display size.

At some point, all vector graphics must be rasterized in order to be displayed on digital

monitors. However, vector images can be displayed with analog CRT technology such as that

used in some electronic test equipment, medical monitors, radar displays, laser shows and early

video games. Plotters are printers that use vector data rather than pixel data to draw graphics.

CGM

CGM (Computer Graphics Metafile) is a file format for 2D vector graphics, raster graphics, and

text. All graphical elements can be specified in a textual source file that can be compiled into a

binary file or one of two text representations. CGM provides a means of graphics data

interchange for computer representation of 2D graphical information independent from any

particular application, system, platform, or device.

Page 8: Edge detection1 (3)

SVG

SVG (Scalable Vector Graphics) is an open standard created and developed by the World Wide

Web Consortium to address the need for a versatile, scriptable and all purpose vector format for

the web and otherwise. The SVG format does not have a compression scheme of its own, but due

to the textual nature of XML, an SVG graphic can be compressed using a program such as gzip.

2.2 Image Processing

Digital image processing, the manipulation of images by computer, is relatively recent

development in terms of man’s ancient fascination with visual stimuli. In its short history, it has

been applied to practically every type of images with varying degree of success. The inherent

subjective appeal of pictorial displays attracts perhaps a disproportionate amount of attention

from the scientists and also from the layman. Digital image processing like other glamour fields,

suffers from myths, misconnect ions, misunderstandings and misinformation. It is vast umbrella

under which fall diverse aspect of optics, electronics, mathematics, photography graphics and

computer technology. It is truly multidisciplinary endeavor ploughed with imprecise jargon.

Several factor combine to indicate a lively future for digital image processing. A major factor is

the declining cost of computer equipment.

Several new technological trends promise to further promote digital image processing.

These include parallel processing mode practical by low cost microprocessors, and the use of

charge coupled devices (CCDs) for digitizing, storage during processing and display and large

low cost of image storage arrays.

In electrical engineering and computer science, image processing is any form of signal

processing for which the input is an image, such as a photograph or video frame; the output of

image processing may be either an image or, a set of characteristics or parameters related to the

image. Most image-processing techniques involve treating the image as a two-

dimensional signal and applying standard signal-processing techniques to it.

Page 9: Edge detection1 (3)

Many of the techniques of digital image processing, or digital picture processing as it

often was called, were developed in the 1960s at the Jet Propulsion Laboratory, Massachusetts

Institute of Technology, Bell Laboratories, University of Maryland, and a few other research

facilities, with application to satellite imagery, wire-photo standards conversion, medical

imaging, videophone, character recognition, and photograph enhancement.[1] The cost of

processing was fairly high, however, with the computing equipment of that era. That changed in

the 1970s, when digital image processing proliferated as cheaper computers and dedicated

hardware became available. Images then could be processed in real time, for some dedicated

problems such as television standards conversion. As general-purpose computers became faster,

they started to take over the role of dedicated hardware for all but the most specialized and

computer-intensive operations.

With the fast computers and signal processors available in the 2000s, digital image

processing has become the most common form of image processing and generally, is used

because it is not only the most versatile method, but also the cheapest. Digital image processing

technology for medical applications was inducted into the Space Foundation Space Technology

Hall of Fame in 1994

In a most generalized way, a digital image is an array of numbers depicting spatial

distribution of a certain field parameters (such as reflectivity of EM radiation, emissivity,

temperature or some geophysical or topographical elevation. Digital image consists of discrete

picture elements called pixels. Associated with each pixel is a number represented as DN

(Digital Number),that depicts the average radiance of relatively small area within a scene. The

range of DN values being normally 0 to 255. The size of this area effects the reproduction of

details within the scene. As the pixel size is reduced more scene detail is preserved in digital

representation. . As general-purpose computers became faster, they started to take over the role

of dedicated hardware for all but the most specialized and computer-intensive operations.

 

Page 10: Edge detection1 (3)

2.2.1 Fundamental Steps In Digital Image Processing

Figure- 2.5: Block diagram of digital image processing

Image Acquisition

Image Acquisition is to acquire a digital image. To do so requires an image sensor and the

capability to digitize the signal produced by the sensor. The sensor could be monochrome or

color TV camera that produces an entire image of the problem domain every 1/30 sec. The image

Page 11: Edge detection1 (3)

sensor could also be line scan camera that produces a single image line at a time. In this case, the

objects motion past the line.

Figure- 2.6: Color TV Camera

Scanner produces a two-dimensional image. If the output of the camera or other imaging

sensor is not in digital form, an analog to digital converter digitizes it. The nature of the sensor

and the image it produces are determined by the application.

Figure- 2.7: Analog to Digital Converters ion image

Image enhancement

Image enhancement is among the simplest and most appealing areas of digital image processing.

Basically, the idea behind enhancement techniques is to bring out detail that is obscured, or

simply to highlight certain features of interesting an image. A familiar example of enhancement

is when we increase the contrast of an image because “it looks better.” It is important to keep in

mind that enhancement is a very subjective area of image processing.

Image enhancement improves the quality (clarity) of images for human viewing.

Removing blurring and noise, increasing contrast, and revealing details are examples of

enhancement operations.

Page 12: Edge detection1 (3)

Figure- 2.8: The Enhanced Image

For example, an image might be taken of an endothelial cell, which might be of low

contrast and somewhat blurred. Reducing the noise and blurring and increasing the contrast

range could enhance the image. The original image might have areas of very high and very low

intensity, which mask details.

Image Restoration

Image restoration is an area that also deals with improving the appearance of an image.

However, unlike enhancement, which is subjective, image restoration is objective, in the sense

that restoration techniques tend to be based on mathematical or probabilistic models of image

degradation.

Figure- 2.9: Comparison of the Restored Image

Page 13: Edge detection1 (3)

Enhancement, on the other hand, is based on human subjective preferences regarding what

constitutes a “good” enhancement result. For example, contrast stretching is considered an

enhancement technique because it is based primarily on the pleasing aspects it might present to

the viewer, where as removal of image blur by applying a de-blurring function is considered a

restoration technique.

Color image processing

The use of color in image processing is motivated by two principal factors. First, color is a

powerful descriptor that often simplifies object identification and extraction from a scene.

Second, humans can discern thousands of color shades and intensities, compared to about only

two dozen shades of gray. This second factor is particularly important in manual image analysis.

Figure- 2.10: Processing the Gray image to color Image

Wavelets and multi resolution processing

Wavelets are the formation for representing images in various degrees of resolution. Although

the Fourier transform has been the mainstay of transform based image processing since the

late1950’s, a more recent transformation, called the wavelet transform, and is now making it

even easier to compress, transmit, and analyze many images. Unlike the Fourier transform,

whose basis functions are sinusoids, wavelet transforms are based on small values, called

Wavelets, of varying frequency and limited duration.

Page 14: Edge detection1 (3)

Wavelets are mathematical functions that cut up data into different frequency

components, and then study each component with a resolution matched to its scale. They have

advantages over traditional Fourier methods in analyzing physical situations where the signal

contains discontinuities and sharp spikes. Wavelets were developed independently in the fields

of mathematics, quantum physics, electrical engineering, and seismic geology. Interchanges

between these fields during the last ten years have led to many new wavelet applications.

Figure- 2.11: Measuring the parameters of the Image

Wavelets were first shown to be the foundation of a powerful new approach to signal

processing and analysis called Multi resolution theory. Multi-resolution theory incorporates and

unifies techniques from a variety of disciplines, including sub band coding from signal

processing, quadrature mirror filtering from digital speech recognition, and pyramidal image

processing.

Compression

Compression, as the name implies, deals with techniques for reducing the storage required

saving an image, or the bandwidth required for transmitting it. Although storage technology has

improved significantly over the past decade, the same cannot be said for transmission capacity.

This is true particularly in uses of the Internet, which are characterized by significant pictorial

Page 15: Edge detection1 (3)

content. Image compression is familiar to most users of computers in the form of image file

extensions, such as the jpg file extension used in the JPEG (Joint Photographic Experts Group)

image compression standard.

Morphological Processing

Morphological processing deals with tools for extracting image components that are useful in the

representation and description of shape. The language of mathematical morphology is set theory.

As such, morphology offers a unified and powerful approach to numerous image processing

problems. Sets in mathematical morphology represent objects in an image. For example, the set

of all black pixels in a binary image is a complete morphological description of the image.

Figure- 2.12: Difference of the image after Morphological processing

In binary images, the sets in question are members of the 2-D integer space Z 2, where

each element of a set is a 2-D vector whose coordinates are the (x, y) coordinates of a black(or

white) pixel in the image. Gray-scale digital images can be represented as sets whose

components are in Z3. In this case, two components of each element of the set refer to the

coordinates of a pixel, and the third corresponds to its discrete gray-level value.

Segmentation

Segmentation procedures partition an image into its constituent parts or objects. In general,

autonomous segmentation is one of the most difficult tasks in digital image processing. A rugged

segmentation procedure brings the process a long way toward successful solution of imaging

problems that require objects to be identified individually.

Page 16: Edge detection1 (3)

Figure- 2.13: Segmented Image

On the other hand, weak or erratic segmentation algorithms almost always guarantee eventual

failure. In general, the more accurate the segmentation, the more likely recognition is to succeed.

Morphological processing deals with tools for extracting image components that are useful in the

representation and description of shape. The language of mathematical morphology is set theory.

As such, morphology offers a unified and powerful approach to numerous image processing

problems. Sets in mathematical morphology represent objects in an image. For example, the set

of all black pixels in a binary image is a complete morphological description of the image.

2.3 Segmentation Techniques

In computer vision, segmentation refers to the process of partitioning a digital image into

multiple segments (sets of pixels, also known as super pixels). The goal of segmentation is to

simplify and/or change the representation of an image into something that is more meaningful

and easier to analyze.[1] Image segmentation is typically used to locate objects and boundaries

(lines, curves, etc.) in images. More precisely, image segmentation is the process of assigning a

label to every pixel in an image such that pixels with the same label share certain visual

characteristics.

The result of image segmentation is a set of segments that collectively cover the entire

image, or a set of contours extracted from the image (see edge detection). Each of the pixels in a

Page 17: Edge detection1 (3)

region are similar with respect to some characteristic or computed property, such

as color, intensity, or texture. Adjacent regions are significantly different with respect to the

same characteristic(s).

2.3.1 Based On Intensity Values

Intensity values used for thresholding unless detected appropriately can result in segmentation

errors. Thresholding and stretching images separate foreground pixels from background pixels

and can be performed before or after applying a morphological operation to an image. While a

threshold operation produces a binary image and a stretch operation produces a scaled, grayscale

image, both operations rely upon the definition of an intensity value. This intensity value is

compared to each pixel value within the image and an output pixel is generated based upon the

conditions stated within the threshold or stretch statement.

In computer vision, segmentation refers to the process of partitioning a digital image into

multiple segments (sets of pixels, also known as super pixels). The goal of segmentation is to

simplify and/or change the representation of an image into something that is more meaningful

and easier to analyze.[1] Image segmentation is typically used to locate objects and boundaries

(lines, curves, etc.) in images. More precisely, image segmentation is the process of assigning a

label to every pixel in an image such that pixels with the same label share certain visual

characteristics.

The result of image segmentation is a set of segments that collectively cover the entire

image, or a set of contours extracted from the image (see edge detection). Each of the pixels in a

region are similar with respect to some characteristic or computed property, such

as color, intensity, or texture. Adjacent regions are significantly different with respect to the

same characteristic(s).

Page 18: Edge detection1 (3)

Intensity histograms provide a means of determining useful intensity values as well as

determining whether or not an image is a good candidate for thresholding or stretching. A

histogram containing definitive peaks of intensities indicates that an image's foreground and

background features can be successfully separated. A histogram containing connected, graduated

ranges of intensities indicates the image is likely a poor candidate for thresholding or stretching.

2.3.2 Edge Detection

Edge detection using image gradients detects only the boundary and the information within the

boundary will be lost. Moreover these are prone to noise. Edge detection is a fundamental tool in

image processing and computer vision, particularly in the areas of feature detection and feature

extraction, which aim at identifying points in a digital image at which the image brightness

changes sharply or more formally has discontinuities.

There are many ways to perform edge detection. However, the most may be grouped into two

categories, gradient and Laplacian. The gradient method detects the edges by looking for the

maximum and minimum in the first derivative of the image. The Laplacian method searches for

zero crossings in the second derivative of the image to find edges. In computer

vision, segmentation refers to the process of partitioning a digital image into

multiple segments (sets of pixels, also known as super pixels). The goal of segmentation is to

simplify and/or change the representation of an image into something that is more meaningful

and easier to analyze.[1] Image segmentation is typically used to locate objects and boundaries

(lines, curves, etc.) in images. More precisely, image segmentation is the process of assigning a

label to every pixel in an image such that pixels with the same label share certain visual

characteristics.

The result of image segmentation is a set of segments that collectively cover the entire

image, or a set of contours extracted from the image (see edge detection). Each of the pixels in a

region are similar with respect to some characteristic or computed property, such

as color, intensity, or texture. Adjacent regions are significantly different with respect to the

same characteristic(s).

Page 19: Edge detection1 (3)

This first figure shows the edges of an image detected using the gradient method

(Roberts, Prewitt, Sobel) and the Laplacian method (Marrs-Hildreth). Notice that the facial

features (eyes, nose and mouth) have very sharp edges. These also happen to be the best

reference points for morphing between two images. Notice also that the Marr-Hildreth not only

has a lot more noise than the other methods, the low-pass filtering it uses distorts the actual

position of the facial features.

Due to the nature of the Sobel and Prewitt filters we can select out only vertical and

horizontal edges of the image as shown below. This is very useful since we do not want to morph

a vertical edge in the initial image to a horizontal edge in the final image. This would cause a lot

of warping in the transition image and thus a bad morph.

The next pair of image shows the horizontal and vertical edges selected out of the group

members images with the Sobel method of edge detection. You will notice the difficulty it had

with certain facial features, such as the hairline of Sri and Jim. This is essentially due to the lack

of contrast between their hair and their foreheads.

2.3.3 Region Growing

The accuracy of the region growing depends on the number of iterations used and they can take

excessive computational time. Region growing is a simple region-based image segmentation

method. It is also classified as a pixel-based image segmentation method since it involves the

selection of initial seed points.

This approach to segmentation examines neighboring pixels of initial “seed points” and

determines whether the pixel neighbors should be added to the region. The process is iterated on,

in the same manner as general data clustering algorithms. The computation is consuming, no

matter the time or power. Noise or variation of intensity may result in holes or over

segmentation. This method may not distinguish the shading of the real images.

Page 20: Edge detection1 (3)

We can conquer the noise problem easily by using some mask to filter the holes or

outlier. Therefore, the problem or noise actually does not exist. In conclusion, it is obvious that

the most serious problem of region growing is the power and time consuming. The main

assumption of this approach is that regions are nearly constant in image intensity. This approach

will not work for non-smoothly varying regions (e.g., textured regions). More sophisticated

approaches are required to allow for more realistic intensity variations due to shading.

2.3.4 Model Based

Model based techniques where contours are identified and the region builds based on these

defined contours and they become more or less specific to the images. One of the many

remaining challenges in automated computer vision is image segmentation. Although the human

visual system is in general capable of very precise segmentation, this task has revealed itself a

very elusive one when it comes to automation.

In this, we will examine a group of (still primitive) algorithms for image

Segmentation that in some way or another break with the “self-containment barrier” in trying to

use some external a priori knowledge about the problem at hand in order to improve the

segmentation. In particular, we will focus on “model based” segmentation algorithms, that is,

segmentation algorithms that use some kind of model (deterministic or statistical) of the image

and/or the objects in it in order to improve the segmentations.

When using such models to assist in segmentation it can obviously be claimed that we are

moving from a pure segmentation problem to a problem in pattern recognition. While this is

partially true, we will not be preoccupied with these subtle distinctions here, and will continue to

consider these algorithms to be segmentation algorithms.

2.3.5 Fuzzy Classification With Neural Network

Fuzzy C Means algorithms are also applied effectively and they are often combined with neural

network models. Fuzzy logic is relatively young theory. Major advantage of this theory is that it

allows the natural description, in linguistic terms, of problems that should be solved rather than

Page 21: Edge detection1 (3)

in terms of relationships between precise numerical values. This advantage, dealing with the

complicated systems in simple way, is the main reason why fuzzy logic theory is widely applied

in technique. It is also possible to classify the remotely sensed image (as well as any other digital

imagery), in such a way that certain land cover classes are clearly represented in the resulting

image.

In computer vision, segmentation refers to the process of partitioning a digital image into

multiple segments (sets of pixels, also known as super pixels). The goal of segmentation is to

simplify and/or change the representation of an image into something that is more meaningful

and easier to analyze.[1] Image segmentation is typically used to locate objects and boundaries

(lines, curves, etc.) in images. More precisely, image segmentation is the process of assigning a

label to every pixel in an image such that pixels with the same label share certain visual

characteristics.

The result of image segmentation is a set of segments that collectively cover the entire

image, or a set of contours extracted from the image (see edge detection). Each of the pixels in a

region are similar with respect to some characteristic or computed property, such

as color, intensity, or texture. Adjacent regions are significantly different with respect to the

same characteristic(s).

Artificial neural networks have been employed for many years in many different

application areas such as speech recognition and pattern recognition .In general, these models are

composed of many nonlinear computational elements operating in parallel and arranged in

patterns reminiscent of biological neural nets.

Fuzzy logic takes advantage of already created simple rules and image classification

equal or even less time consuming. Considering the level of classification accuracy, fuzzy logic

can be satisfactory used for image classification. Neural network method has some advantages,

stable training results and no requirement of a priori knowledge provided by the simple

competitive learning, and optimization for application that need to high precision.

Page 22: Edge detection1 (3)

Chapter 3

EDGE DETECTION

3.1 Edge Detection

Edge detection is one of the fundamental operations in image processing. Many other operations

are based on edge detection and much has been written about this subject. This chapter will

discuss the subject and explore some basic techniques. The next chapter will discuss some

advanced forms of edge detection.

Detecting edges is a basic operation in image processing. The edges of items in an image

hold much of the information in the image. The edges tell you where items are, their size, shape,

and something about their texture. The top part of Figure shows the side view of an ideal edge.

An edge is where the gray level of the image moves from an area of low values to high values or

vice versa. The edge itself is at the center of this transition. An edge detector should return an

image with gray levels like those shown in the lower part of Figure. The detected edge gives a

bright spot at the edge and dark areas everywhere else. Calculus fans will note the detected edge

is the derivative of the edge. This means it is the slope or rate of change of the gray levels in the

edge. The slope of the edge is always positive or zero and it reaches its maximum at the edge.

For this reason, edge detection is often called image differentiation.

The problem in edge detection is how to calculate the derivative (the slope) of an image

in all directions? Convolution of the image with masks is the most often used technique of doing

this. . The idea is to take a 3 x 3 array of numbers and multiply it point by point with a 3 x 3

section of the image. You sum the products and place the result in the center point of the image.

The question in this operation is how to choose the 3 x 3 mask. These are basic masks that

amplify the slope of the edge. Take the simple one-dimensional case shown in Figure. Look at

the points on the ideal edge near the edge

Page 23: Edge detection1 (3)

Figure- 3.1: Graphs of Gray Scale Values at Edges

Page 24: Edge detection1 (3)

They could have values such as [3 5 7]. The slope through these three points is (7 - 3)/2

= 2. Convolving these three points with [-1 0 1] produces -3 + 7 = 4. The convolution amplified

the slope, and the result is a large number at the transition point in the edge. Convolving [-1 0 1]

with a line performs a type of differentiation or edge detection.

The number of masks used for edge detection is almost limitless. Researchers have used

different techniques to derive masks and then experimented with them to discover more masks.

Figure 5.3 shows four masks used in the source code and examples in this chapter. The first three

masks are the Kirsch, Prewitt, and Sobel masks as given in Levine's text (there are different

masks bearing the same name in the literature). The fourth mask, the \quick" mask, is one I \

created" while working on this process (there is no doubt that someone else created this mask

before me).

The Kirsch, Prewitt, and Sobel masks are \compass gradient" or directional edge

detectors. This means that each of the eight masks detects an edge in one direction. Given a

pixel, there are eight directions to travel to a neighboring pixel (above, below, left, right, upper

left, upper right, lower left, and lower right). Therefore, there are eight possible directions for an

edge. The directional edge detectors can detect an edge in only one of the eight directions. To

detect only left to right edges, use only one of the eight masks. To detect all of the edges,

perform convolution over an image eight times using each of the eight masks. The \quick mask"

is so named because it can detect edges in all eight directions in one convolution. This has

obvious speed advantages. There are, however, occasions when detecting one type of edge is

desired, so use a directional mask for those occasions.

There are two basic principles for each edge detector mask. The first is that the numbers

in the mask sum to zero. If a 3 x 3 area of an image contains a constant value (such as all ones),

then there are no edges in that area. The result of convolving that area with a mask should be

zero. If the numbers in the mask sum to zero, convolving the mask with a constant area will

result in the correct answer of zero. The second basic principle is that the mask should

approximate differentiation or amplify the slope of the edge. The simple example [-1 0 1] given

Page 25: Edge detection1 (3)

earlier showed how to amplify the slope of the edge. The first Kirsch, Prewitt, and Sobel masks

use this idea to amplify an edge ramping up from the bottom of an image area to the top.

3.2 Implementing Edge Detectors

The functions detect edges and perform convolution implement the Kirsch, Prewitt, and Sobel

edge detectors. The detect edges function calls perform convolution to detect the edges. Next, it

“fixes" the edges of the output image (more on this later) and writes it to the output image file.

The function perform convolution does the convolution operation eight times (once for

each direction) to detect all the edges. First, it calls setup masks to copy the correct masks. The

parameter detect type determines which masks to use. The convention is type 1=Prewitt,

2=Kirsch, and 3=Sobel. The function perform convolution clears the output image, sets several

maximum values, and does the convolution eight times over the entire image array. At each

point, the code checks to see if the result of convolution is greater than the maximum allowable

value or less than zero, and corrects for these cases.

After convolution, there is the option of thresholding the output of edge detection. Edge

detectors produce results that vary from zero to the maximum gray level value. This variation

shows the strength of an edge. An edge that changes from 10 to 200 will be stronger than one

that changes from 10 to 50. The output of convolution will indicate this strength. It is often

desirable to threshold the output so strong edges will appear relatively bright (or dark) and weak

edges will not appear at all. This lowers the amount of noise in the edge detector output and

yields a better picture of the edges. The detect edges and perform convolution functions pass a

threshold parameter.

If threshold == 1, perform convolution goes through the output image and sets any pixel

above the high parameter to the maximum and any pixel below the high parameter to zero.

The quick edge function performs edge detection using the single 3 x 3 quick mask. It

performs convolution over the image array using the quick mask. It thresholds the output image

if requested, and fixes the edges of the output image. All these operations are the same as in the

detect edges and perform convolution functions.

Page 26: Edge detection1 (3)

Several short utility functions make up the remainder of Listing 5.1. The setup masks

function copies the desired type of mask (Kirsch, Prewitt, or Sobel) into the mask arrays for the

perform convolution function. The fix edges function corrects the output image after convolution

(fix edges is shown in this listing, but resides in source code file utility.c). Convolving a 3 x 3

mask over an image array does not process the pixels along on the outer edge of the image. The

result is a blank line around the image array. The fix edges function goes around the edge of the

image array and copies valid values out to the edge. This removes the distracting lines. These

edge detectors are called by the main routine of the medge program. The medge program ties

these and the edge detectors described in the next chapter into one convenient program. That

program is presented in the next chapter.

The simplest method of image segmentation is called the threshold method. This method

is based on a clip-level (or a threshold value) to turn a gray-scale image into a binary image. The

key of this method is to select the threshold value (or values when multiple-levels are selected).

Several popular methods are used in industry including the maximum entropy method, Otsu's

method (maximum variance), and et al. k-means clustering can also be used.

Edge detection is a well-developed field on its own within image processing. Region

boundaries and edges are closely related, since there is often a sharp adjustment in intensity at

the region boundaries. Edge detection techniques have therefore been used as the base of another

segmentation technique. The edges identified by edge detection are often disconnected. To

segment an object from an image however, one needs closed region boundaries.

For any given segmentation of an image, this scheme yields the number of bits required

to encode that image based on the given segmentation. Thus, among all possible segmentations

of an image, the goal is to find the segmentation which produces the shortest coding length. This

can be achieved by a simple agglomerative clustering method. The distortion in the lossy

compression determines the coarseness of the segmentation and its optimal value may differ for

each image. This parameter can be estimated heuristically from the contrast of textures in an

image. For example, when the textures in an image are similar, such as in camouflage images,

stronger sensitivity and thus lower quantization is required.

Page 27: Edge detection1 (3)

Chapter 4

MATLAB

4.1 Introduction to MATLAB

MATLAB is a high-performance language for technical computing. It integrates computation,

visualization, and programming in an easy-to-use environment where problems and solutions are

expressed in familiar mathematical notation. Typical uses include

Math and computation

Algorithm development

Data acquisition

Modeling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

Application development, including graphical user interface building

Figure- 4.1: MATLAB LOGO

Page 28: Edge detection1 (3)

MATLAB is an interactive system whose basic data element is an array that does not

require dimensioning. This allows you to solve many technical computing problems, especially

those with matrix and vector formulations, in a fraction of the time it would take to write a

program in a scalar non interactive language such as C or FORTRAN. The name MATLAB

stands for matrix laboratory. MATLAB was originally written to provide easy access to matrix

software developed by the LINPACK and EISPACK projects. Today, MATLAB engines

incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for

matrix computation.

MATLAB has evolved over a period of years with input from many users. In university

environments, it is the standard instructional tool for introductory and advanced courses in

mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-

productivity research, development, and analysis. MATLAB features a family of add-on

application-specific solutions called toolboxes. Very important to most uses of MATLAB,

toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive

collections of MATLAB functions (M-files) that extend the MATLAB environment to solve

particular classes of problems. Areas in which toolboxes are available include signal processing,

control systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

MATLAB provides a number of features for documenting and sharing your work. You

can integrate your MATLAB code with other languages and applications, and distribute your

MATLAB algorithms and applications. The MATLAB language supports the vector and matrix

operations that are fundamental to engineering and scientific problems. It enables fast

development.

With the MATLAB language, you can program and develop algorithms faster than with

traditional languages because you do not need to perform low-level administrative tasks, such as

declaring variables, specifying data types, and allocating memory. In many cases, MATLAB

eliminates the need for ‘for’ loops. As a result, one line of MATLAB code can often replace

several lines of c.

Page 29: Edge detection1 (3)

At the same time, MATLAB provides all the features of a traditional programming

language, including arithmetic operators, flow control, data structures, data types, object-oriented

programming (OOP), and debugging features.

MATLAB

MATLAB is a high-level technical computing language and interactive environment for

algorithm development, data visualization, data analysis, and numeric computation. Using the

MATLAB product, you can solve technical computing problems faster than with traditional

programming languages, such as C, C++, and Fortran.

You can use MATLAB in a wide range of applications, including signal and image

processing, communications, control design, test and measurement, financial modeling and

analysis, and computational biology. Add-on toolboxes (collections of special-purpose

MATLAB functions, available separately) extend the MATLAB environment to solve particular

classes of problems in these application areas.

MATLAB provides a number of features for documenting and sharing your work. You

can integrate your MATLAB code with other languages and applications, and distribute your

MATLAB algorithms and applications.

Key Features High-level language for technical computing

Development environment for managing code, files, and data

Interactive tools for iterative exploration, design, and problem solving

Mathematical functions for linear algebra, statistics, Fourier analysis, filtering,

optimization, and numerical integration

2-D and 3-D graphics functions for visualizing data

Tools for building custom graphical user interfaces

Page 30: Edge detection1 (3)

Functions for integrating MATLAB based algorithms with external applications and

languages, such as C, C++, Fortran, Java, COM, and Microsoft Excel

In computing a graphical user interface (GUI, sometimes pronounced gooey,) is a type

of user interface that allows users to interact with electronic devices with images rather than text

commands.GUIs can be used in computers, hand-held devices such as MP3 players, portable

media players or gaming devices, household appliances and office equipment . A GUI represents

the information and actions available to a user through graphical icons and visual indicators such

as secondary notation, as opposed to text-based interfaces, typed command labels or text

navigation. The actions are usually performed through direct manipulation of the graphical

elements.

The term GUI is historically restricted to the scope of two-dimensional display screens

with display resolutions capable of describing generic information, in the tradition of

the computer science research at the Palo Alto Research Center (PARC). The term GUI earlier

might have been applicable to other high-resolution types of interfaces that are non-generic, such

as videogames, or not restricted to flat screens, like volumetric displays.

4.2 The MATLAB system

The MATLAB system consists of five main parts

Development Environment:

This is the set of tools and facilities that help you use MATLAB functions and files. Many of

these tools are graphical user interfaces. It includes the MATLAB desktop and command

window, a command history, an editor and debugger, and browsers for viewing help, the

workspace, files, and the search path.

The MATLAB Mathematical Function Library

Page 31: Edge detection1 (3)

This is a vast collection of computational algorithms ranging from elementary functions, like

sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse,

matrix Eigen values, Bessel functions, and fast Fourier transforms.

The MATLAB Language

This is a high-level matrix/array language with control flow statements, functions, data

structures, input/output, and object-oriented programming features. It allows both “programming

in the small” to rapidly create quick and dirty throw-away programs, and “programming in the

large” to create large and complex application programs.

Graphics

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as

annotating and printing these graphs. It includes high-level functions for two-dimensional and

three-dimensional data visualization, image processing, animation, and presentation graphics. It

also includes low-level functions that allow you to fully customize the appearance of graphics as

well as to build complete graphical user interfaces on your MATLAB applications.

The MATLAB Application Program Interface (API)

This is a library that allows you to write C and FORTRAN programs that interact with

MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), calling

MATLAB as a computational engine, and for reading and writing MAT-files. Various toolboxes

are there in MATLAB for computing recognition techniques, but we are using IMAGE

PROCESSING toolbox.

4.3 Graphical User Interface (GUI)

MATLAB’s Graphical User Interface Development Environment (GUIDE) provides a rich set of

tools for incorporating graphical user interfaces (GUIs) in M-functions. Using GUIDE, the

processes of laying out a GUI (i.e its buttons, pop-up menus, etc.)and programming the operation

Page 32: Edge detection1 (3)

of the GUI are divided conveniently into two easily managed and relatively independent tasks.

The resulting graphical M-function is composed of two identically named (ignoring extensions)

files:

A file with extension .fig, called a FIG-file that contains a complete graphical description of

all the function’s GUI objects or elements and their spatial arrangement. A FIG-file contains

binary data that does not need to be parsed when he associated GUI-based M-function is

executed.

A file with extension .m, called a GUI M-file, which contains the code that controls the GUI

operation. This file includes functions that are called when the GUI is launched and exited,

and callback functions that are executed when a user interacts with GUI objects for example,

when a button is pushed.

To launch GUIDE from the MATLAB command window, type guide filename. Where filename

is the name of an existing FIG-file on the current path. If filename is omitted, GUIDE opens a

new (i.e., blank) window.

A graphical user interface (GUI) is a human-computer interface (i.e., a way for humans to

interact with computers) that uses windows, icons and menus and which can be manipulated by a

mouse (and often to a limited extent by a keyboard as well).

GUIs stand in sharp contrast to command line interfaces (CLIs), which use only

text and are accessed solely by a keyboard. The most familiar example of a CLI to many people

is MS-DOS. Another example is Linux when it is used in console mode (i.e., the entire screen

shows text only).

A window is a (usually) rectangular portion of the monitor screen that can display its

contents (e.g., a program, icons, a text file or an image) seemingly independently of the rest of

the display screen. A major feature is the ability for multiple windows to be open

simultaneously. Each window can display a different application, or each can display different

files (e.g., text, image or spreadsheet files) that have been opened or created with a single

application.

Page 33: Edge detection1 (3)

Figure- 4.2: GUI Window

An icon is a small picture or symbol in a GUI that represents a program (or command), a

file, a directory or a device (such as a hard disk or floppy). Icons are used both on

the desktop and within application programs. Examples include small rectangles (to represent

files), file folders (to represent directories), a trash can (to indicate a place to dispose of

Page 34: Edge detection1 (3)

unwanted files and directories) and buttons on web browsers (for navigating to previous pages,

for reloading the current page, etc.).

Commands are issued in the GUI by using a mouse, trackball or touchpad to first move a

pointer on the screen to, or on top of, the icon, menu item or window of interest in order

to select that object. Then, for example, icons and windows can be moved by dragging (moving

the mouse with the held down) and objects or programs can be opened by clicking on their icons.

Advantages of GUIs

A major advantage of GUIs is that they make computer operation more intuitive, and thus easier

to learn and use. For example, it is much easier for a new user to move a file from one directory

to another by dragging its icon with the mouse than by having to remember and type seemingly

arcane commands to accomplish the same task.

Adding to this intuitiveness of operation is the fact that GUIs generally provide users

with immediate, visual feedback about the effect of each action. For example, when a user

deletes an icon representing a file, the icon immediately disappears, confirming that the file has

been deleted (or at least sent to the trash can). This contrasts with the situation for a CLI, in

which the user types a delete command (inclusive of the name of the file to be deleted) but

receives no automatic feedback indicating that the file has actually been removed.

In addition, GUIs allow users to take full advantage of the powerful multitasking (the

ability for multiple programs and/or multiple instances of single programs to run simultaneously)

capabilities of modern operating systems by allowing such multiple programs and/or instances to

be displayed simultaneously. The result is a large increase in the flexibility of computer use and

a consequent rise in user productivity.

But the GUI has became much more than a mere convenience. It has also become the

standard in human-computer interaction, and it has influenced the work of a generation of

computer users. Moreover, it has led to the development of new types of applications and entire

new industries. An example is desktop publishing, which has revolutionized (and partly wiped

out) the traditional printing and typesetting industry.

Page 35: Edge detection1 (3)

Despite the great convenience of the GUI however, system administrators and other

advanced users tend to prefer the CLI for many operations because it is frequently more

convenient and generally more powerful1. On Unix-like operating systems, GUIs are actually just

attractive, convenient coverings for command line programs (i.e., programs which operate from a

CLI), and they rely on them for their operation.

One of the great attractions of Unix-like operating systems is that they have maintained

their CLI capabilities while continuing to improve their GUIs, thereby allowing advanced users

to harness the full power of the computer while simultaneously making it easier for beginning

and intermediate users. In contrast, the newer versions of Microsoft Windows (such as 2000 and

XP) have downgraded their CLIs to marginal roles.

A graphical user interface (GUI) is a graphical display in one or more windows

containing controls, called components that enable a user to perform interactive tasks. The user

of the GUI does not have to create a script or type commands at the command line to accomplish

the tasks. Unlike coding programs to accomplish tasks, the user of a GUI need not understand the

details of how the tasks are performed.

GUI components can include menus, toolbars, push buttons, radio buttons, list boxes, and

sliders just to name a few. GUIs created using MATLAB tools can also perform any type of

computation, read and write data files, communicate with other GUIs, and display data as tables

or as plots.

In computing a graphical user interface (GUI, sometimes pronounced gooey,[1]) is a

type of user interface that allows users to interact with electronic devices with images rather than

text commands. GUIs can be used in computers, hand-held devices such as MP3 players,

portable media players or gaming devices, household appliances and office equipment .

A GUI represents the information and actions available to a user through graphical icons and

visual indicators such as secondary notation, as opposed to text-based interfaces, typed command

labels or text navigation. The actions are usually performed through direct manipulation of the

graphical elements.[2]

The term GUI is historically restricted to the scope of two-dimensional display screens

with display resolutions capable of describing generic information, in the tradition of

Page 36: Edge detection1 (3)

the computer science research at the Palo Alto Research Center (PARC). The term GUI earlier

might have been applicable to other high-resolution types of interfaces that are non-generic, such

as video games, or not restricted to flat screens, like volumetric displays.[3]

The GUIs familiar to most people today are Microsoft Windows, Mac OS X, and X

Window System interfaces. Apple, IBM and Microsoft used many of Xerox's ideas to develop

products, and IBM's Common User Access specifications formed the basis of the user interface

found in Microsoft Windows, IBM OS/2 Presentation Manager, and the Unix Motif toolkit

and window manager. . Unlike coding programs to accomplish tasks, the user of a GUI need not

understand the details of how the tasks are performed These ideas evolved to create the interface

found in current versions of Microsoft Windows, as well as in Mac OS X and various desktop

environments for Unix-like operating systems, such as Linux. Thus most current GUIs have

largely common idioms. . In contrast, the newer versions of Microsoft Windows (such as 2000

and XP) have downgraded their CLIs to marginal roles.

Page 37: Edge detection1 (3)

Chapter 5

PROJECT DESCRIPTION

5.1 Block Diagram

Figure- 5.1: Block Diagram description

5.2 Sobel Edge Detection Enhancement Algorithm

In edge detection, the Sobel operator is used commonly. The Sobel operator is a classic first

order edge detection operator, computing an approximation of the gradient of the image intensity

function. At each point in the image, the result of the Sobel operator is the corresponding norm

of this gradient vector. The Sobel operator only considers the two orientations which are 0°and

90°convolution kernels. The operator uses the two kernels which are convolved with the original

image to calculate approximations of the gradient. The two convolution kernels are designed to

respond maximally to edges running vertically and horizontally relative to the pixel grid, one

kernel for each of the two perpendicular orientations. The kernels can be applied separately to

the input image, to produce separate measurements of the gradient component in each orientation

(call these Gx and Gy).

INPUT IMAGE

SOBEL OPERATOR

EDGE DETECTIONFPGA

SPARTAN 3E

UARTOUTPUT IMAGE

Page 38: Edge detection1 (3)

These can then be combined together to find the absolute magnitude of the gradient at

each point. The gradient magnitude is given by:

Typically, an approximate magnitude is computed using:

This is much faster to compute. The Sobel operator has the advantage of simplicity in

calculation. But the accuracy is relatively low because it only used two convolution kernels to

detect the edge of image. Therefore, the orientation of the convolution kernels is increased from

2 to 4 in order to increase the accuracy of edge detection. The four convolution kernels are

shown in Figure-5.2.

5.3 FPGA Hardware Implementation

This design uses 3×3 convolution kernels, processing 1024×1024×8 Gray Scale Image. The

system is divided into four modules: 3×3 pixel generation module, Sobel enhancement operator

module edges control module and binary segmentation. In this system, Clk is the clock signal,

Reset is the reset signal and EN is data control signal, Data input is the pixel signal of Gray Scale

Image, Result is the result of edge detection operator signal, Generation data and Data are the

middle signal.

5.3.1 .3×3 Pixel Generation Module

Figure- 5.2: Sobel Operators

Page 39: Edge detection1 (3)

This module consists of 3 shift register groups and two FIFO. The FIFO is used to cache

a line of image data. The image data input according to the clock signal, so P1, P2, •••, P9 is the

3 × 3 image data template. When the data is continuously input, 3×3 image data template change.

It can contain all pixels of an image. The FIFO is generated by dual-port RAM instead of FIFO

IP core.

5.3.2 Sobel Enhancement Operator Module

The parallel processing construction is used in orientation convolution kernel. The

orientation convolution result is compared each other, and then, the maximum value is the

output. The pipeline structure is used to calculate each orientation convolution kernel. It is six

corresponding input data because three coefficients of each convolution kernel are zero;

Multiplied by 2 is instead by one left.

5.3.3 Edges Control Module

The structure of edges control module is shown in Fig. Clk is the clock signal and Reset is the

reset signal; Turn is enable signal, when the Turn valid, the module work. EN is the output data

control signal. This module can know where the current pixel location and whether it is the edges

of the pixel image. Sobel edge detection enhancement operator can not deal with the left edge,

right edge, the up edge and down edge. In this design, the result of the edge pixels is set to zero,

otherwise, call Sobel enhancement operator module.

5.3.4 Binary Segmentation Module

The structure of binary segmentation module is shown in Fig. EN is the output data control

signal. Data is the result of the Sobel enhancement operator module. Result is 0 or 255. In this

module, the final result is the binary image of edge detection having only two pixel values

according to the given threshold value, i.e., 0 and 255.

Page 40: Edge detection1 (3)

Chapter 6

DEVELOPING CUSTOM LOGIC

6.1 Introduction To EDK Tool

EDK 8.1 Micro Blaze Tutorial in Spartan 3E

This tutorial will demonstrate process of creating and testing a Micro Blaze system design using

the Embedded Development Kit (EDK). EDK is the combination of software and hardware by

the name of embedded. EDK itself contains two parts

Xilinx Platform Studio (XPS)

Software Development Kit (SDK)

6.1.1 Defining the Hardware Design (XPS)

The tutorial consists of the following section

System Requirements

Micro Blaze System Description

Tutorial Steps

The following steps are described in this tutorial:

Starting XPS

Using the Base System Builder Wizard

Create – Import IP Peripheral

Design Modification using Platform Studio

Implementing the Design

Page 41: Edge detection1 (3)

Defining the Software Design

Downloading the Design

Debugging the Design

Performing Behavioral Simulation of the Embedded System

6.1.2 System Requirements

You must have the following software installed on your PC to complete this tutorial:

• Windows 2000 SP2/Windows XP

Note: This tutorial can be completed on Linux or Solaris, but the screenshots and directories

illustrated in this tutorial are based on the Windows Platform.

EDK 8.1i or later

ISE 8.1i sp1 or later

In order to download the completed processor system, you must have the following hardware:

Xilinx Spartan-3 Evaluation Board (3S200 FT256 -4)

Xilinx Parallel -4 Cable used to program and debug the device

Serial Cable

6.1.3 Micro Blaze System Description

In general, to design an embedded processor system, you need the following:

Hardware components

Memory map

Software application

Tutorial Design Hardware

Page 42: Edge detection1 (3)

The Micro Blaze (MB) tutorial design includes the following hardware components:

Micro Blaze

Local Memory Bus (LMB) Bus

LMB_BRAM_IF_CNTLR

BRAM_BLOCK

On-chip Peripheral Bus (OPB) BUS

OPB_MDM

OPB_UARTLITE

3 - OPB_GPIOs

OPB_EMC

Setup

Spartan-3 board with a RS-232 terminal connected to the serial port and configured for 57600

baud, with 8 data bits, no parity and no handshakes.

Creating the Project File in XPS

The first step in this tutorial is using the Xilinx Platform Studio (XPS) to create a project file.

XPS allows you to control the hardware and software development of the Micro Blaze system,

and includes the following:

• An editor and a project management interface for creating and editing source code

• Software tool flow configuration options

You can use XPS to create the following files

• Project Navigator project file that allows you to control the hardware implementation flow

Page 43: Edge detection1 (3)

• Microprocessor Hardware Specification (MHS) file

• Microprocessor Software Specification (MSS) file

XPS supports the software tool flows associated with these software specifications. Additionally,

you can use XPS to customize software libraries, drivers, and interrupt handlers, and to compile

your programs.

Starting XPS

• To open XPS, select Start → Programs → Xilinx Platform Studio 8.1i → Xilinx Platform

Studio

• Select Base System Builder Wizard (BSB) to open the Create New Project Using BSB

Wizard dialog box shown in Figure 1.

• Click Ok.

• Use the Project File Browse button to browse to the folder you want as your project

directory.

• Click Open to create the system.xmp file then Save.

• Click Ok to start the BSB wizard.

MHS and MPD Files

The next step in the tutorial is defining the embedded system hardware with the Microprocessor

Hardware Specification (MHS) and Microprocessor Peripheral Description (MPD) files. The

MPD file contains all of the available ports and hardware parameters for a peripheral. The

tutorial MPD file is located in the following directory.

MHS File

The Microprocessor Hardware Specification (MHS) file describes the following:

Page 44: Edge detection1 (3)

• Embedded processor: either the soft core MicroBlaze processor or the hard core PowerPC (only

available in Virtex-II Pro and Virtex-4 FX devices)

• Peripherals and associated address spaces

• Buses

• Overall connectivity of the system

The MHS file is a readable text file that is an input to the Platform Generator (the hardware

system building tool). Conceptually, the MHS file is a textual schematic of the embedded

system. To instantiate a component in the MHS file, you must include information specific to the

component.

MPD File

Each system peripheral has a corresponding MPD file. The MPD file is the symbol of the

embedded system peripheral to the MHS schematic of the embedded system. The MPD file

contains all of the available ports and hardware parameters for a peripheral. The tutorial MPD

file is located in the following directory:

$XILINX_EDK/hw/Xilinx Processor IPLib/pcores/<peripheral name>/data

EDK provides two methods for creating the MHS file. Base System Builder Wizard and the

dd/Edit Cores Dialog assist you in building the processor system, which is defined in the MHS

file. This tutorial illustrates the Base System Builder. This tutorial will demonstrate process of

creating and testing a Micro Blaze system design using the Embedded

• Use the following steps to create the processor system:

• In the Base System Builder – Select “I would like to create a new design” then click

Next.

• In the Base System Builder - Select Board Dialog select the following, as shown in

Figure 2:

• Board Vendor: Xilinx

Page 45: Edge detection1 (3)

• Board Name: Spartan-3E

• Board Version: C, D.

To debug the design, follow these steps:

In XPS select Debug-> XMD debug Options. The XMD Debug Options dialog box allows the

user to specify the connections type and JTAG chain Definition. The connection types are

available for Micro Blaze:

• Simulator – enables XMD to connect to the Micro Blaze ISS

• Hardware – enables XMD to connect to the MDM peripheral in the hardware

• Stub – enables XMD to connect to the JTAG UART or UART via XMDSTUB

• Virtual platform – enables a virtual (c model) to be used

Verify that Hardware is selected

Select Save

Select Debug -> Launch XMD

6.1.4 XILINX ISE

The Xilinx Integrated Software Environment (ISE) is a software suite that allows a user to take a

design from the design entry stage through to the Xilinx device programming stage. The ISE

Project Navigator provides management and processing of the design by implementing the

following steps in the ISE design flow design through the following steps in the ISE design flow.

This project uses the ISE project navigator version 8.2.03i to implement the design.

Design Entry

This is the very first step in the ISE design process. During this stage the user creates the

project source files based on the design objectives. Programming languages can be used

Page 46: Edge detection1 (3)

to create the top-level design file i.e. Hardware Description Languages (HDL) such as

Verilog, ABEL or VHDL, alternatively, a schematic may be used. A number of formats

may be used to create the lower level source files in the design. The designer may be

working with a synthesized EDIF (Electronic data Interchange Format) file that has been

generated by a third party design entry tool or an NGC/NGO file, if this is the case,

design entry and synthesis can be skipped.

Synthesis

Once Design Entry has been completed the designer may run the synthesis tool. During

this stage the language design used e.g. VHDL or Verilog is converted into net list files

that are used as inputs into the implementation process. Once this step is completed a

synthesis report is generated which can be viewed. A Technology and Real-Time Logic

(RTL) schematic is also created. The Syntax is checked and once verified, the next step

may be implemented.

Implementation

Once the implementation tool has been run the logical design is converted into a physical

format (e.g. Bit File) that may be downloaded to the specified target device. In this

project the target device is the Spartan board. From within Project Navigator the

implementation process may be run in one or multiple steps depending on whether the

designer is targeting a Field Programmable Gate Array (FPGA) or a Complex

Programmable Logic Device (CPLD). Multiple reports are generated during this stage

that may be useful to the designer.

Verification

Verification may be carried out at multiple stages in the design flow. Simulation software

can be used to test the timing and the functionality of the whole design or a particular part

Page 47: Edge detection1 (3)

of the design. Simulation allows the designer to create and verify complex functions

speedily. During simulation, the source code used e.g. VHDL or Verilog is interpreted

into circuit functionality and logical results of the described HDL are displayed to

determine the correct operation of the circuit.

Device Configuration

Once a programming file has been generated, the target device may be configured. A

programming file generation report is also available after this stage is completed. During

configuration, the Xilinx tool generates configuration files and programming files may be

downloaded from a host computer to a Xilinx device.

6.2 Visual Basic

Visual Basic is the third-generation event-driven programming language and  integrated

development environment (IDE) from Microsoft for its COM programming model. Visual Basic

is relatively easy to learn and use.

Visual Basic was derived from BASIC and enables the rapid application development

(RAD)of graphical user interface (GUI) applications, access to databases using Data Access

Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and

objects. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic,

but perform differently.[3]

A programmer can put together an application using the components provided with

Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing

so requires external function declarations.

6.2.1 Getting started with VISUAL BASIC 6.0

Visual Basic is initiated by using the Programs option > Microsoft Visual Basic 6.0 > Visual

Basic 6.0. Clicking the Visual Basic icon, we can view a copyright screen enlisting the details of

the license holder of the copy of Visual Basic 6.0. Then it opens in to a new screen as shown in

Page 48: Edge detection1 (3)

figure 1 below, with the interface elements Such as MenuBar, ToolBar, The New Project dialog

box. These elements permit the user to buid different types of Visual Basic applications

Figure- 6.1: Blank form in Visuaal basic 6.0

6.2.2 The Integrated Development Environment

One of the most significant changes in Visual Basic 6.0 is the Integrated Development

Environment (IDE). IDE is a term commonly used in the programming world to describe the

interface and environment that we use to create our applications. It is called integrated because

we can access virtually all of the development tools that we need from one screen called an

interface. The IDE is also commonly referred to as the design environment, or the program.

The Visual Basic IDE is made up of a number of components

Menu Bar

Tool Bar

Page 49: Edge detection1 (3)

Project Explorer

Properties window

Form Layout Window

Toolbox

Form Designer

Object Browser

In previous versions of Visual Basic, the IDE was designed as a Single Document

Interface (SDI). In a Single Document Interface, each window is a free-floating window that is

contained within a main window and can move anywhere on the screen as long as Visual Basic

is the current application. But, in Visual Basic 6.0, the IDE is in a Multiple Document Interface

(MDI) format. In this format, the windows associated with the project will stay within a single

container known as the parent. Code and form-based windows will stay within the main

container form.

6.2.3 Menu Bar

This Menu Bar displays the commands that are required to build an application. The main menu

items have sub menu items that can be chosen when needed. The toolbars in the menu bar

provide quick access to the commonly used commands and a button in the toolbar is clicked once

to carry out the action represented by it.

6.2.4 Toolbox

The Toolbox contains a set of controls that are used to place on a Form at design time thereby

creating the user interface area. Additional controls can be included in the toolbox by using the

Components menu item on the Project menu. A Toolbox is represented in figure shown below.

Page 50: Edge detection1 (3)

Toolboxes commonly have a hinged cover for a top with a handle for carrying, and one

or more latches securing the cover to the box. Open smaller compartments are typically located

inside, but larger toolboxes will often have a removable tote tray sitting on a flange inside the lip

of the box, with a single larger compartment below.

Figure- 6.2: Toolbox window with its controls available commonly

6.2.5 Properties Window

The Properties Window is docked under the Project Explorer window. The Properties Window

exposes the various characteristics of selected objects. Each and every form in an application is

considered an object. Now, each object in Visual Basic has characteristics such as color and size.

Other characteristics affect not just the appearance of the object but the way it behaves too. All

these characteristics of an object are called its properties.

Chapter 7

CODING

7.1 Source coding

Page 51: Edge detection1 (3)

#include "stdio.h"

#include "math.h"

#include <house.h>

int kernel_hr[3][3];

int kernel_vr[3][3];

int INPUT[128][128];

int output1[128][128];

int output2[128][128];

int Sliding_window_hr[3][3];

int Sliding_window_vr[3][3];

void main(){

int i,j;

int len=127;

kernel_hr[0][0] = -2; kernel_hr[0][1] = -1; kernel_hr[0][2] = 0;

kernel_hr[1][0] = -1; kernel_hr[1][1] = 0; kernel_hr[1][2] = 1;

kernel_hr[2][0] = 0; kernel_hr[2][1] = 1; kernel_hr[2][2] = 2;

kernel_vr[0][0] = 0; kernel_vr[0][1] = -1; kernel_vr[0][2] = -2;

kernel_vr[1][0] = 1; kernel_vr[1][1] = 0; kernel_vr[1][2] = -1;

kernel_vr[2][0] = 2; kernel_vr[2][1] = 1; kernel_vr[2][2] = 0;

for( i=0;i<128;i++){

for( j=0;j<128;j++){

INPUT[i][j]=hai[i][j];

xil_printf("%d\n",INPUT[i][j]);}

}

for(i=0;i<128;i++){

for (j=0;j<128;j++){

if (i==0 & j==0){

}

Page 52: Edge detection1 (3)

else if (i==0 & j==len){

}else if (i==len & j==0){

}else if (j==len & i==len){

}else if (i==1){

}else if (i==len){

}else if (j==len){

}else if (j==1){

}else{

Sliding_window_hr[1][1]=INPUT[i-1][j-1]*kernel_hr[0][0];

Sliding_window_hr[1][2]=INPUT[i-1][j]*kernel_hr[0][1];

Sliding_window_hr[1][3]=INPUT[i-1][j+1]*kernel_hr[0][2];

Sliding_window_hr[2][1]=INPUT[i][j-1]*kernel_hr[1][0];

Sliding_window_hr[2][2]=INPUT[i][j]*kernel_hr[1][1];

Sliding_window_hr[2][3]=INPUT[i][j+1]*kernel_hr[1][2];

Sliding_window_hr[3][1]=INPUT[i+1][j-1*kernel_hr[2][0];

Sliding_window_hr[3][2]=INPUT[i+1][j]*kernel_hr[2][1];

Sliding_window_hr[3][3]=INPUT[i+1][j+1]*kernel_hr[2][2];

output1[i][j]=Sliding_window_hr[1][1]+Sliding_window_hr[1][2]+Sliding_window_hr[1][3]+Sliding_window_hr[2][1]+Sliding_window_hr[2][2]+Sliding_window_hr[2][3]+Sliding_window_hr[3][1]+Sliding_window_hr[3][2]+Sliding_window_hr[3][3];

Sliding_window_vr[1][1]=INPUT[i-1][j-1]*kernel_vr[0][0];

Page 53: Edge detection1 (3)

Sliding_window_vr[1][2]=INPUT[i-1][j]*kernel_vr[0][1];

Sliding_window_vr[1][3]=INPUT[i-1][j+1]*kernel_vr[0][2];

Sliding_window_vr[2][1]=INPUT[i][j-1]*kernel_vr[1][0];

Sliding_window_vr[2][2]=INPUT[i][j]*kernel_vr[1][1];

Sliding_window_vr[2][3]=INPUT[i][j+1]*kernel_vr[1][2];

Sliding_window_vr[3][1]=INPUT[i+1][j-1]*kernel_vr[2][0];

Sliding_window_vr[3][2]=INPUT[i+1][j]*kernel_vr[2][1];

Sliding_window_vr[3][3]=INPUT[i+1][j+1]*kernel_vr[2][2];

output2[i][j]=Sliding_window_vr[1][1]+Sliding_window_vr[1][2]+Sliding_window_vr[1][3]+Sliding_window_vr[2][1]+Sliding_window_vr[2][2]+Sliding_window_vr[2][3]+Sliding_window_vr[3][1]+Sliding_window_vr[3][2]+Sliding_window_vr[3][3];

}}

}for( i=0;i<128;i++)

{for( j=0;j<128;j++){

if(output1[i][j]>output2[i][j]){

xil_printf("%d\n",output1[i][j]);}else{

xil_printf("%d\n",output2[i][j]);}

}}

}

Page 54: Edge detection1 (3)

Chapter 8

RESULTS

8.1 Results

Fig 8.1 Input image for edge detection

Page 55: Edge detection1 (3)

Figure- 8.2: Result of the Image Edge Detection

Page 56: Edge detection1 (3)

The figure 8.1 specifies the input image whose edges are to be detected and the figure 8.2

specifies the the output image whose edges are detected.The hardware was realized on a Xilinx

FPGA. The processor was coded using VHDL and simulated using XILINX ISE.VHDL cannot

handle the standard image formats, the images were converted to ASCII text files using

MATLAB. The ASCII text file was applied as vector to the hardware interface. The output files

were similarly converted and viewed in MATLAB. The output image is shown Figure- 8.1 . The

execution time for the entire program for an image of size 128x128 is a matter of few seconds.

Page 57: Edge detection1 (3)

Chapter 9

CONCLUSION

Thus the edge of the Image can be effectively detected using Sobel operator apart from the

various Gradient operators. The result of the complex image can be obtained at higher rates by

using FPGA instead of DSP Processors. the image edge detected by this method can be

effectively used in the various fields of satellite images, X-rays, text detection and in mapping of

roads. The Sobel operator adding the orientation of the convolution kernels can locate accurately

the edge, thin the boundary lines, and not be sensitive to noise. The FPGA implementation of it

meets the real-time requirements. This architecture based on FPGA is much better than

processing images on software platform using high level programming languages like C or C++.

Page 58: Edge detection1 (3)

REFERENCES

[1] Jain, Anil K. (1989). Fundamentals of Digital Image Processing, Prentice-Hall, Inc.

[2] Chanda, B. and Dutta, D. Majumdar. (2001). Digital Image Processing and

Analysis,Prentice-Hall of India.

[3] Gonzalez, Rafael C. and Woods, Richard E. (2002). Digital Image Processing,

Pearson Education, Inc.

[4] Pratt, W. K. (2004). Digital Image Processing, John Wiley & Sons, Inc.

[5] Bose, Tamal (2004). Digital Signal and Image Processing, John Wiley & Sons, Inc

[6] Rafael C. Gonzalez, Richard E. Woods . Digital Image Processing (2nd Edition). Prentice

Hall, 2nd edition (January 15, 2002)

[7] D. T.Saegusa, T.Maruyama, Y.Yamaguchi, “How fast is an FPGA in image processing?”,

IEICE Technical Report, Vol.108. No.48, 2008, pp.83–88

[8] Yangli ,Yangbing. “Study of FPGA based Parallel Processing of Sobel Operator” AI

Modern Electronics Technique 2005.J.

[9] SHEN fengting WEI hong “An Improved Thread Edge Detection Method Based On Sobel

Algorithm”. CONTROL&AUTOMATION 2008

[10] Steve Kilts, Advanced FPGA Design: Arichitecture , Implementation , and Optimization ,

John Tiley & Sons

[11] Arrigo Benedetti, Andrea Prati, Nello Scarabottolo. “Image convolution on FPGAs: the

implementation of a multi-FPGA FIFO structure”. Euromicro Conference, 1998.

[12] Spartan FPGA Complete Data Sheet Xilinx Inc.

[13] P. Athanas and A. Abbott. Real-time image processing on a custom computing platform.

In IEEE Computer, Feb. 1995.