Colour Image Segmentation Using FPGA
Colour Image Segmentation Using FPGA
Colour Image Segmentation Using FPGA
Chapter 1
INTRODUCTION
People are only interested in certain parts of the image in the research and application
of the image. These parts are frequently referred as a target or foreground (other part is called
background); they generally correspond to the image in a specific and unique nature of the
area. It needs to extract and separate them in order to identify and analyze object, on this
basis it will be possible to further use for the target. Image segmentation is a technique and
process which divide the image into different feature of region and extract out the interested
target. Here features can be pixel grayscale, colour, texture, etc. Pre-defined targets can
correspond to a single region or multiple regions. To illustrate the level of the image
segmentation in image processing, we have introduced "image engineering" concept ", it
bring the involved theory, methods, algorithms, tools, equipment of image segmentation into
an overall framework. Image Engineering is a new subject for research and application of
image field, its content is very abundant. According to the different of the abstract degree and
research methods, it can be divided into three levels: Image processing, image analysis and
image understanding.
Image processing is emphasis on the transformation between the images and improves
the visual effects of image. Image analysis is mainly monitor and measure the interested
targets in the image in order to get its objective information as a result build up a description
of the image, the key point of the image understanding is further study on the nature of each
target and the linkage of each other as well obtain an explanation of objective scenario for
original image as result guide and plan to action.
Image processing, image analysis and image understanding have different operational,
refer to Figure 1. Image processing is relatively low-level operations; it is mainly operated on
the pixel-level. Then image analysis enters the middle-level, it focuses on measuring,
expression and description of target. Image Understanding is mainly high-level operation,
essentially it focus on the operation and illation of data symbol which abstracts from the
description.
Image segmentation is a key step from the image processing to image analysis, it
occupy an important place. On the one hand, it is the basis of target expression and has
important effect on the feature measurement. On the other hand, as the image segmentation,
the target expression based on segmentation, the feature extraction and parameter
measurement that converts the original image to more abstract and more compact form, it is
possible to make high-level image analysis and understanding.
In the actual production life, the application of image segmentation is also very wide
and almost appeared in all related areas of image processing as well as involved various types
of image. In these applications, image segmentation is usually used for image analysis,
identification and compress code, etc.
Chapter 2
Human eyes can distinguish thousands of colours but can only distinguish 20 kinds of
grayscale, so we can easily and accurately find the target from the colour images. However, it
is difficult to find out from the grayscale image. The reason is that colour can provide more
information than grayscale. The colour for the pattern recognition and machine vision is very
useful and necessary. At present, specifically applied to the colour image segmentation
approach is not so much as for the grayscale images, most of proposed colour image
segmentation methods are the combination of the existing grayscale image segmentation
method on the basis of different colour space. Commonly used for colour image segmentation
methods are histogram threshold, feature space clustering, region-based approach, based on
edge detection methods, fuzzy methods, artificial neural network approach, based on physical
model methods, etc.
The basic idea of region growing is a collection of pixels with similar properties to
form a region. First, we need to find a seed pixel as a started point for each of needed
segmentation. And then merge the same or similar property of pixel (Based on a pre-
determined growing or similar formula to determine) with the seed pixel around the seed
pixel domain into the domain of seed pixel. These new pixels as a new seed pixel to continue
the above process until no more pixels that satisfy the condition can be included, and then the
region has grown. In the practical application of this method we need to address three
questions: first, chose or determined a group of seed pixel which can correctly represent the
required region; second, fixed the formula which can contain the adjacent pixels in the
growth; third, made rules or conditions to stop the growth process. The advantage of region
growing algorithm is easy to complete and compute. Similar to the threshold, the region
growing methods are rarely used alone; it is often used with other segmentation methods. The
practical method of this subject combines the watershed algorithm and region growing
algorithm for colour image segmentation. The disadvantage of region growing: first, it needs
human interaction to obtain the seed point, so that the user needs to implant a seed point in
every region which needs to extract; second, The patterns of regional growth are also
sensitive to noise as result the extracted region has empty or links the separate region under
the case of local effect. This article according a certain rules to automatic select seed pixels as
well as effective solve the first question. We carry on the regional growing on the basis of the
watershed segmentation algorithm; this method effectively solved the second questions.
Domain decomposition technique makes seed region continually split into four rectangular
regions until the internal of every region is similar. Region merging is often combines with
the region growing and domain decomposition in order to merge the similar sub-region into a
domain as large as possible. The disadvantage of domain decomposition technique may cause
destruction of the border.
a) Chose or determined a group of seed pixel which can correctly represent the
required region;
b) Fixed the formula which can contain the adjacent pixels in the growth;
c) Made rules or conditions to stop the growth process. The seed region growing
algorithm is proposed by Adams and Bischof, Metmert and Jackway further described the
dependency relationship between pixels in the seed growth:
i) The first order of dependence occurs when the number of pixels has the same
difference ratio as their vicinity.
ii) The second order of dependence occurs when a pixels has the same difference ratio
as their vicinity.
Frank and Shouxian Cheng applied the automatic seed selection method, they selected
seed which can represents needed segmentation region based on certain similarity criteria and
proposed a strategy to solve the above two pixels dependence. The method in this paper is
combines the watershed algorithm on the basis of Frank and Shouxian Cheng's as well
proposes a new seed region growing method. The selection of growth criteria not only
depends on the specific issues themselves, but also depends on the type of practical image
data. For example, when the image is a colorized, the graphic will be effect by utilize
monochrome criteria. Therefore, we carry on seed selection and regional growth according to
the hue and saturation in the colour image in this paper.
First, we use the watershed algorithm to initialize segmentation for the image as well
as form segmentation results; secondly, according to a certain rules, automatically select the
part of the region as a seed region; on this basis, engage in regional growth. Finally, the
regional merged.
Chapter 3
BLOCK DIAGRAM
The entire block diagram can be divided into 2 segments – the raw data inputting &
the data processing.
INPUTTING IMAGE
The image inputted is either in .tif or .jpg format. The image is loaded using the
MATLAB interface. The inputted image is either of 64x64, 128x128 or 256x256 pixel size.
When the inputted image is of varying size, a resizing mechanism is done to obtain a standard
input image resolution. The inputted image is of RGB colour format. Thus there are 3 planes
of colour schemes – Red, Green & Blue. Here we split the 3 planes into separate planes and
the intensity of each and every plane is considered separately. The intensity variations in each
and every pixel are converted into grayscale. The grayscale values range from 0 to 255,
where 0 represents the Black & 255 represents the White. Each pixel value thus ranging
between 0 and 255 is stored as a header file. Thus the inputted images are converted into raw
bit streams.
DATA PROCESSING
The raw bit stream generated using the MATLAB is transferred to the Spartan 3E
FPGA processor. The algorithm code developed using the Xilinx XPS/IDE is then loaded
into the Spartan 3E using the serial bus. The Spartan 3E performs the algorithm and
segmentation. The entire data processing is done at the Spartan 3E processor. The
thresholding as well as the region growing algorithm is performed at the Spartan. Once the
region of interest has been jotted out using the algorithms, the object recognition is being
performed to determine the nature of the object for our concern. Once the target object has
been identified, the region under interest is outputted back to the system using the UART
Serial Bus Interface.
HARDWARE
Chapter 4
SPARTAN 3 FPGA TRAINER KIT
The FPGA used in the kit is SPARTAN 3E which is a product of Xilinx and it has
got 500k gate. The Spartan 3E used in the trainer kit has a QFP packaging and got a
temperature range of 0 to 85degree Celsius. Generally FPGA is available in two speed grade
high and standard speed grade. It has got a clock generator of 50 kHz which is given as input
to the DCM of FPGA. The trainer kit provides an external SRAM for loading program and
other functions. The SRAM is of 256*16k size. Also others feature like 7segment display,
dip switch, LED, LCD display are provided in the kit. There point for the Vcc to connect
and regulator to regulate the voltage. Generally a 5v adapter is used to connect the kit.
JTAG and RS232 connectors are provided in the kit for programing of the Spartan 3E.
Details of each component are discussed below.
4.2.1 Introduction
4.2.2 Features
I/O CAPABILITIES of Spartan 3E
The Spartan-3E FPGA Select IO interface supports many popular single-ended and
differential standards.
Spartan-3E FPGAs support the single-ended standards like 3.3V low-voltage TTL
(LVTTL) , Low-voltage CMOS (LVCMOS) at 3.3V, 2.5V, 1.8V,1.5V, or 1.2V,3V PCI at 33
MHz, and in some devices, 66 MHz , HSTL I and III at 1.8V, commonly used in memory
applications, SSTL I at 1.8V and 2.5V, commonly used for memory applications. Spartan-3E
FPGAs also support most low voltage differential I/O standards like LVDS which is called
as low voltage differential signaling , Bus LVDS, mini-LVDS, RSDS, Differential HSTL
(1.8V, Types I and III), Differential SSTL (2.5V and 1.8V, Type I), 2.5V LVPECL inputs.
The Configurable Logic Blocks (CLBs) constitute the main logic resource for
implementing synchronous as well as combinatorial circuits. Each CLB contains four slices,
and each slice contains two Look-Up Tables (LUTs) to implement logic and two dedicated
storage elements that can be used as flip-flops or latches. The LUTs can be used as a 16x1
memory (RAM16) or as a 16-bit shift register and additional multiplexers and carry logic
simplify wide logic and arithmetic functions. Each CLB is identical, and the Spartan-3E
family CLB structure is identical to that for the Spartan-3 family.
Figure 6 - CLBs
In case of XC3S500E total 1164 CLBs which is arranged in 46 rows and 34 columns
In Spartan -XC3S500E there are a total of 232 I/O and 56 among them are input only pin.
Dedicated Inputs are IOBs which are used only as inputs. Pin names designate a Dedicated
Input if the name starts with IP, for example, IP or IP_Lxxx_x. Dedicated inputs retain the
full functionality of the IOB for input functions with a single exception for differential inputs
(IP_Lxxx_x). For the differential Dedicated Inputs, the on-chip differential termination is not
available.
signal then feeds a 6-tap delay line. The coarse and tap delays vary. All six taps are available
via a multiplexer for use as an asynchronous input directly into the FPGA fabric. In this way,
the delay is programmable in 12 steps. Three of the six taps are also available via a
multiplexer to the D inputs of the synchronous storage elements. The delay inserted in the
path to the storage element can be varied in six steps. The first, coarse delay element is
common to both asynchronous and synchronous paths, and must be either used or not used
for both paths
The delay values are set up in the silicon once at configuration time. They are non-
modifiable in device operation. The primary use for the input delay element is to adjust the
input delay path to ensure that there is no hold time requirement when using the input flip-
flops with a global clock.
IOBs Organization
The Spartan-3E architecture organizes IOBs into four I/O banks as shown in Figure below.
Each bank maintains separate VCCO and VREF supplies. The separate supplies allow each
bank to independently set VCCO. Similarly, the VREF supplies can be set for each bank.
1. The VCCO supplies, one for each of the FPGA’s I/O banks, power the output drivers. The
voltage on the VCCO pins determines the voltage swing of the output signal.
2. VCCINT is the main power supply for the FPGA’s internal logic.
Block RAM
Spartan-3E devices incorporate 4 to 36 dedicated block RAMs, which are organized as dual-
port configurable 18 Kbit blocks. Block RAM synchronously stores large amounts of data
while distributed RAM, is better suited for buffering small amounts of data anywhere along
signal paths. In case XC3S500E ,we have 20 no of block ram with addressable bits of
368,640 in column of 2.
The block RAM has a dual port structure. The two identical data ports called A and B permit
independent access to the common block RAM, which has a maximum capacity of 18,432
bits. Each port has its own dedicated set of data, control, and clock lines for synchronous read
and write operations.
Multiplier Blocks
The Spartan-3E devices provide 4 to 36 dedicated multiplier blocks per device. The
multipliers are located together with the block RAM in one or two columns depending on
device density. The multiplier blocks primarily perform two’s complement numerical
multiplication but can also perform some less obvious applications, such as simple data
storage and barrel shifting. Logic slices also implement efficient small multipliers and
thereby supplement the dedicated multipliers.
This block Provide self-calibrating, fully digital solutions for distributing, delaying,
multiplying, dividing, and phase-shifting clock signals. The DCM supports three major
functions:
A. Clock-skew Elimination:
Clock skew within a system occurs due to the different arrival times of a clock signal
at different points on the die, typically caused by the clock signal distribution network. Clock
skew increases setup and hold time requirements and increases clock-to-out times, all of
which are undesirable in high frequency applications. The DCM eliminates clock skew by
phase-aligning the output clock signal that it generates with the incoming clock signal. This
mechanism effectively cancels out the clock distribution delays.
B. Frequency Synthesis:
The DCM can generate a wide range of different output clock frequencies derived from
the incoming clock signal. This is accomplished by either multiplying or dividing the
frequency of the input clock signal by any of several different factors.
C. Phase Shifting:
The DCM provides the ability to shift the phase of its entire output clock signals with
respect to the input clock signal.it has the provision to shift the phase 90 and 180
Chapter 5
J TAG
JTAG is an acronym that stands for “Joint Test Action Group”. The group was
a consortium of vendors focused on problems found when testing electronic circuit boards.
Key members included: TI, Intel and others. JTAG is the informal name often used to describe
the standard that resulted from the work of this group. Specifically, the standard is known
as IEEE1149.1 Boundary-Scan. The term JTAG is used to describe test and debug interfaces
based on the specifications brought about by this group. JTAG emulators leverage extended
registers and boundary-scan instructions , put on-chip by the processor manufacturer. These
extra features, allow the JTAG connector to be used to control a microprocessor that is run,
stop, step and read/write memory and registers. JTAG Boundary-Scan Test tools allow the
hardware level debugging, programming and testing of circuit boards.
The main problem that the JTAG group set out to solve was that traditional In-Circuit
Test or ICT, was no longer as effective as it once was for board test. This change was due to
the rise in use of surface mount devices such as Ball Grid Array (BGA) devices. The ever
decreasing size of modern electronic circuits and the rise of multi-layer printed circuit boards
were also key drivers for JTAG. These new devices had their pins (called balls) on the
bottom of the chip. When soldered down to a circuit board the pins could not be accessed as
they were covered by the chip itself. As many of these modern ICs had many hundreds of
pins it quickly became impractical to add test points for all the new pins. The pins that
comprise the TAP interface are used to control the access to a long chain of I/O cells at each
pin of a device. By clocking data patterns in and reading values out, it is possible to set and
determine the state of a pin. By extension, since other non-JTAG devices may be connected
to these pins, those devices can often be tested as well.
JTAG utilizes a standard set of signals to communicate with the IC or ICs under test.
These signals taken together are known as the TAP or Test Access Port. This standard
configuration is typically used for FPGA (such as Xilinx) JTAG programming adapters. The
various signals are:
This is the data from the JTAG tool into the device under test or (DUT)
This is the data out of the last IC in the chain on the DUT back to the test tool
This is the JTAG System CLOCK from the tool into the device
This signal from the tool to the device is used to manipulate the internal state
machine that controls Boundary-Scan operation
This is an optional signal, often used with JTAG emulation or when multiple
chains must be tied together
Other than downloading data to the chip, an important function the j tag can be used to
perform is boundary scan. It can be used in both chip level and board level testing
Boundary Scan allows to do the following types of chip level testing like Presence of the
device – Is the device on the board, did it get soldered on, Orientation of the device, Is it
oriented correctly, is it rotated, shifted, the wrong package, Is it bonded to the board, Is it
soldered properly or are their issues with the solder joint, is the internal pin to amplifier
interconnect damaged, Read the devices ID register (get chip revision level information)
Board Level Testing Boundary Scan is Testing at the board level adds inter-device and
board-level testing such a, Ability to verify the presence and integrity of the entire scan chain
and each device on it, Device interconnect tests, Open, Short and Stuck At (0,1) failures.
When bringing up and debugging your new hardware, Boundary Scan comes to the rescue in
several important ways such as
When you get your initial boards, not all devices may be fitted. As we only need good
power, ground and at least one part on the JTAG Chain to begin testing and we should be
able to ID the part on the chain and then test for opens and shorts for any board area that is
touched by this device.
You may also be able to do initial device programming. For example, if the device on the
chain is a microprocessor or DSP, most likely you will have access to RAM and FLASH
memory via the address, data and control bus. This can allow you to ID and Program and test
these so-called devices like FPGAs, CPLDs.
Prototypes are often rushed through assembly in order to make engineering deadlines.
As a result, assembly and manufacturing problems will exist. Boundary Scan is prefect for
testing for common problems like unfitted or ill fitted devices, solder issues (cold or hot
Joints), as well as open, shorts, stuck at and device functional failures.
As will be able to focus your debug efforts on the new release of firmware, knowing
full well that your hardware is good initial firmware or diagnostics are written for your new
hardware, Boundary Scan can be used to rule out bad hardware.
Chapter 6
RS 232
The RS-232 standard defines the voltage levels that correspond to logical one and
logical zero levels for the data transmission and the control signal lines. Valid signals are plus
or minus 3 to 15 volt. The ±3 V range near zero volts is not a valid RS-232 level. The
standard specifies a maximum open-circuit voltage of 25 volts, signal levels of ±5 V, ±10 V,
±12 V, and ±15 V are all commonly seen depending on the power supplies available within a
device. RS-232 drivers and receivers must be able to withstand indefinite short circuit to
ground or to any voltage level up to ±25 volts.
SOFTWARE
Chapter 7
SOFTWARE DEVELOPMENT TOOLS
The software part of our project involves two sections. They are:
7.1 MATLAB
The algorithm of the MATLAB programming is:-
I. The picture is given as input to MATLAB
II. Input image is resize to required size
III. The input image is converted to grey scale
IV. Image is then converted to bit stream
The output of the MATLAB is the bit stream of the input of the image, which contains all the
information about the pixel values .these is then given to the Spartan trainer kit using a j-tag.
7.3 FLOWCHART
Input Image
Compare with
neighboring pixels
YES If
difference
>
threshold
NO
7.4 ALGORITHM
gui_Singleton = 1;
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
Else
gui_mainfcn(gui_State, varargin{:});
end
handles.output = hObject;
guidata(hObject, handles);
varargout{1} = handles.output;
if isequal(filename,0) | isequal(pathname,0)
else
a=aviread(filename);
axes(handles.axes1);
movie(a);
handles.filename=filename;
guidata(hObject, handles);
end
filename=handles.filename;
str1='frame';
str2='.bmp';
handles.frm_cnt=frm_cnt;
h = waitbar(0,'Please wait...');
for i=1:frm_cnt;
filename1=strcat(strcat(num2str(i)),str2);
waitbar(i/10,h)
end
close(h);
guidata(hObject, handles);
warndlg('process completed');
if isequal(filename,0) | isequal(pathname,0)
else
filename=strcat(pathname,filename);
a=imread(filename);
b=imresize(a,[64 64]);
imshow(b);
handles.a=b;
% imwrite(a,'test.bmp');
guidata(hObject, handles);
end
res= handles.a;
[r c p]=size(res);
if (p==3)
res=rgb2gray(res);
imwrite(res,'test.bmp');
else
imwrite(res,'test.bmp');
end
[r c]=size(res);
res=double(res);
fid=fopen('Image2.h','wt');
fprintf(fid,'%c',as);
fprintf(fid,'\n%c\n','{');
% as=8;
for i=1:c;
te=res(i,:);
fprintf(fid,'%c','{');
fprintf(fid,'%d,',te);
fprintf(fid,'%c','}');
fprintf(fid,'%c\n',',');
end;
fprintf(fid,'%c %c','}',';');
% fprintf(fid,'%c',';');
fclose(fid);
delete('image3.h');
delete('test.bmp');
close all;
exit;
#include <stdio.h>
#include <math.h>
#include "Image4.h"
#include "Image3.h"
int INPUT1[64][64];
int diff1[64][64];
int INPUT2[64][64];
int SEG1[64][64];
int Sliding_windowr[3][3];
int FIRSTFILTER[64][64];
int EDGEIMAGE[64][64];
int n=8,t;
int Cen[8];
int Value_Check,count;
int SR1,SR2,SR3,SR4,SR5,SR6,SR7,SR8,SR9;
int TH1=255;
int TH2=0;
int CHECK1;
int CHECK2;
int CHECK3;
int CHECK4;
int CHECK5;
int CHECK6;
int CHECK7;
int CHECK8;
float bbr;
float median1();
float median1(int SR1,int SR2,int SR3,int SR4,int SR5,int SR6,int SR7,int SR8)
{
int i,j;
float median;
int arr[8];
arr[0]=SR1;
arr[1]=SR2;
arr[2]=SR3;
arr[3]=SR4;
arr[4]=SR5;
arr[5]=SR6;
arr[6]=SR7;
arr[7]=SR8;
for (i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
if (arr[j]<=arr[j+1])
{
t=arr[j];
arr[j]=arr[j+1];
arr[j+1]=t;
}
else
continue;
}//for
}/// for
if (n%2==0)
{
median=(arr[n/2]+arr[n/2+1])/2.0;
}
else
{
median=arr[n/2+1];
}
return (median);
}//end of median
void main()
{
int i,j,count,k,l,m,n;
int temp1,temp2,temp3;
for( i=0;i<64;i++)
{
for( j=0;j<64;j++)
{
INPUT1[i][j]=InputImage3[i][j];
// printf("%d \n",INPUT1[i][j]);
}
for( i=0;i<64;i++)
{
for( j=0;j<64;j++)
{
INPUT2[i][j]=InputImage4[i][j];
printf("%d \n",INPUT2[i][j]);
}
for (i=0;i<64;i++)
{
for (j=0;j<64;j++)
{
diff1[i][j]= (INPUT1[i][j]- INPUT2[i][j]);
printf("%d\n",diff1[i][j]);
}
}
for(i=0;i<64;i++)
{
for (j=0;j<64;j++)
{
Value_Check=diff1[i][j];
if (Value_Check>20)
{
SEG1[i][j]=255;
}
else
{
SEG1[i][j]=0;
}
printf("%d \n",SEG1[i][j]);
}
}
for(i=0;i<64;i++)
{
for (j=0;j<64;j++)
{
if (i==0 & j==0)
{
}
else if (i==127 & j==0)
{
}
else if (j==127 & i==127)
{
}
else if (i==1)
{
}
else if (i==127)
{
}
else if (j==127)
{
}
else if (j==1)
{
}
else
{
Sliding_windowr[1][1]=SEG1[i-1][j-1];
Sliding_windowr[1][2]=SEG1[i-1][i];
Sliding_windowr[1][3]=SEG1[i-1][i+1];
Sliding_windowr[2][1]=SEG1[i][j-1];
Sliding_windowr[2][2]=SEG1[i][j];
Sliding_windowr[2][3]=SEG1[i][j+1];
Sliding_windowr[3][1]=SEG1[i+1][j-1];
Sliding_windowr[3][2]=SEG1[i+1][j];
Sliding_windowr[3][3]=SEG1[i+1][j+1];
// disp(Sliding_window);
SR1=Sliding_windowr[1][1];
SR2=Sliding_windowr[1][2];
SR3=Sliding_windowr[1][3];
SR4=Sliding_windowr[2][1];
SR5=Sliding_windowr[2][3];
///SR6=Sliding_windowr[2][2];
SR6=Sliding_windowr[3][1];
SR7=Sliding_windowr[3][2];
SR8=Sliding_windowr[3][3];
bbr=median1(SR1,SR2,SR3,SR4,SR5,SR6,SR7,SR8);
}
FIRSTFILTER[i][j]=bbr;
printf("%d\n",FIRSTFILTER[i][j]);
}
///////////////////////EDGE DETECTION
for( i=0;i<64;i++)
{
for( j=0;j<64;j++)
{
EDGEIMAGE[j][i]=255;
}
////////////////////////////DETECTING ONES/////////////////
for(i=0;i<64;i++)
{
for (j=0;j<64;j++)
{
if ((i==0)&&(j==0))
{
CHECK1=FIRSTFILTER[j][i+1];
CHECK2=FIRSTFILTER[j+1][i+1];
CHECK3=FIRSTFILTER[j+1][i];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
{
EDGEIMAGE[j][i]=0;
}
else if ((i==0)&&(j==127))
{
CHECK1=FIRSTFILTER[j][i+1];
CHECK2=FIRSTFILTER[j+1][i+1];
CHECK3=FIRSTFILTER[j+1][i];
if (FIRSTFILTER[j+1][i]==TH1)
{
if (FIRSTFILTER[j+1][i-1]==TH1)
{
if (FIRSTFILTER[j][i-1]==TH1)
{
EDGEIMAGE[j][i]=0;
}
else if ((i==127 )&&( j==0))
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i+1];
CHECK3=FIRSTFILTER[j][i+1];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
EDGEIMAGE[j][i]=0;
}
else if ((j==127)&&(i==127))
{
CHECK1=FIRSTFILTER[j][i-1];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j-1][i];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
EDGEIMAGE[j][i]=0;
}
else if (i==1)
{
CHECK1=FIRSTFILTER[j][i-1];
CHECK2=FIRSTFILTER[j+1][i-1];
CHECK3=FIRSTFILTER[j+1][i];
CHECK4=FIRSTFILTER[j+1][i+1];
CHECK5=FIRSTFILTER[j][i+1];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
if (CHECK3==TH1)
if (CHECK4==TH1)
if (CHECK5==TH1)
EDGEIMAGE[j][i]=0;
}
else if (i==127)
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j][i-1];
CHECK4=FIRSTFILTER[j+1][i-1];
CHECK5=FIRSTFILTER[j+1][i];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
{
if (CHECK4==TH1)
{
if (CHECK5==TH1)
EDGEIMAGE[j][i]=0;
}
}
}
}
}
}
else if (j==127)
{
CHECK1=FIRSTFILTER[j][i-1];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j-1][i];
CHECK4=FIRSTFILTER[j-1][i+1];
CHECK5=FIRSTFILTER[j][i+1];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
{
if (CHECK4==TH1)
if (CHECK5==TH1)
EDGEIMAGE[j][i]=0;
}
}
}
}
else if (j==1)
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i+1];
CHECK3=FIRSTFILTER[j][i+1];
CHECK4=FIRSTFILTER[j+1][i+1];
CHECK5=FIRSTFILTER[j+1][i];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
if (CHECK4==TH1)
if (CHECK5==TH1)
EDGEIMAGE[j][i]=0;
}
}
}
}
}
}
else
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j][i-1];
CHECK4=FIRSTFILTER[j+1][i-1];
CHECK5=FIRSTFILTER[j+1][i];
CHECK6=FIRSTFILTER[j][i-1];
CHECK7=FIRSTFILTER[j+1][i-1];
CHECK8=FIRSTFILTER[j+1][i];
if (CHECK1==TH1)
{
if (CHECK2==TH1)
{
if (CHECK3==TH1)
if (CHECK4==TH1)
if (CHECK5==TH1)
if (CHECK6==TH1)
if (CHECK7==TH1)
if (CHECK8==TH1)
EDGEIMAGE[j][i]=0;
} //1
} //2
} //3
}//4
}//5
}//6
}//7
}//8
}
}
}
////////////////////////////////////DETECTING ZEROS
for(i=0;i<64;i++)
{
for (j=0;j<64;j++)
{
if ((i==0)&&(j==0))
{
CHECK1=FIRSTFILTER[j]
[i+1];
CHECK2=FIRSTFILTER[j+1][i+1];
CHECK3=FIRSTFILTER[j+1][i];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
{
EDGEIMAGE[j][i]=0;
}
}
else if ((i==0)&&(j==127))
{
CHECK1=FIRSTFILTER[j][i+1];
CHECK2=FIRSTFILTER[j+1][i+1];
CHECK3=FIRSTFILTER[j+1][i];
if (FIRSTFILTER[j+1][i]==TH2)
{
if (FIRSTFILTER[j+1][i-1]==TH2)
{
if (FIRSTFILTER[j][i-1]==TH2)
{
EDGEIMAGE[j][i]=0;
}
}
}
}
else if ((i==127 )&&( j==0))
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i+1];
CHECK3=FIRSTFILTER[j][i+1];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
EDGEIMAGE[j][i]=0;
}
}
}
else if ((j==127)&&(i==127))
{
CHECK1=FIRSTFILTER[j][i-1];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j-1][i];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
EDGEIMAGE[j][i]=0;
}
}
else if (i==1)
{
CHECK1=FIRSTFILTER[j][i-1];
CHECK2=FIRSTFILTER[j+1][i-1];
CHECK3=FIRSTFILTER[j+1][i];
CHECK4=FIRSTFILTER[j+1][i+1];
CHECK5=FIRSTFILTER[j][i+1];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
if (CHECK3==TH2)
{
if (CHECK4==TH2)
if (CHECK5==TH2)
EDGEIMAGE[j][i]=0;
}
} }
}
}
else if (i==127)
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j][i-1];
CHECK4=FIRSTFILTER[j+1][i-1];
CHECK5=FIRSTFILTER[j+1][i];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
if (CHECK4==TH2)
if (CHECK5==TH2)
EDGEIMAGE[j][i]=0;
}
}
}
}
}
else if (j==127)
{
CHECK1=FIRSTFILTER[j][i-
1];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j-1][i];
CHECK4=FIRSTFILTER[j-1][i+1];
CHECK5=FIRSTFILTER[j][i+1];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
if (CHECK4==TH2)
{
if (CHECK5==TH2)
EDGEIMAGE[j][i]=0;
}
}
}
}
}
else if (j==1)
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i+1];
CHECK3=FIRSTFILTER[j][i+1];
CHECK4=FIRSTFILTER[j+1][i+1];
CHECK5=FIRSTFILTER[j+1][i];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
if (CHECK4==TH2)
{
if (CHECK5==TH2)
EDGEIMAGE[j][i]=0;
}
}
}
}
}
}
else
{
CHECK1=FIRSTFILTER[j-1][i];
CHECK2=FIRSTFILTER[j-1][i-1];
CHECK3=FIRSTFILTER[j][i-1];
CHECK4=FIRSTFILTER[j+1][i-1];
CHECK5=FIRSTFILTER[j+1][i];
CHECK6=FIRSTFILTER[j][i-1];
CHECK7=FIRSTFILTER[j+1][i-1];
CHECK8=FIRSTFILTER[j+1][i];
if (CHECK1==TH2)
{
if (CHECK2==TH2)
{
if (CHECK3==TH2)
if (CHECK4==TH2)
if (CHECK5==TH2)
if (CHECK6==TH2)
if (CHECK7==TH2)
if (CHECK8==TH2)
EDGEIMAGE[j][i]=0;
} //1
} //2
} //3
} //4
} //5
} //6
} //7
}//8
}
}
//////////////////////////////////////
//printf("output");
for( i=0;i<64;i++)
{
for( j=0;j<64;j++)
{
printf("%d \n",EDGEIMAGE[i][j]);
for( i=0;i<64;i++)
{
for( j=0;j<64;j++)
{
if (FIRSTFILTER[i][j]==255)
{
count=count+1;
}
}
}
// printf("%d \n",count);
Chapter 8
APPLICATIONS
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 is 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). When applied to a stack of images, typical in Medical imaging, the
resulting contours after image segmentation can be used to create 3D reconstructions with the
help of interpolation algorithms like Marching cubes.
Surveillance cameras are video cameras used for the purpose of observing an area.
They are often connected to a recording device, IP network, and/or watched by a security
guard/law enforcement officer. Cameras and recording equipment used to be relatively
expensive and required human personnel to monitor camera footage. Now with cheaper
production techniques, it is simple and inexpensive enough to be used in home security
systems, and for everyday surveillance. Analysis of footage is made easier by automated
software that organizes digital video footage into a searchable database, and by automated
video analysis software (such as VIRAT and HumanID) . The amount of footage is also
drastically reduced by motion sensors which only record when motion is detected.
Medical imaging is the technique and process used to create images of the human
body (or parts and function thereof) for clinical purposes (medical procedures seeking to
reveal, diagnose or examine disease) or medical science (including the study of
normal anatomy and physiology). Although imaging of removed organs and tissues can be
performed for medical reasons, such procedures are not usually referred to as medical
imaging, but rather are a part of pathology.
The term non-invasive is a term based on the fact that following medical imaging
modalities do not penetrate the skin physically. But on the electromagnetic and radiation
level, they are quite invasive. From the high energy photons in X-Ray Computed
Tomography, to the 2+ Tesla coils of an MRI device, these modalities alter the physical and
chemical environment of the body in order to obtain data.
is the “resonance” part of MRI. The RF pulse makes them (only the one or two extra
unmatched protons per million) spin at a specific frequency, in a specific direction. The
particular frequency of resonance is called the Larmour frequency and is calculated based on
the particular tissue being imaged and the strength of the main magnetic field. MRI uses
three electromagnetic fields: a very strong (on the order of units of Teslas) static magnetic
field to polarize the hydrogen nuclei, called the static field; a weaker time-varying (on the
order of 1 kHz) field(s) for spatial encoding, called the gradient field(s); and a weak
radio (RF) field for manipulation of the hydrogen nuclei to produce measurable signals,
collected through an RF antenna.
Like CT, MRI traditionally creates a two dimensional image of a thin "slice" of the
body and is therefore considered a tomographic imaging technique. Modern MRI instruments
are capable of producing images in the form of 3D blocks, which may be considered a
generalization of the single-slice, tomographic, concept. Unlike CT, MRI does not involve
the use of ionizing radiation and is therefore not associated with the same health hazards. For
example, because MRI has only been in use since the early 1980s, there are no known long-
term effects of exposure to strong static fields (this is the subject of some debate; see 'Safety'
in MRI) and therefore there is no limit to the number of scans to which an individual can be
subjected, in contrast with X-ray and CT. However, there is well-identified health risks
associated with tissue heating from exposure to the RF field and the presence of implanted
devices in the body, such as pace makers. These risks are strictly controlled as part of the
design of the instrument and the scanning protocols used.
Since Because CT and MRI are sensitive to different tissue properties, the appearance
of the images obtained with the two techniques differ markedly. In CT, X-rays must be
blocked by some form of dense tissue to create an image, so the image quality when looking
at soft tissues will be poor. In MRI, while any nucleus with a net nuclear spin can be used, the
proton of the hydrogen atom remains the most widely used, especially in the clinical setting,
because it is so ubiquitous and returns a large signal. This nucleus, present in water
molecules, allows the excellent soft-tissue contrast achievable with MRI.
Pattern based algorithms compare the basic fingerprint patterns (arch, whorl, and
loop) between a previously stored template and a candidate fingerprint. This requires that the
images be aligned in the same orientation. To do this, the algorithm finds a central point in
the fingerprint image and centers on that. In a pattern-based algorithm, the template contains
the type, size, and orientation of patterns within the aligned fingerprint image. The candidate
fingerprint image is graphically compared with the template to determine the degree to which
they match.
As of 2006, there was little standardization in the processes used in MV. Nonetheless,
the first step in the MV process is acquisition of an image, typically using cameras, lenses,
and lighting that has been designed to provide the differentiation required by subsequent
processing. MV software packages then employ various digital image processing techniques
to allow the hardware to recognize what it is looking at.
Chapter 9
9.1 ADVANTAGES
2. Since hardware is FPGA as technology increase software part can be updated with
ease.
9.2 LIMITATIONS
Chapter 10
SCOPE
10.2 CONCLUSION
We are so happy presenting our project, colour image segmentation using FPGA
successfully. With the successful completion of our project, we were able to broaden the
horizon of our knowledge.
Chapter 11
BIBLIOGRAPHY
[1] Jun Tung “Colour Image Segmentation based on Region Growing Approach”
[Xi'an Shiyou University]
[2] Yining Deng, B. S. Manjunath and Hyundoo Shin “Colour Image Segmentation”
[University of Caloifornia]
[5] Bergmann, E.V., B.K. Walker, and B.K. Levy, The Research on Stereo Matching
Algorithm based on Region-growth. Journal of Guidance, Control, and Dynamics,
1987. 10(5): p. 483-491.
[7] Tanygin, S. image dense stereo matching by technique of region growing,. Journal
of Guidance, Control, and Dynamics, 1997.20(4): p. 625-632.
[8] Lee, A.Y. and J.A. Wertz, Harris operator is used to improve the exact position of
point feature, 2002. 39(1): p. 153-155
[9] Palimaka, J. and B.V. burlton, fast computation of matching value for binocular
stereo vision. 1992: Hilton Head Island. p. 21-26.
www.xilinx.com
www.edaboard.com
www.cs.toronto.edu
www.mathworks.com