Professional Documents
Culture Documents
Image Processing
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.
Image processing usually refers to digital image processing,
but optical and analog image processing also are possible. The acquisition of
images (producing the input image in the first place) is referred to as imaging.
1
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Image segmentation
High dynamic range imaging by combining multiple images
Geometric hashing for 2-D object recognition with affine invariance
Applications of image processing
Further information: Imaging
Computer vision
Optical sorting
Augmented Reality
Face detection
Feature detection
Lane departure warning system
Non-photorealistic rendering
Medical image processing
Microscope image processing
Morphological image processing
Remote sensing
2
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Tasks of DIP
Digital image processing allows the use of much more complex algorithms for
image processing, and hence, can offer both more sophisticated performance at
simple tasks, and the implementation of methods which would be impossible by
analog means.
In particular, digital image processing is the only practical technology for:
Classification
Feature extraction
Pattern recognition
Projection
Multi-scale signal analysis
Some techniques which are used in digital image processing include:
Pixelization
Linear filtering
Principal components analysis
Independent component analysis
Hidden Markov models
Partial differential equations
Self-organizing maps
Neural networks
Wavelets
What is a Maze
A maze is a tour puzzle in the form of a complex branching passage through
which the solver must find a route. In everyday speech, both maze and labyrinth
denote a complex and confusing series of pathways, but technically the maze is
distinguished from the labyrinth, as the labyrinth has a single through-route with
twists and turns but without branches, and is not designed to be as difficult to
3
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Maze construction
Mazes have been built with walls and rooms, with hedges, turf, corn stalks, hay
bales, books, paving stones of contrasting colors or designs, bricks and turf,[3] or
in fields of crops such as corn or, indeed, maize. Maize mazes can be very large;
they are usually only kept for one growing season, so they can be different
every year, and are promoted as seasonal tourist attractions. Indoors, Mirror
Mazes are another form of maze, where many of the apparent pathways are
imaginary routes seen through multiple reflections in mirrors. Another type of
maze consists of a set of rooms linked by doors (so a passageway is just another
room in this definition). Players enter at one spot, and exit at another, or the idea
may be to reach a certain spot in the maze. Mazes can also be printed or drawn
on paper to be followed by a pencil or fingertip.
FIGURE-1
Generating mazes
Maze generation is the act of designing the layout of passages and walls within
a maze. There are many different approaches to generating mazes, where
various maze generation algorithms exist for building them, either by hand or
automatically by computer.
4
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
There are two main mechanisms used to generate mazes. "Carving passages" is
where one marks out the network of available routes. "Adding walls" is where
one lays out a set of obstructions within an open area. Most mazes drawn on
paper are where one draws the walls, where the spaces in between the markings
compose the passages.
Solving mazes
Maze solving is the act of finding a route through the maze from the start to
finish. Some maze solving methods are designed to be used inside the maze by
a traveler with no prior knowledge of the maze, whereas others are designed to
be used by a person or computer program that can see the whole maze at once.
The mathematician Leonhard Euler was one of the first to analyze plane mazes
mathematically, and in doing so made the first significant contributions to the
branch of mathematics known as topology.
Mazes containing no loops are known as "standard", or "perfect" mazes, and are
equivalent to a tree in graph theory. Thus many maze solving algorithms are
closely related to graph theory. Intuitively, if one pulled and stretched out the
paths in the maze in the proper way, the result could be made to resemble a tree.
5
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
6
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Gray Image
In photography and computing, a grayscale or greyscale digital image is an
image in which the value of each pixel is a single sample, that is, it carries
only intensity information. Images of this sort, also known as black-and-white,
are composed exclusively of shades of gray, varying from black at the weakest
intensity to white at the strongest.[1]
Grayscale images are distinct from one-bit black-and-white images, which in
the context of computer imaging are images with only the two colors,black,
and white (also called bilevel or binary images). Grayscale images have many
shades of gray in between. Grayscale images are also called monochromatic,
denoting the absence of any chromatic variation.
Grayscale images are often the result of measuring the intensity of light at each
pixel in a single band of the electromagnetic spectrum (e.g. infrared,visible
light, ultraviolet, etc.), and in such cases they are monochromatic proper when
only a given frequency is captured. But also they can be synthesized from a full
color image.
7
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Numerical representations
The intensity of a pixel is expressed within a given range between a minimum
and a maximum, inclusive. This range is represented in an abstract way as a
range from 0 (total absence, black) and 1 (total presence, white), with any
fractional values in between. This notation is used in academic papers, but it
must be noted that this does not define what "black" or "white" is in terms
of colorimetry.
Another convention is to employ percentages, so the scale is then from 0% to
100%. This is used for a more intuitive approach, but if onlyinteger values are
used, the range encompasses a total of only 101 intensities, which are
insufficient to represent a broad gradient of grays. Also, the percentile notation
is used in printing to denote how much ink is employed in halftoning, but then
the scale is reversed, being 0% the paper white (no ink) and 100% a solid black
(full ink).
In computing, although the grayscale can be computed through rational
numbers, image pixels are stored in binary, quantized form. Some early
grayscale monitors can only show up to sixteen (4-bit) different shades, but
today grayscale images (as photographs) intended for visual display (both on
screen and printed) are commonly stored with 8 bits per sampled pixel, which
allows 256 different intensities (i.e., shades of gray) to be recorded, typically on
a non-linear scale. The precision provided by this format is barely sufficient to
8
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
avoid visible banding artifacts, but very convenient for programming due to the
fact that a single pixel then occupies a single byte.
Technical uses (e.g. in medical imaging or remote sensing applications) often
require more levels, to make full use of the sensor accuracy (typically 10 or 12
bits per sample) and to guard against roundoff errors in computations. Sixteen
bits per sample (65,536 levels) is a convenient choice for such uses, as
computers manage 16-bit words efficiently. The TIFF and the PNG (among
other) image file formats supports 16-bit grayscale natively, although browsers
and many imaging programs tend to ignore the low order 8 bits of each pixel.
No matter what pixel depth is used, the binary representations assume that 0 is
black and the maximum value (255 at 8 bpp, 65,535 at 16 bpp, etc.) is white, if
not otherwise noted.
Binary Image
A binary image is a digital image that has only two possible values for
each pixel. Typically the two colors used for a binary image are black and white
though any two colors can be used. The color used for the object(s) in the image
is the foreground color while the rest of the image is the background color.
Binary images are also called bi-level or two-level. This means that each pixel is
stored as a single bit (‘0’or‘1’). The names black and
white, B&W,monochrome or monochromatic are often used for this concept,
but may also designate any images that have only one sample per pixel, such
asgrayscale images. In Photoshop parlance, a binary image is the same as an
image in "Bitmap" mode.
Binary images often arise in digital image processing as masks or as the result
of certain operations such as segmentation, thresholding, and dithering. Some
input/output devices, such as laser printers, fax machines, and bilevel computer
displays, can only handle bilevel images. A binary image is usually stored in
memory as a bitmap, a packed array of bits. A 640×480 image requires
9
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
10
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
FIGURE4
Reflected Structuring Elements
Z (ρ ,χ ) = Z (−ρ ,−χ ) for all (ρ ,χ )∈ S
Let Z be a SE and let S be the square of pixel locations
that contains the set {(r,c), (−r,−c) | (r,c)∈supp(Z)}. Thenis the reflected
structuring element. Z is Z rotated by 180º around its origin.
Example for reflected S.E.
FIGURE-5
11
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Erosion
Erosion is one of two fundamental operations (the other being dilation)
in Morphological image processing from which all other morphological
operations are based. It was originally defined for binary images, later being
extended to grayscale images, and subsequently to complete lattices.
FIGURE-6;The erosion of the dark-blue square by a disk, resulting in the light-blue square.
Binary erosion
In binary morphology, an image is viewed as a subset of an Euclidean space
or the integer grid , for some dimension d.
12
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
The basic idea in binary morphology is to probe an image with a simple, pre-
defined shape, drawing conclusions on how this shape fits or misses the shapes
in the image. This simple "probe" is called structuring element, and is itself a
binary image (i.e., a subset of the space or grid).
Let E be an Euclidean space or an integer grid, and A a binary image in E.
The erosion of the binary image A by the structuring element B is defined by:
Example
Suppose A is a 13 * 13 matrix and B is a 5 * 1 matrix:
0000000000000
0000000000000
0000000000000
0000000000000
0001111111000 1
0001111111000 1
0001111111000 1
0001111111000 1
0001111111000 1
0000000000000
0000000000000
0000000000000
0000000000000
13
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Assuming that the origin B is at its center, for each pixel in A superimpose the
origin of B, if B is completely contained by A the pixel is retained, else deleted.
The Erosion of A by B is given by
0000000000000
0000000000000
0000000000000
0000000000000
0000000000000
0000000000000
0001111111000
0000000000000
0000000000000
0000000000000
0000000000000
0000000000000
0000000000000
This means that only when B is completely contained inside A that the pixels
values are retained, else it gets deleted or in other words it gets eroded.
Properties
The erosion is translation invariant.
It is increasing, that is, if , then .
If the origin of E belongs to the structuring element B, then the erosion
is anti-extensive, i.e., .
The erosion satisfies , where denotes
the morphological dilation.
The erosion is distributive over set intersection
Grayscale erosion
In gray scale morphology, images are functions mapping an Euclidean
space or grid E into , where is the set of reals, is an
14
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
element larger than any real number, and is an element smaller than
any real number.
Denoting an image by f(x) and the gray scale structuring element by b(x),
the gray scale erosion of f by b is given by
,
.
Dilation
Dilation is one of the basic operations in mathematical morphology.
Originally developed for binary images, it has been expanded first
to grayscale images, and then to complete lattices. The dilation operation
usually uses a structuring element for probing and expanding the shapes
contained in the input image.
15
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Binary Dilation
In binary morphology, dilation is a shift-invariant (translation invariant)
operator, strongly related to the Minkowski addition.
A binary image is viewed in mathematical morphology as a subset of
an Euclidean space Rd or the integer grid Zd, for some dimension d.
LetE be a Euclidean space or an integer grid, A a binary image in E,
and B a structuring element.
The dilation of A by B is defined by:
.
The dilation is commutative, also given by
: .
If B has a center on the origin, then the dilation of A by B can be
understood as the locus of the points covered by B when the center
of Bmoves inside A. The dilation of a square of side 10, centered at the
origin, by a disk of radius 2, also centered at the origin, is a square of side
12, with rounded corners, centered at the origin. The radius of the
rounded corners is 2.
16
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Grayscale dilation
In grayscale morphology,images are functions mapping an Euclidean
space or grid E into , where is the set of reals, is an
element larger than any real number, and is an element smaller than
any real number.
Grayscale structuring elements are also functions of the same format,
called "structuring functions".
Denoting an image by f(x) and the structuring function by b(x), the
grayscale dilation of f by b is given by
,
where "sup" denotes the supremum.
17
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
,
where .
In this case, the dilation is greatly simplified, and given by
,
.
18
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Thresholding of an image
Thresholding is the simplest method of image segmentation. From
a grayscale image, thresholding can be used to create binary images.
Methods
During the thresholding process, individual pixels in an image are marked as
“object” pixels if their value is greater than some threshold value (assuming an
object to be brighter than the background) and as “background” pixels
otherwise. This convention is known asthreshold above. Variants
include threshold below, which is opposite of threshold above; threshold inside,
where a pixel is labeled "object" if its value is between two thresholds;
and threshold outside, which is the opposite of threshold inside (Shapiro, et al.
2001:83). Typically, an object pixel is given a value of “1” while a background
pixel is given a value of “0.” Finally, a binary image is created by coloring each
pixel white or black, depending on a pixel's label's.
Threshold selection
The key parameter in the thresholding process is the choice of the threshold
value (or values, as mentioned earlier). Several different methods for choosing a
threshold exist; users can manually choose a threshold value, or a thresholding
19
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
20
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
5. Go back to step two, now using the new threshold computed in step four,
keep repeating until the new threshold matches the one before it (i.e. until
convergence has been reached).
This iterative algorithm is a special one-dimensional case of the k-means
clustering algorithm, which has been proven to converge at a local minimum—
meaning that a different initial threshold may give a different final result.
Adaptive thresholding
Thresholding is called adaptive thresholding when a different threshold is
used for different regions in the image. This may also be known
as local or dynamic thresholding (Shapiro, et al. 2001:89).
21
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
local methods adapt the threshold value on each pixel to the local image
characteristics."
Multiband thresholding
Colour images can also be thresholded. One approach is to designate a separate
threshold for each of the RGB components of the image and then combine them
with an AND operation. This reflects the way the camera works and how the
data is stored in the computer, but it does not correspond to the way that people
recognize colour. Therefore, the HSL and HSVcolour models are more often
used. An interesting new method uses the CMYK colour model to threshold
colour images (Pham et al., 2007).
In histology images the colour is given by 2 or more dyes, for
example hematoxylin and DAB. The contributions of these two dyes to the
colour image can be established by using colour deconvolution. The incident
light is measured by looking at an unstained part of the slide. Then you measure
the relative absorption of each the 3 RGB components of the image by each
dye. Absorption is defined by Beer's Law. The absorption characteristics for
each dye can be obtained by measuring the RGB components of the colour in
areas of the slide that are only coloured by one dye. The computer software can
solve 3 linear equations for each pixel in the image, one for each colour
channel, in order to resolve the amounts of each of the dyes at each locus in the
image. This method can resolve up to 3 different dyes. The result is an image
for each dye, showing the amount of that dye throughout the image. This allows
the amount of dye to be quantified, which is important for image analysis
of immunohistochemical stains.
Image Histograms
An image histogram is a type of histogram which acts as a graphical
representation of the tonal distribution in a digital image.[1] It plots the number
22
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
of pixels for each tonal value. By looking at the histogram for a specific image a
viewer will be able to judge the entire tonal distribution at a glance.
Image histograms are present on many modern digital cameras. Photographers
can use them as an aid to show the distribution of tones captured, and whether
image detail has been lost to blown-out highlights or blacked-out shadows.[2]
The horizontal axis of the graph represents the tonal variations, while
the vertical axis represents the number of pixels in that particular tone.[1] The
left side of the horizontal axis represents the black and dark areas, the middle
represents medium grey and the right hand side represents light and pure white
areas. The vertical axis represents the size of the area that is captured in each
one of these zones. Thus, the histogram for a very bright image with few dark
areas and/or shadows will have most of its data points on the right side and
center of the graph. Conversely, the histogram for a very dark image will have
the majority of its data points on the left side and center of the graph.
23
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
editor allow the user to visually adjust the brightness value of each pixel and to
dynamically display the results as adjustments are made.[3] Improvements in
picture brightness and contrast can thus be obtained.
In the field of Computer Vision, image histograms can be useful tools
for thresholding. Because the information contained in the graph is a
representation of pixel distribution as a function of tonal variation, image
histograms can be analyzed for peaks and/or valleys which can then be used to
determine a threshold value. This threshold value can then be used for edge
detection, image segmentation, and co-occurrence matrices.
24
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
How it works
Connected component labeling works by scanning an image, pixel-by-pixel
(from top to bottom and left to right) in order to identify connected pixel
regions, i.e. regions of adjacent pixels which share the same set of intensity
values V. (For a binary image V={1}; however, in a graylevel image V will take
on a range of values, for example: V={51, 52, 53, ..., 77, 78, 79, 80}.)
Connected component labeling works on binary or graylevel images and
different measures of connectivity are possible. However, for the following we
assume binary input images and 8-connectivity. The connected components
labeling operator scans the image by moving along a row until it comes to a
point p (where p denotes the pixel to be labeled at any stage in the scanning
process) for which V={1}. When this is true, it examines the four neighbors
of p which have already been encountered in the scan (i.e. the neighbors (i) to
the left of p, (ii) above it, and (iii and iv) the two upper diagonal terms). Based
on this information, the labeling of p occurs as follows:
If all four neighbors are 0, assign a new label to p, else
if only one neighbor has V={1}, assign its label to p, else
if more than one of the neighbors have V={1}, assign one of the labels
to p and make a note of the equivalences.
25
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
After completing the scan, the equivalent label pairs are sorted into equivalence
classes and a unique label is assigned to each class. As a final step, a second
scan is made through the image, during which each label is replaced by the label
assigned to its equivalence classes. For display, the labels might be different
graylevels or colors.
After scanning this image and labeling the distinct pixels classes with a different
grayvalue, we obtain the labeled output image
Note that this image was scaled, since the initial grayvalues (1 - 8) would all
appear black on the screen. However, the pixels initially assigned to the lower
classes (1 and 2) are still indiscernible from the background. If we assign a
distinct color to each graylevel we obtain
26
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
we first have to threshold the image in order to produce a binary input image
(the implementation being used only takes binary images). Setting all values
above a value of 150 to zero yields
The white dots correspond to the black, dead cells in the original image. The
connected components of this binary image can be seen in
27
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
be distinguished by the human eye. Two possible ways to assign the colors are
as follows:
We only use a few colors (e.g. 8) which are clearly different from each
other and assign each graylevel of the connected component image to one
of these colors. The result can be seen in
We can now easily distinguish two different components, provided that they
were not assign the same color. However, we lose a lot of information because
the (in this case) 163 graylevels are reduced to 8 different colors.
We can assign a different color to each grayvalue, many of them being
quite similar. A typical result for the above image would be
Although, we sometimes cannot tell the border between two components when
they are very close to each other, we do not lose any information.
More sophisticated techniques combine both methods. They make sure that two
nearby components always have distinct colors by taking into account the colors
of the neighbors of the component which is going to be assigned a color.
If we compare the above color-labeled images with the original, we can see that
the number of components is quite close to the number of dead cells in the
image. However, we obtain a small difference since some cells merge together
into one component or dead cells are suppressed by the threshold.
Example2:
We encounter greater problems when trying to count the number of turkeys in
28
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
yields
as a graylevel or
29
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
where the multi-spectral image was classified into two groups. If we now apply
connected components labeling, connected geographic regions which belong to
the same intensity classes can be labeled. The result contains 49 different
components, most of them being only a few pixels large. The color labeled
version can be seen in
One could now use this image to further investigate the regions, e.g. if some
components changed their size compared to a reference image or if other
regions merged together.
30
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
detect and measure features, analyze shapes and textures, and adjust the color
balance of images.
Key Features
Image enhancement, filtering, and deblurring
Image analysis, including segmentation, morphology, feature extraction,
and measurement
Spatial transformations and image registration
Image transforms, including FFT, DCT, Radon, and fan-beam projection
Workflows for processing, displaying, and navigating arbitrarily large
images
Modular interactive tools, including ROI selections, histograms, and
distance measurements
ICC color management
Multidimensional image processing
Image-sequence and video display
DICOM import and export
31
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
32
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Reconstruction
Distance transform
Image Processing Toolbox also contains advanced image analysis functions that
lets us:
Measure the properties of a specified image region, such as the area,
center of mass, and bounding box
Detect lines and extract line segments from an image using the Hough
transform
Measure properties, such as surface roughness or color variation, using
texture analysis functions
DIP functions of MATLAB used in the simulation code for solving the
maze
imread
Read image from graphics file
Syntax
A=imread(filename,fmt)
[X,map]=imread(...)…….reads the indexed image in filename into X and its
associated colormap into map. Colormap values in the image file are
automatically rescaled into the range [0,1].
[...]=imread(filename)….. attempts to infer the format of the file from its
content
[...]=imread(URL,...)…… reads the image from an Internet URL. The URL
must include the protocol type (e.g., http://).
[...] = imread(...,Param1,Val1,Param2,Val2...) ………..specifies parameters that
control various characteristics of the operations for specific formats.
33
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Description
A = imread(filename, fmt) reads a grayscale or color image from the file
specified by the string filename. If the file is not in the current folder, or in a
folder on the MATLAB path, specify the full pathname.
The text string fmt specifies the format of the file by its standard file extension.
For example, specify 'gif' for Graphics Interchange Format files. To see a list of
supported formats, with their file extensions, use the imformats function. If
imread cannot find a file named filename, it looks for a file named filename.fmt.
The return value A is an array containing the image data. If the file contains a
grayscale image, A is an M-by-N array. If the file contains a truecolor image, A
is an M-by-N-by-3 array. For TIFF files containing color images that use the
CMYK color space, A is an M-by-N-by-4 array. The class of A depends on the
bits-per-sample of the image data, rounded to the next byte boundary.
imshow
imshow is a function used to Display the image.
Syntax
imshow(I)
imshow(I,[low,high])
imshow(RGB)
imshow(BW)
imshow(X,map)
imshow(filename)
himage=imshow(...)
imshow(..., param1, val1, param2, val2,...)
Description
imshow(I) displays the grayscale image I.
34
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Set
Set Handle Graphics object properties
35
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Syntax
set(H,'PropertyName',PropertyValue,...)
set(H,a)
set(H,pn,pv,...)
set(H,pn,MxN_pv)
a=set(h)
pv = set(h,'PropertyName')
Description
set(H,'PropertyName',PropertyValue,...) sets the named properties to
the specified values on the object(s) identified by H. H can be a vector of
handles, in which case set sets the properties' values for all the objects.
set(H,a) sets the named properties to the specified values on the object(s)
identified by H. a is a structure array whose field names are the object
property names and whose field values are the values of the
corresponding properties.
set(H,pn,pv,...) sets the named properties specified in the cell array pn to
the corresponding value in the cell array pv for all objects identified in H.
set(H,pn,MxN_pv) sets n property values on each of m graphics objects,
where m = length(H) and n is equal to the number of property names
contained in the cell array pn. This allows you to set a given group of
properties to different values on each object.
a = set(h) returns the user-settable properties and possible values for the
object identified by h. a is a structure array whose field names are the
object's property names and whose field values are the possible values of
the corresponding properties. If you do not specify an output argument,
the MATLAB software displays the information on the screen. h must be
scalar.
36
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
uint8
Stored integer value of fi object as built-in uint8.uint8 converts data to
unsigned 8 bit integer.
Syntax
c = uint8(a);
Description
Fixed-point numbers can be represented as
Real-world value = (slope X stored integer)+bias;
The stored integer is the raw binary number, in which the binary point is
assumed to be at the far right of the word.
c = uint8(a) returns the stored integer value of fi object a as a built-in
uint8. If the stored integer word length is too big for a uint8, or if the
stored integer is signed, the returned value saturates to a uint8.
label2rgb
Convert label matrix into RGB image
Syntax
RGB = label2rgb(L)
RGB = label2rgb(L, map)
RGB = label2rgb(L, map, zerocolor)
RGB = label2rgb(L, map, zerocolor, order)
37
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Description
RGB = label2rgb(L) converts a label matrix, L, such as those returned
by labelmatrix, bwlabel, bwlabeln, or watershed, into an RGB color
image for the purpose of visualizing the labeled regions. The label2rgb
function determines the color to assign to each object based on the
number of objects in the label matrix and range of colors in the colormap.
The label2rgb function picks colors from the entire range.
RGB = label2rgb(L, map) defines the colormap map to be used in the
RGB image. map can have any of the following values:
n-by-3 colormap matrix
String containing the name of a MATLAB colormap function, such as
'jet' or 'gray' (See colormap for a list of supported colormaps.)
Function handle of a colormap function, such as @jet or @gray
If you do not specify map, the default value is 'jet'.
RGB = label2rgb(L, map, zerocolor) defines the RGB color of the
elements labeled 0 (zero) in the input label matrix L. As the value of
zerocolor, specify an RGB triple.
bwlabel
Label connected components in 2-D binary image
Syntax
L = bwlabel(BW, n)
[L, num] = bwlabel(BW, n)
Description
38
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
imdilate
imdilate is a function that is used to Dilate the image
Syntax
IM2 = imdilate(IM,SE)
IM2 = imdilate(IM,NHOOD)
IM2 = imdilate(IM,SE,PACKOPT)
IM2 = imdilate(...,SHAPE)
Description
IM2 = imdilate(IM,SE) dilates the grayscale, binary, or packed binary
image IM, returning the dilated image, IM2. The argument SE is a
structuring element object, or array of structuring element objects,
returned by the strel function.
If IM is logical and the structuring element is flat, imdilate performs
binary dilation; otherwise, it performs grayscale dilation. If SE is an array
of structuring element objects, imdilate performs multiple dilations of the
input image, using each structuring element in SE in succession.
IM2 = imdilate(IM,NHOOD) dilates the image IM, where NHOOD is a
matrix of 0's and 1's that specifies the structuring element neighborhood.
39
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
imfill
Fill image regions and holes
Syntax
BW2 = imfill(BW)
[BW2,locations] = imfill(BW)
BW2 = imfill(BW,locations)
BW2 = imfill(BW,'holes')
I2 = imfill(I)
BW2 = imfill(BW,locations,conn)
Description
BW2 = imfill(BW) displays the binary image BW on the screen and lets
you define the region to fill by selecting points interactively by using the
mouse. To use this interactive syntax, BW must be a 2-D image. Press
Backspace or Delete to remove the previously selected point. A shift-
click, right-click, or double-click selects a final point and starts the fill
operation. Pressing Return finishes the selection without adding a point.
40
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
imerode
imerode is the function used to Erode the image
Syntax
IM2 = imerode(IM,SE)
IM2 = imerode(IM,NHOOD)
IM2 = imerode(...,PACKOPT,M)
IM2 = imerode(...,SHAPE)
Description
IM2 = imerode(IM,SE) erodes the grayscale, binary, or packed binary
image IM, returning the eroded image IM2. The argument SE is a
41
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
uigetfile
Open standard dialog box for retrieving files
Syntax
filename = uigetfile
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec)
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec,DialogTitle)
[FileName,PathName,FilterIndex] =
uigetfile(FilterSpec,DialogTitle,DefaultName)
[FileName,PathName,FilterIndex] = uigetfile(...,'MultiSelect',selectmode)
42
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Description
filename = uigetfile displays a modal dialog box that lists files in the current
folder and enables you to select or enter the name of a file. If the filename is
valid and if the file exists, uigetfile returns the filename as a string when you
click Open. Otherwise uigetfile displays an appropriate error message, after
which control returns to the dialog box. You can then enter another filename or
click Cancel. If you click Cancel or close the dialog window, uigetfile returns
0. Successful execution of uigetfile does not open a file; it only returns the name
of an existing file that you identify.
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec) displays
only those files with extensions that match FilterSpec. On some platforms
uigetfile also displays the files that do not match FilterSpec in grey. The
uigetfile function appends 'All Files' to the list of file types. FilterSpec
can be a string or a cell array of strings, and can include the * wildcard.
If FilterSpec is a filename, that filename displays, selected in the File
name field. The extension of the file is the default filter.
FilterSpec can include a path. That path can contain '.','..', \, '/', or '~'. For
example, '../*.m' lists all code files in the folder above the current folder.
If FilterSpec is a folder name, uigetfile displays the contents of that
folder, the File name field is empty, and no filter applies. To specify a
folder name, make the last character of FilterSpec either '\' or '/'.
If FilterSpec is a cell array of strings, it can include two columns. The
first column contains a list of file extensions. The optional second column
contains a corresponding list of descriptions. These descriptions replace
standard descriptions in the Files of type field. A description cannot be
an empty string. The second and third examples illustrate use of a cell
array as FilterSpec.
43
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
44
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
you cancel it or remove the wildcard characters. This restriction applies to all
platforms, even to file systems that permit these characters in file names.
uiwait
Block program execution and wait for resume
Syntax
uiwait
uiwait(h)
uiwait(h,timeout)
Description
uiwait blocks execution until uiresume is called or the current figure is deleted.
This syntax is the same as uiwait(gcf).
uiwait(h) blocks execution until uiresume is called or the figure h is deleted.
uiwait(h,timeout) blocks execution until uiresume is called, the figure h is
deleted, or timeout seconds elapse. The minimum value of timeout is 1. If
uiwait receives a smaller value, it issues a warning and uses a 1 second timeout.
questdlg
used to Create and open question dialog box
Syntax
button = questdlg('qstring')
button = questdlg('qstring','title')
button = questdlg('qstring','title',default)
button = questdlg('qstring','title','str1','str2',default)
button = questdlg('qstring','title','str1','str2','str3',default)
button = questdlg('qstring','title', ..., options)
Description
45
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
46
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
std
Standard deviation
Syntax
s = std(X)
s = std(X,flag)
s = std(X,flag,dim)
Description
s = std(X), where X is a vector, returns the standard deviation using (1) above.
The result s is the square root of an unbiased estimator of the variance of the
population from which X is drawn, as long as X consists of independent,
identically distributed samples.
If X is a matrix, std(X) returns a row vector containing the standard deviation of
the elements of each column of X. If X is a multidimensional array, std(X) is
the standard deviation of the elements along the first nonsingleton dimension of
X.
s = std(X,flag) for flag = 0, is the same as std(X). For flag = 1, std(X,1) returns
the standard deviation using (2) above, producing the second moment of the set
of values about their mean.
s = std(X,flag,dim) computes the standard deviations along the dimension of X
specified by scalar dim. Set flag to 0 to normalize Y by n-1; set flag to 1 to
normalize by n.
47
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
RESULT
FIGURE-16;Maze to be solved
48
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
49
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
FIGURE-17
50
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
FIGURE-18
51
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
FIGURE-19
52
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
Conclusion
By implementing the digital image processing and analysis tools of MATLAB,
we have been able to develop the code for solving the mazes, in
which,mathematical morphology and its basic operators ‘Dilation’ and
‘Erosion’ plays the main role.Also the study of different thersholding & labeling
techniques of image processing helped us in achieving the result.
Thus our termpaper on”Maze solving using Imaze Analysis” has been
successfully completed .
53
Koneru Lakshmaiah College Of Engineering
Maze Solving Using Image Analysis
References
54
Koneru Lakshmaiah College Of Engineering