Professional Documents
Culture Documents
CHAPTER 1
DIGITAL IMAGE PROCESSING
1.1. INTRODUCTION
Digital image processing is an area characterized by the need for extensive
experimental work to establish the viability of proposed solutions to a given problem.
An important characteristic underlying the design of image processing systems is the
significant level of testing and experimental solution. This characteristic implies that the
ability to formulate approaches and quickly prototype candidate solutions generally
plays a major role in reducing the cost and time required to arrive at a viable system
implementation.
Although strong 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 content. Image compression is familiar
(perhaps inadvertently) 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.
1. In sense, two elements are required to acquire digital images. The first is the
physical device that is sensitive to the energy radiated by the object we wish to
image. The second called a digitizer, is a device for converting the output of the
physical sensing device into digital form.
2. Specialized image processing hardware usually consists of the digitizer plus
hardware that performs other primitive operations such as arithmetic and logical
operations (ALU). E.g. Noise reduction. This type of hardware sometimes is called
a front end subsystem.
3. The computer is an image processing system is a general purpose to
supercomputer.
4. Mass storage capability is a must in image processing applications.
5. Image displays in use today are mainly color type monitors.
6. Hardcopy devices for recording images include laser printers, and film cameras.
7. Networking for communication
Edge Detection System For Noisy Images
Now the approximate absolute gradient magnitude (edge strength) at each point can be
found as
G = √𝐺2 + 𝐺2
𝑥 𝑦
and the orientation of the gradient can be found using the gradient in the x and y directions
𝐺
=tan−1 ( 𝑥 )
𝐺𝑦
Non-Maximum Suppression
This is necessary to convert the blurred edges in the image of the gradient magnitudes to
sharp edges. Actually this is performed by considering only all local maxima in the
gradient image and deleting everything rest. The algorithm is applied for each pixel in
the gradient image.
To find the edge points, we need to find the local maxima of the gradient magnitude.
Broad ridges must be thinned so that only the magnitudes at the points of greatest local
change remain.
All values along the direction of the gradient that are not peak values of a ridge are
suppressed.
Hysteresis Thresholding
After the non-maximum suppression step, the edge pixels are still marked with their
strength pixel-by-pixel.
The received image may still contain false edge points. Using threshold, Potential edges
are determined by double thresholding (High and Low).
If the gradient at a pixel is
Above “High”, declare it as an ‘edge pixel’
Below “Low”, declare it as a “non-edge-pixel”
Between “low” and “high”
Consider its neighbours iteratively then declare it an “edge pixel” if it is connected to an
‘edge pixel’ directly or via pixels between “low” and “high”
Essentially what we are trying to do here with the Sobel Operator is trying to find out
the amount of the difference by placing the gradient matrix over each pixel of our
image. We get two images as output, one for X- Direction and other for Y-Direction. By
using Kernel Convolution, we can see in the example image below there is an edge
between the column of 100 and 200 values.
Vertical Edges
Vertical direction
When we apply this mask on the image it prominent vertical edges. It simply works
like as first order derivate and calculates the difference of pixel intensities in an edge
region. As the center column is of zero so it does not include the original values of an
image but rather it calculates the difference of right and left pixel values around that
edge. This increase the edge intensity and it became enhanced comparatively to the
original image.
Table: 2.1 Vertical Direction Mask
Above mask will find the edges in vertical direction and it is because the zeros column
in the vertical direction. When you will convolve this mask on an image, it will give you
the vertical edges in an image.
Horizontal Direction
This mask will prominent the horizontal edges in an image. It also works on the
principle of above mask and calculates difference among the pixel intensities of a
particular edge. As the center row of mask is consist of zeros so it does not include the
original values of edge in the image but rather it calculate the difference of above and
below pixel intensities of the particular edge. Thus increasing the sudden change of
intensities and making the edge more visible. Both the above masks follow the principle
of derivate mask. Both masks have opposite sign in them and both masks sum equals
tozero. The third condition will not be applicable in this operator as both the above
masks are standardize and we can’t change the value in them.
Table: 2.2 Horizontal Direction Mask
-1 -1 -1
0 0 0
1 1 1
Fig: 2.7 Original Image Fig: 2.8 After Applying Prewitt operator
Once the image has been Log filtered, it only remains to detect the zero crossings.
This can be done in several ways.
The simplest is to simply threshold the Log output at zero, to produce a binary
image where the boundaries between foreground and background regions represent the
locations of zero crossing points. These boundaries can then be easily detected and
marked in single pass, e.g. using some morphological operator. For instance, to locate all
boundary points, we simply have to mark each foreground point that has at least one
background neighbour.
The problem with this technique is that will tend to bias the location of the zero
crossing edge to either the light side of the edge, or the dark side of the edge, depending
on whether it is decided to look for the edges of foreground regions or for the edges of
background regions.
A better technique is to consider points on both sides of the threshold boundary,
and choose the one with the lowest absolute magnitude of the Laplacian, which will
hopefully be closest to the zero crossing.
Since the zero crossings generally fall in between two pixels in the Log filtered
image, an alternative output representation is an image grid which is spatially shifted
half a pixel across and half a pixel down, relative to the original image. Such a
representation is known as a dual lattice. This does not actually localize the zero
crossing any more accurately, of course.
Fig: 2.10 Original Image Fig:2.11 After Applying Zero Cross Operator
A morphological operation on a binary image creates a new binary image in which the
pixel has a non-zero value only if the test is successful at that location in the input
image. The structuring element is a small binary image, i.e. a small matrix of pixels,
each with a value of zero or one:
Fig: 2.14 Greyscale image Fig: 2.15 Erosion: a 2×2 square structuring
Dilation
The dilation of an image f by a structuring element s (denoted f s) produces a
new binary image g = f s with ones in all locations (x, y) of a structuring element's
origin at which that structuring element s hits the input image f, i.e. g(x,y) = 1
if s hits f and 0 otherwise, repeating for all pixel coordinates (x,y). Dilation has the
opposite effect to erosion -- it adds a layer of pixels to both the inner and outer
boundaries of regions.
Fig: 2.16 Binary Image Fig: 2.17 Dilation: a 2×2 square structuring
(𝑥−𝜇)2
P(x) = 1 −
𝜎√2𝜋
𝑒 2𝜎2
2 −(𝑧−𝑎)2
𝜋𝑏 𝑏(4−𝜋)
P (z) (z-a)𝑒 𝑏 Mean:𝜇 = 𝑎 + √ Variance:𝜎2 =
𝑏 4 4
=
Start
Consider the
next neighbor
pixel Compute the gradient magnitude
say
IS
G>T
End
3.2 Flow chart for the Procedure of the proposed edge detection
method In this system, an edge detection method for detecting the edge of noisy and
non-noisy images is proposed. Phases are: initially RGB image divide to the three
constituent channels of R, G and B. Then we use Median filter on each channel,
applying a definite value [12]. Then attach all the channels together to achieve a new
RGB image. The aim of applying Median filter in this fashion is to achieve a kind of
special smoothing of the image, which can deal with all sort of noises. It should be
considered, applying this filter only to one channel and on the gray image would not
achieve the desired result. Selecting pixels by the Median filter is presented in fig 3.2.
Acquiring RGB image from the input
Fig: 3.2 Flow chart for the Procedure of the proposed edge detection method
In the next stage, the smoothed image becomes sharpened by the Unsharp Mask filter
[13]. Table 1 presents the filter used for edge sharpening. After edge sharpening, for
edge detection, the output image will be sent to the gray level. Next, it is the time for
applying the proposed edge detection filter, which is a 3*3 matrix. It will be applied to
the image from four sides. This filter is presented in formula 1. This filter after
smoothing and sharpening the image causes very beautiful sharp edges, and also causes
the noise not
Being seen in the output image. In order to eliminate the superfluous noises in output
binary image, a post-processing action is applying to two dimensions of the image. This
happens for eliminating the possible noises. Finally, for thinning the edges, using Hit or
Miss Morphology system, the final output is achieved. This system is implemented by
Mat lab. The flowchart of the proposed system is presented in Figure 3.2.
For validating the acquired result, we use the PSNR and SSIM factors. The value of
PSNR factor should be usually “between” 5 to 50. The more this value is, the better, and
the high similarity of the input image with reference can be estimated by a number like
50. The next factor is SSIM which is a number between 0 and 1. The higher this value
is, the better result exist. The best result is something “between” 0.9 to 1.
CHAPTER 4
SOFTWARE DESCRIPTION
4.1 INTRODUCTION
The tutorials are independent of the rest of the document. The primarily objective is to
help you learn quickly the first steps. The emphasis here is “learning by doing”.
Therefore, the best way to learn is by trying it yourself. Working through the examples
will give you a feel for the way that MATLAB operates. [20] In this introduction we will
describe how MATLAB handles simple numerical expressions and mathematical
formulas.
MATLAB has many advantages compared to conventional computer languages
(e.g., C, FORTRAN) for solving technical problems. MATLAB is an interactive system
whose basic data element is an array that does not require dimensioning. The software
package has been commercially available since1984 and is now considered as a standard
tool almost universities and industries worldwide. [20]
It has powerful built-in routines that enable a very wide variety of computations. It
also has easy to use graphics commands that make the visualization of results
immediately available. Specific applications are collected in packages referred to as
toolbox. There are toolboxes for signal processing, symbolic [20] computation, control
theory, simulation, optimization, and several other fields of applied science and
engineering.
4.2 BASIC FEATURES
As we mentioned earlier, the following TUTORIAL lessons are designed to get you started
quickly in MATLAB. The lessons are intended to make you familiar with the basics of
MATLAB.
4.3 A MINIMUM MATLAB SESSION
The goal of this minimum session (also called starting and exiting sessions) is to learn
the first steps:
1. How to logon
2. Invoke MATLAB
3. Do a few simple calculations
4. How to quit MATLAB
4.3.1 Starting Mat lab
After logging into your account, you can enter MATLAB by double-clicking on the
MATLAB shortcut icon (MATLAB 7.0.4) on your Windows desktop. When you start
MATLAB, a special window called the MATLAB desktop appears. The desktop is a
window that contains other windows. [20] The major tools within or accessible from
the desktop are:
• The Command Window
• The Command History
• The Workspace
• The Current Directory
• The Help Browser
• The Start Button
4.5 FEATURES
Following are the basic features of MATLAB:
It is a high-level language for numerical computation, visualization and
application development.
It also provides an interactive environment for iterative exploration, design and
problem solving.
It provides vast library of mathematical functions for linear algebra, statistics,
Fourier analysis, filtering, optimization, numerical integration and solving
ordinary differential equations.
It provides built-in graphics for visualizing data and tools for creating custom
plots.
MATLAB's programming interface gives development tools for improving code
quality, maintainability, and maximizing performance.
It provides tools for building applications with custom graphical interfaces.
It provides functions for integrating MATLAB based algorithms with external
applications and languages such as C, Java, .NET and Microsoft Excel.
4.6 USES OF MATLAB
MATLAB is widely used as a computational tool in science and engineering
encompassing the fields of physics, chemistry, math and all engineering streams.
It is used in a range of applications including: [20]
signal processing and Communications
image and video Processing
control systems
test and measurement
computational finance
computational biology
4.7 IMAGE PROCESSING TOOL BOX
The Image Processing Toolbox is a collection of functions that extend the capabilities of
the MATLAB’s numeric computing environment. [20] The toolbox supports wide range
of image processing operations, including:
• Geometric operations
• Neighborhood and block operations
• Linear filtering and filter design
• Transforms
• Image analysis and enhancement
• Binary image operations
• Region of interest operations
TABLES
Table 4.1: Image to Display
IMAGE DISPLAY
Image Create and display image object
Images Scale and display as image
I’m show Display image
Color bar Display color bar
Get image Get image data from axes
True size Adjust display size of image
Zoom Zoom in and zoom out of 2D plot
Image Conversion
gray2ind Intensity image to index image
im2bw Image to binary
im2double Image to double precision
im2uint8 Image to 8-bit unsigned integers
im2uint16 Image to 16-bit unsigned integers
ind2gray Indexed image to intensity image
mat2gray Matrix to intensity image
rgb2gray RGB image to grayscale
rgb2ind Rgb image to indexed image
4.8 IMAGE OPERATIONS
• RGB image to gray image
• Image resize
• Image crop
• Image rotate
• Image histogram
• Image histogram equalization
• Image DCT/IDCT
• Convolution
4.9 IMREAD
SYNTAX
A = imread(filename)
A = imread(filename,fmt)
A = imread( ,idx)
A = imread( ,Name,Value)
[A,map] = imread( )
[A,map,transparency] = imread( )
A = imread(filename) reads the image from the file specified by filename, inferring the
format of the file from its contents. If filename is a multi-image file, then imread reads
the first image in the file.
A = imread(filename,fmt) additionally specifies the format of the file with the standard
file extension indicated by fmt. If imread cannot find a file with the name specified
by filename, it looks for a file named filename.fmt.
A = imread( ,idx) reads the specified image or images from a multi-image file. This
syntax applies only to GIF, CUR, ICO, TIF, and HDF4 files. You must specify
a filename input, and you can optionally specify fmt.
A = imread( ,Name,Value) specifies format-specific options using one or more name-
value pair arguments, in addition to any of the input arguments in the previous syntaxes.
[A,map] = imread( ) reads the indexed image in filename into A and reads its
associated colormap into map. Colormap values in the image file are automatically
rescaled into the range [0,1].
[A,map,transparency] = imread( ) additionally returns the image transparency. This
syntax applies only to PNG, CUR, and ICO files. For PNG files, transparency is the
alpha channel, if one is present. For CUR and ICO files, it is the AND (opacity) mask
4.10 IMSHOW
SYNTAX
imshow(I) imshow(I,
[low high])
imshow(I,[])
imshow(RGB)
imshow(BW)
imshow(X,map)
imshow(filename)
imshow( ,Name,Value)
himage = imshow( )
Description
imshow(I) displays the grayscale image I in a figure. imshow uses the default display
range for the image data type and optimizes figure, axes, and image object properties for
image display.
imshow(I,[low high]) displays the grayscale image I, specifying the display range as a
two-element vector, [low high]. For more information, see the Display Range
parameter.
imshow(I,[]) displays the grayscale image I, scaling the display based on the range of
pixel values in I. imshow uses [min(I(:)) max(I(:))] as the display range. imshow
displays the minimum value in I as black and the maximum value as white. For more
information, see the DisplayRange parameter.
imshow(RGB) displays the truecolor image RGB in a figure.
imshow(BW) displays the binary image BW in a figure. For binary
images, imshow displays pixels with the value 0 (zero) as black and 1 as white.
imshow(X,map) displays the indexed image X with the Colour map. A colour map
matrix can have any number of rows, but it must have exactly 3 columns. Each row is
interpreted as a colour, with the first element specifying the intensity of red, the second
green, and the third blue. Colour intensity can be specified on the interval [0, 1].
imshow(filename) displays the image stored in the graphics file specified by filename.
imshow( ,Name,Value) displays an image, using name-value pairs to control aspects
of the operation.
himage = imshow( ) returns the image object created by imshow.
4.11 IMHIST
SYNTAX
[counts,binLocations] = imhist(I)
[counts,binLocations] = imhist(I,n)
[counts,binLocations] = imhist(X,map)
imhist( )
Description
[counts,binLocations] = imhist(I) calculates the histogram for the grayscale image I.
The imhist function returns the histogram counts in counts and the bin locations
in bilocation. The number of bins in the histogram is determined by the image type.
You optionally can compute the histogram counts and bin locations using a GPU
(requires Parallel Computing Toolbox™). For more information, see Image Processing
on a GPU.
[counts,binLocations] = imhist(I,n) specifies the number of bins, n, used to calculate the
histogram.
[counts,binLocations] = imhist(X,map) calculates the histogram for the indexed
image X with colormap map. The histogram has one bin for each entry in the colour
map.
This syntax is not supported on a GPU.
imhist( ) displays a plot of the histogram. If the input image is an indexed image, then
the histogram shows the distribution of pixel values above a colour bar of the colour
map.
If you use this syntax when I is a gpu Array, then no plot is displayed. imhist returns the
histogram counts in and does not return the histogram bin locations.
4.12 RGB2GRAY
SYNTAX
I = rgb2gray(RGB)
newmap = rgb2gray(map)
Description
I = rgb2gray (RGB) converts the true color image RGB to the grayscale image I.
The rgb2gray function converts RGB images to grayscale by eliminating the hue and
saturation information while retaining the luminance. If you have Parallel Computing
Toolbox™ installed, rgb2gray can perform this conversion on a GPU
4.13 BWCONNCO MP ()
SYNTAX
CC = bwconncomp(BW)
CC = bwconncomp(BW,conn)
Description
CC = bwconncomp(BW) returns the connected components CC found in the binary
image BW. bwconncomp uses a default connectivity of 8 for two dimensions, 26 for
three dimensions, and conndef(ndims(BW),'maximal') for higher dimensions
4.14 RGB2HSV
SYNTAX
HSV = rgb2hsv (RGB)
hsvmap = rgb2hsv(rgbmap)
Description
HSV = rgb2hsv (RGB) converts the red, green, and blue values of an RGB image to hue,
saturation, and value (HSV) values of an HSV image.
Fig: 5.1Horizontal and Vertical edges Fig: 5.2 Median Filter Edges
Fig: 5.3 RGB Smooth medfilt2 Fig: 5.4 Gray scale smooth
The original image without adding any noise is shown in fig 5.1 with vertical and
horizontal edges. Initially RGB image is divided into three constituent channels R, G, B.
Then the median filter is applied to the image which is shown figure 5.3 for sharping of
the image. The edges after applying the median filter is shown in fig 5.2. Then the RGB
image is converted into gray scale image for smoothing shown in fig 5.4.
AFTER APPLYING GAUSSIAN NOISE
Fig: 5.6 Edges Gaussian Fig: 5.7 RGB Smooth medfilt2 and
Gaussian noise
Fig: 5.8 Gray scale smooth & Fig: 5.9 Gray scale smooth with
Gaussian Noise wiener2&Gaussian noise
The original image without adding any noise is shown in fig 5.5 with vertical and
horizontal edges. Then the Gaussian noise is applied to the original image then the
edges are detected for Gaussian noise which is shown in fig 5.6. This RGB image is
applied to the median filter along with Gaussian noise for sharping the edges shown in
fig 5.7. Then the RGB image is converted into gray scale for smoothing the image
shown in fig 5.8. The gray scale image is applied with the wiener filter and Gaussian
noise shown in fig 5.9.
APPLYING SALT AND PEPPER NOISE
Fig: 5.11 Edges Salt Pepper Fig: 5.12 RGB Smooth medfilt2&Salt
Pepper noise
Fig: 5.13 Gray scale smooth &salt Fig: 5.14Gray scale smooth with
wiener2&Salt Pepper noise pepper noise
The original image without adding any noise is shown in fig 5.10 with vertical and
horizontal edges. Then the salt and pepper noise is applied to the original image then the
edges are detected for salt and pepper noise which is shown in fig 5.11. This RGB
image is applied to the median filter along with salt and pepper noise for sharping the
edges shown in fig 5.12. Then the RGB image is converted into gray scale for
smoothing the image shown in fig 5.13. The gray scale image is applied with the wiener
filter and salt and pepper noise shown in fig 5.14.
APPLYING RAYLEIGH NOISE
Fig: 5.18 Gray scale smooth & Fig: 5.19Gray scale smooth with wiener2&
Rayleigh Noise Rayleigh Noise
APPLYING GAMMA NOISE
The original image without adding any noise is shown in fig 5.20 with vertical and
horizontal edges. Then the Gamma noise is applied to the original image then the edges
are detected for Gamma noise which is shown in fig 5.21. This RGB image is applied to
the median filter along with Gamma noise for sharping the edges shown in fig 5.22.
Then the RGB image is converted into gray scale for smoothing the image shown in fig
5.23. The gray scale image is applied with the wiener filter and Gamma noise shown in
fig 5.24.
PSNR VALIDATIONS FOR VARIOUS NOISES
Table: 5.2 PSNR Validations
Gaussian 13.2352
Rayleigh 23.5873
Gamma 13.9062
Edge Detection System For Noisy Images
Gaussian 0.3226
Rayleigh 0.8808
Gamma 0.4527
CHAPTER 6
CONCLUSION AND FUTURE SCOPE
CONCLUSION:
The proposed system is not only a new edge detection approach, but is able
to deal with different noises in digital images, and indicate the least of sensitivity. This
happens in a condition in which, conventional edge detection methods, have a lot of
sensitivity to different kind of noises.
This system does not change the real position of the edges, which causes to use it in
applied cases with the peace of mind. This system possesses the best results, in validated
visual and statistical results against other conventional edge detection methods, in the
same situation. With changing the proposed system, we are able to create a sort of
image feature extraction method (this is of future works)
FUTURE SCOPE:
This method gives the fine details of an edge which helps the doctor to make sure the
state of illness development and confirm how to cure it. Furthermore the computational
time for edge detection is much smaller when compared to the other traditional
techniques. The work can be extended to text image, satellite image, video frames, etc.
In future work parallelizing an edge detection algorithms, provides better performance
results for image-processing applications.
REFERENCES