Upload
others
View
30
Download
0
Embed Size (px)
Citation preview
DISCRETE COSINE TRANSFORM
DISCRETE COSINE TRANSFORM FOR VARIOUS VALUES OF U AND V
AIM: To find discrete cosine transform for various values of u and v.
THEORY:
The discrete cosine transform (DCT) helps separate the image into parts (or spectral sub-bands) of
differing importance (with respect to the image's visual quality). The DCT is similar to the discrete Fourier
transform: it transforms a signal or image from the spatial domain to the frequency domain.
For most images, much of the signal energy lies at low frequencies , these appear in the upper left
corner of the DCT. It is computationally easier to implement and more efficient to regard the DCT as a set
of basis functions which given a known input array size (8 x 8) can be precomputed and stored. Each step from
left to right and top to bottom is an increase in frequency by 1/2 cycle. For example, moving right one from the
top-left square yields a half-cycle increase in the horizontal frequency. Another move to the right yields two
half-cycles. A move down yields two half-cycles horizontally and a half-cycle vertically. The top left square
gives dc component. For each value of u and v we get cosine waveform with different frequencies.
y(p+1,q+1)= ∑ ∑ AlphaU*AlphaV*cos(((2*p+1)*pi*u)/(2* p q
N))*cos(((2*q+1)*pi*v)/(2* N)));p=0 to N-1 and q=0 to N-1
AlphaU = sqrt(1/N) for u=0
AlphaU = sqrt(2/N) for other values of u
AlphaV = sqrt(1/N) for v=0
AlphaV = sqrt(2/N) for other values of v
PROCEDURE:
1. Initialize N=64.
2. Fix the values of alphau and alphav for different values of u and v.
3. Find y(p+1,q+1) for various values of u and v.
4. We observe that horizontal frequencies increases from left to right and vertical frequencies increase from top
to bottom.
5. We observe cosine waveform of different frequencies for different values of u and v.
NUMBER OF RGB VALUES CORRESPONDING TO
INTENSITY LEVEL
AIM
To determine the Total number of RGB values for an Intensity level and illustration of RGB triangle and Circle
on Intensity Axis.
THEORY
RGB colour cube
The colour space for computer based applications is often visualised by a unit cube. Each colour (red, green, blue)
is assigned to one of the three orthogonal coordinate axes in 3D space. An example of such a cube is shown below
along with some key colours and their coordinates.
Fig(1)
Note:
Along each axis of the colour cube the colours range from no contribution of that component to a fully
saturated colour.
The colour cube is solid, any point (colour) within the cube is specified by three numbers, namely, an r,g,b
triple.
The diagonal line of the cube from black (0,0,0) to white (1,1,1) represents all the greys, that is, all the
red, green, and blue components are the same.
In practice different computer hardware/software combinations will use different ranges for the colours,
common ones are 0-256 and 0-65536 for each component. This is simply a linear scaling of the unit colour
cube described here.
This RGB colour space lies within our perceptual space, that is, the RGB cube is smaller and represents
fewer colours than we can see.
The CMY and CMYK Colour Model
Cyan, magenta, yellow are the secondary colours of light or , alternatively , the primary colours of pigments. For
example, when a surface coated with cyan pigment is illuminated whit the light from reflected white light, which
itself is composed of equal amounts of red, green, and blue light. Most devices that deposit coloured pigment on
paper, such as colour printers and copiers, require CMY data input or perform an RGB to CMY conversion
internally. This conversion is performed using the simple operation.
Where, again, the assumption is that all colour values have been normalized to the range [0,1].
The HSI Colour Model
As we have seen , creating colours in the RGB and CMY models and changing from one model to the other is
straightforward process.The RGB system matches nicely with the fact that the human eye is strongly perceptive
to red, green, and blue primaries. Unfortunately , the RGB , CMY, and other similar colour models are not well
suited for describing colours in terms that are practical for human interpretation.
-When humans view a colour object, we describe it by its hue, saturation, and brightness.
-Whereas saturation gives a measure of the degree to which a pure colour is diluted by white light.
-Brightness is a subjective descriptor that is practically impossible to measure.
-It embodies the achromatic notion of intensity and is one of the key factors in describing colour sensation.
If we wantes to determine the intensity component of any colour point in above fig a,we would simply pass a
plane perpendicular to the intensity axis and containing the colour point.
As the planes moves up and down the intensity axis, the boundary defined by the intersection of each plane with
the faces of the cube have either a triangular or circular shape Fig(3).
Fig(3) a. RGB Triangles on Intensity axis ,b. RGB circles on Intensity Axis
STEPS
1. Choose in Intensity level.
2. By using formula I = (R+G+B)/3 , find R+G+B in terms of I as :
R+G+B = 3I ---------------------Eq.1
Where R = number of Red colour Values.
G = number of Green colour Values.
B = number of Blue colour Values.
I = Intensity Level.
3. Substitute the chosen Intensity level in Eq.1 and vary R , G and B value such that there combination
satisfies Eq.1.
4. The total number of combinations is the required answer.
IMAGE ROTATION THROUGH AN ANGLE USING TWO
METHODS
THEORY: Motivation to use color image rotation:
Rotation can be used to turn an image by a required angle for further processing. It helps us to rotate an image
for better view of the image
1) Image Rotation through an angle by transformation of coordinates:- Aim: To rotate a color or gray image by an angle θ counter clock wise or clock wise using transformation of coordinates and using nearest neighbour interpolation. Steps :
1. Read a color or rgb image. 2. Convert the rgb image to gray image.
3. Take an angle θ(in degrees) and convert it into radians.This is the angle by which the image has to be
rotated. 4. Take the transformation matrix as T={cosθ –sinθ;sinθ cosθ}. 5. Output image coordinates=T*input image coordinates.
6. Replace the new coordinates with the corresponding intensity values of the original image using nearest
neighbour interpolation.
7. Take ceil or round the pixels of the new image before replacing the intensities. Since coordinates can’t be fractional values.
8. Now display the rotated image.
2)Image rotation along maximum variance using eigen basis:- Aim: To rotate a misaligned image along maximum variance using eigen basis. Steps :
1. Read a color image. 2. Convert the color image to a gray image. 3. Find all the pixels which are black in color i.e with intensity value ‘0’.
4. Find the covariance matrix “Cx”of the black pixels’ coordinates(i.e ‘x’ found in previous step). 5. Compute the eigen values and vectors of Cx using eig function in Matlab.
6. Find the transformed vectors y=E’(x-µx). 7. Display the transformed image using Hotelling transform.
8. The covariance matrix of transformed vector y is Cy=E’CxE.
EIGEN BASIS OF FLOWERS
Aim:-
To find the eigen basis of flowers and reconstruction of original images by using linear
combinations of original images.
Theory
Eigen flowers can be considered as a set of standardized flower ingredients derived from
statistical analysis of many pictures of flowers. For example ,one’s flower might be composed
of the average flower plus 10% from eigen flower 1 ,55% from eigen flower 2 ,and even 3%
from eigen flower 3.But it does not take many eigen flowers combined together to achieve a
fair approximation of most flowers. This technique is also used for medical image analysis
handwriting analysis ,lip reading etc.
Procedure
1. Collect the group of closed angle flower images.
2. Each image is of the size 48x48.
3. Each image is reshaped to the size of 2304x1.
4. Compute the co-variance matrix for all images.
(arrange all the eigen values in the decreasing order)
5. Compute the Eigen basis corresponding to significant eigenvalues.
6. Reshape the obtained Eigen basis to 48x48 sized images.
7. Plot all the Eigen basis images using subplot
(use image.m, imshow.m to plot images).
8. Represent all the images individually as the linear combinations of the Eigen basis images
(compressed images).
IMAGE ENHANCEMENT
The principal objective of image enhancement is to process a given image so that the
result is more suitable than the original image for a specific application.
It accentuates or sharpens image features such as edges, boundaries, or contrast to make a
graphic display more helpful for display and analysis.
The enhancement doesn't increase the inherent information content of the data, but it
increases the dynamic range of the chosen features so that they can be detected easily.
The greatest difficulty in image enhancement is quantifying the criterion for enhancement
and, therefore, a large number of image enhancement techniques are empirical and
require interactive procedures to obtain satisfactory results.
Image enhancement methods can be based on either spatial or frequency domain
techniques.
Spatial domain enhancement methods
Spatial domain techniques are performed to the image plane itself and they are based on
direct manipulation of pixels in an image.
The operation can be formulated as g(x,y) =T[f(x,y)],
where g is the output, f is the input image and T is an operation on f defined over some
neighborhood of (x,y).
According to the operations on the image pixels, it can be further divided into 2
categories: Point operations and spatial operations (including linear and non-linear
operations).
Frequency domain enhancement methods
These methods enhance an image f(x,y) by convoluting the image with a linear, position
invariant operator.
The 2D convolution is performed in frequency domain with DFT.
Spatial domain: g(x,y)=f(x,y)*h(x,y)
Frequency domain: G(w1,w2)=F(w1,w2)H(w1,w2)
Enhancement by point processing
These processing methods are based only on the intensity of single pixels.
Simple intensity transformation:
(a). Image negatives:
Negatives of digital images are useful in numerous applications, such as displaying
medical images and photographing a screen with monochrome positive film with the idea
of using the resulting negatives as normal slides.
Transform function T : g(x,y)=L-f(x,y),
where L is the max. intensity.
(b). Contrast stretching
Low-contrast images can result from poor illumination, lack of dynamic range in the
image sensor, or even wrong setting of a lens aperture during image acquisition.
The idea behind contrast stretching is to increase the dynamic range of the gray levels in
the image being processed.
Histogram processing
The histogram of a digital image with gray levels in the range [0,L-1] is a discrete
function p(rk)=nk/n, where rk is the kth gray level, nk is the number of
pixels in the image with that gray level, n is the total number of pixels in the image, and
k=0,1..L-1.
P(rk) gives an estimate of the probability of occurrence of gray level rk.
The shape of the histogram of an image gives us useful information about the possibility
for contrast enhancement.
A histogram of a narrow shape indicates little dynamic range and thus corresponds to an
image having low contrast
(a) Histogram equalization
The objective is to map an input image to an output image such that its histogram. is uniform
after the mapping.
Let r represent the gray levels in the image to be enhanced and s is the enhanced output with a
transformation of the form s=T(r).
Assumption:
1. T(r) is single-valued and monotonically increasing in the interval [0,1], which preserves the
order from black to white in the gray scale.
2. 0 T(r) 1 for 0 r 1, which guarantees the mapping is consistent with the allowed range
of pixel values.
If Pr(r) and T(r) are known and T^-1(s) satisfies condition (a), the pdf of the transformed
gray levels is
Using a transformation function equal to the cumulative distribution of r produces an image
whose gray levels have a uniform density, which implies an increase in the dynamic range of
the pixels.
In order to be useful for digital image processing, eqns. should be formulated in discrete form:
A plot of Pr(rk )versus rk is actually a histogram, and the technique used for obtaining a
uniform histogram is known as histogram equalization or histogram linearization
(b) Histogram specification
Histogram equalization only generates an approximation to a uniform histogram.
Sometimes the ability to specify particular histogram shapes capable of highlighting certain
gray-level ranges in an image is desirable.
Procedures:
The principal difficulty in applying the histogram specification method to image enhancement
lies in being able to construct a meaningful histogram.
Spatial Filtering:
The use of spatial masks for image processing is called spatial filtering.
The masks used are called spatial filters.
The basic approach is to sum products between the mask coefficients and the intensities of the
pixels under the mask at a specific location in the image.
Where, (2d+1)X(2d+1) is the mask size, w(i,j)'s are weights of the mask, f(x,y) is input pixel at
coordinates (x,y), R(x,y) is the output value at (x,y).
If the center of the mask is at location (x,y) in the image, the gray level of the pixel located at
(x,y) is replaced by R, the mask is then moved to the next location in the image and the process
is repeated. This continues until all pixel locations have been covered.
1.Smoothing filter:
Smoothing filters are used for blurring and for noise reduction.
Blurring is used in preprocessing steps, such as removal of small details from an image prior
to object extraction, and bridging of small gaps in lines or curves.
Noise reduction can be accomplishing by blurring with a linear filter and also by nonlinear
filtering.
(a). Low pass filtering
The key requirement is that all coefficients are positive.
Neighborhood averaging is a special case of LPF where all coefficients are equal.
It blurs edges and other sharp details in the image.
(b). Median filtering
If the objective is to achieve noise reduction instead of blurring, this method should be used.
This method is particularly effective when the noise pattern consists of strong, spike-like
components and the characteristic to be preserved is edge sharpness.
It is a nonlinear operation.
For each input pixel f(x,y), we sort the values of the pixel and its neighbors to determine their
median and assign its value to output pixel g(x,y).
2.Sharpening Filters
To highlight fine detail in an image or to enhance detail that has been blurred, either in error
or as a natural effect of a particular method of image
acquisition.
Uses of image sharpening vary and include applications ranging from electronic printing and
medical imaging to industrial inspection and autonomous target detection in smart weapons.
(a). Basic highpass spatial filter
The shape of the impulse response needed to implement a highpass spatial filter indicates that
the filter should have positive coefficients near its center, and negative coefficients in the outer
periphery.
The filtering output pixels might be of a gray level exceeding [0,L-1].
The results of highpass filtering involve some form of scaling and/or clipping to make sure
that the gray levels of the final results are within [0,L-1].
(b). Derivative filters.
Differentiation can be expected to have the opposite effect of averaging, which tends to blur
detail in an image, and thus sharpen an image and be able to detect edges.
The most common method of differentiation in image processing applications is the gradient.
For a function f(x,y), the gradient of f at coordinates
(x',y') is defined as the vector
Its magnitude can be approximated in a number of ways, which result in a number of
operators such as Roberts, Prewitt and Sobel operators for computing its value.
Enhancement in the frequency domain:
We simply compute the Fourier transform of the image to be enhanced, multiply the result by
a filter transfer function, and take the inverse transform to produce the enhanced image.
Lowpass filtering
Edges and sharp transitions in the gray levels contribute to the high frequency content of its
Fourier transform, so a lowpass filter smoothes an image.
Highpass filtering
A highpass filter attenuates the low frequency components without disturbing the high
frequency information in the Fourier transform domain can
sharpen edges
STEPS FOR MASK OPERATIONS
1. Read the real time image
2. Convert it into gray image
3. Pad zeros to the matrix
4. Create a matrix of same size
5. Apply the mask to every 3X3 or 5X5 of the matrix and store it in the
new matrix
6. Display and compare the results
STEPS FOR THRESHOLDING
1. Read the real time image
2. Convert it into gray image
3. Create a new matrix of same size
4. Fix a thresholding value and compare it with each pixel
5. If the value is less than the threshold value make it zero, otherwise as
one
6. Display and compare the results
STEPS FOR EDGE DETECTION
1. Read the real time image
2. Convert it into gray image
3. Apply vertical edge detection mask and store the result, Ly
4. Apply horizontal edge detection mask and store the result, Lx
5. Now find the magnitude using the formula ,
6. Display and compare the results
PROBABILISTIC APPROACH 1
AIM:
Identifying the identical face images among trained and testing face image data and computing
percentage of success(POS) using probabilistic approach 1 of pattern recognition.
Steps and theory:
probabilistic approach comes under Statistical pattern recognition. Statistical pattern
recognition relates to the use of statistical techniques for analyzing data measurements in order
to extract information and make justified decisions. It is a very active area of study and
research, which has seen many advances in recent years. Applications such as data mining, web
searching, multimedia data retrieval, face recognition, and cursive handwriting recognition, all
require robust and efficient pattern recognition techniques.
SUPPORT VECTOR MACHINE
AIM:
Identifying the face images among trained and testing face image data and computing
percentage of success(POS) using Support Vector Machine of pattern recognition.
THEORY:
Consider two classes, first class including face images and second class including non-face
images. The equation for the line separating the two classes is given by 𝑊𝑇𝑋+ , where X is the
input image vector, W is the weight to be adapted and b is the scalar.
If
𝑊𝑇𝑋𝑘+𝑏<-1,𝑘 image belongs to class-2 (non-face image)
𝑊𝑇𝑋𝑘+𝑏 >1, 𝑋𝑘 image belongs to class-1 (face image)
In order to adjust the weights to the most appropriate values, a training sequence is used
initially. The training vectors are
(𝑋1,1)
(𝑋2,2)
.
.
(𝑋𝑁,𝑡𝑁)
Where 𝑡𝑘 is the variable such that, 𝑡𝑘 = +1 if 𝑋𝑘 belongs to class-1
-1 if 𝑋𝑘 belongs to class-2
PROCEDURE:
Step 1: For the give training vector consisting of N samples, use the equations given below to
obtain all ʎ’s - ʎ1, ʎ2,…ʎ𝑁,
Σ(𝑡𝑘𝑁𝑘=1𝑡𝑟𝑋𝑟𝑇𝑋𝑘ʎ𝑘)=2 ,𝑓𝑜𝑟 𝑟=1 𝑡𝑜 𝑁
Σ(𝑡𝑘𝑁𝑘=1ʎ𝑘)=0
Step 2: From the ʎ’s obtained, retain only those with positive values and use those ʎ𝑘 and their
corresponding 𝑋𝑘 to update W with the help of the following equation
𝑊=0.5Σ(𝑡𝑘𝑁𝑘=1𝑋𝑘ʎ𝑘)
Step 3: In order to obtain the value of ‘b’, use a non-zero ʎ𝑘 and its corresponding 𝑋𝑘 and 𝑡𝑘
from the training data in the following equation
ʎ[(𝑊𝑇𝑋𝑘+𝑏)𝑡𝑘−1]=0
This constitutes one epoch. The steps 2 and 3 are repeated many number of times, each time
with the recently acquired value of W as the initial value, so that the process approaches
convergence.
With this the training portion gets over.
Step 4: Now that the weights are adapted, unknown images are given as input (X) and
If
𝑊𝑇𝑋𝑘+𝑏<-1,𝑘 image belongs to class-2 (non-face image)
𝑊𝑇𝑋𝑘+𝑏 >1, 𝑋𝑘 image belongs to class-1 (face image)
IMAGE RESTORATION
IMAGE COMPRESSION USING WAVELET
PROCEDURE:
IMAGE COMPRESSION USING DCT
PROCEDURE:
MORPHOLOGICAL OPERATIONS
Logical Operations Involving Binary Image
The majority of applications based on the morphological concepts involve binary images.
Logic operations, although simple in nature, provide a powerful complement to implementation of
image processing algorithms based on morphology.
The principal logic operations used in image processing are AND, OR, and NOT (COMPLEMENT).
These operations are functionally complete in the sense that they can be combined to form any other
logic operation.
Logic operations are performed on a pixel by pixel basis between corresponding pixels of two or more
images, except NOT, which operates on the pixels of a single image.
Example:
The AND operation of two binary variables is 1 only when both variables are 1, i.e. the result at any
location in a resulting AND image is 1 only if the corresponding pixels in the two input images are 1.
Other logic operations are easily constructed using the principle logic operations. For example; XOR,
NOT-AND etc.
The logic operators described have one-to-one correspondence with the set operations, with the
limitations with the limitations that the logical operations are restricted to binary operations.
Morphological Operations:
Dilation
If A and B are from sets in Z2, i.e. from 2-dimensional Euclidean space ([a1,a2] & [b1,b2]
are elements of A & B respectively), then the dilation of A by B, is defined as
This equation is based on obtaining the reflection of B about its origin and shifting this
reflection by z.
The dilation of A by B then is the set of all displacements, z, such that B and A overlap by at
least one element.
Set B is commonly referred to as the structuring element.
Dilation causes the binary image to expand.
Algorithm for Dilution
1. Read the image.
2. Convert the image from RGB to Grey using rgb2grey()
3. Set the threshold value as 128
4. Set the grey value as 255 for every value of pixel whose grey value is greater than threshold
and as 0 for every value of pixel whose grey value is less than the threshold. Thus the image
is converted into binary image.
5. Create the structuring element.
6. Traverse the structuring element, row-wise and column-wise through the entire image.
7. At each instant, perform element by element multiplication and obtain the maximum value
and use it to replace the center pixel of that block of the input image.
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1
1 1 1
1 1 1
For red block:
The value of the middle pixel = max[1*0, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0] = 0
For blue block:
The value of the middle pixel = max[1*0, 1*0, 1*0, 1*1, 1*1, 1*1, 1*1, 1*1, 1*1] = 1
For yellow block:
The value of the middle pixel = max[1*1, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0, 1*0] = 1
Erosion
For sets A and B in Z2, i.e. from 2-dimensional Euclidean space ([a1,a2] & [b1,b2] are
elements of A & B respectively), the erosion of A by B, is defined as
This equation indicates that the erosion of A by B is the set of all points z such that B,
translated by z, is contained in A
The erosion of A by B then is the set of all displacements, z, such that B and A overlap by
every element.
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Diluted Image
Algorithm for Erosion
1. Read the image.
2. Convert the image from RGB to Grey using rgb2grey()
3. Set the threshold value as 128
4. Set the grey value as 255 for every value of pixel whose grey value is greater than threshold
and as 0 for every value of pixel whose grey value is less than the threshold. Thus the image
is converted into binary image.
5. Create the structuring element.
6. Traverse the structuring element, row-wise and column-wise through the entire image.
7. At each instant, perform element by element multiplication and obtain the minimum value
and use it to replace the center pixel of that block of the input image.
1 1 1
1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Image
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Structuring Element
Eroded Image
Opening and Closing
Opening generally smoothes the contour of an object, breaks narrow isthmuses, and
eliminates thin protrusions.
The opening of set A by structuring element B, is defined as
Thus, the opening A by B is the erosion of A by B, followed by a dilation of the result by B.
Closing also tends to smooth sections of contours but, as opposed to opening, it generally
fuses narrow breaks and long thin gulfs, eliminates small holes, and fills gaps in the contour.
The closing of set A by structuring element B, is defined as
Thus, the closing A by B is the dilation of A by B, followed by a erosion of the result by B.
Algorithm for Opening
1. Read the image.
2. Convert the image from RGB to Grey using rgb2grey()
3. Set the threshold value as 128
4. Set the grey value as 255 for every value of pixel whose grey value is greater than threshold
and as 0 for every value of pixel whose grey value is less than the threshold. Thus the image
is converted into binary image.
5. Create the structuring element.
6. Traverse the structuring element, row-wise and column-wise through the entire image.
7. At each instant, perform element by element multiplication and obtain the minimum value
and use it to replace the center pixel of that block of the input image.
8. Save the resulting image.
9. On the resulting image, traverse the structuring element, row-wise and column-wise.
10. At each instant, perform element by element multiplication and obtain the maximum value
and use it to replace the center pixel of that block of the input image.
Algorithm for Closing
1. Read the image.
2. Convert the image from RGB to Grey using rgb2grey()
3. Set the threshold value as 128
4. Set the grey value as 255 for every value of pixel whose grey value is greater than threshold
and as 0 for every value of pixel whose grey value is less than the threshold. Thus the image
is converted into binary image.
5. Create the structuring element.
6. Traverse the structuring element, row-wise and column-wise through the entire image.
7. At each instant, perform element by element multiplication and obtain the maximum value
and use it to replace the center pixel of that block of the input image.
8. Save the resulting image.
9. On the resulting image, traverse the structuring element, row-wise and column-wise.
10. At each instant, perform element by element multiplication and obtain the minimum value
and use it to replace the center pixel of that block of the input image.
Boundary Extraction
The boundary of a set A can be obtained by first eroding A by B and then performing the set
difference between A and its erosion.
Algorithm for Boundary Extraction
1. Read the image.
2. Convert the image from RGB to Grey using rgb2grey()
3. Set the threshold value as 128
4. Set the grey value as 255 for every value of pixel whose grey value is greater than
threshold and as 0 for every value of pixel whose grey value is less than the threshold.
Thus the image is converted into binary image.
5. Create the structuring element.
6. Traverse the structuring element, row-wise and column-wise through the entire image.
7. At each instant, perform element by element multiplication and obtain the maximum
value and use it to replace the center pixel of that block of the input image.
8. Save the resulting image.
9. Subtract the resulting image from the binary image to get the boundary.
IMAGE SEGMENTATION
AIM: To segment a image using point detection, line detection (hough transform) and
edge detection
Image segmentation:
A process of subdividing an image into constituent parts or objects in image. Different
approaches for image segmentation
1.Discontinuity based
(i) Isolated points
(ii)Lines
(iii)Edges
2.Similarity based
(i) Thresholding
(ii) Region growing
(iii) Region splitting and merging
STEPS FOR IMAGE SEMENTATION THROUGH BASIC THRESHOLDING:
1. Take a image and read it and convert the image from rgb to hsv model.
2. Using only hue content create a empty matrix using hue size.
3. Set a threshold and check each and every row and column of the hue matrix.
4. If the value of it is lower than threshold, set value as zero in empty matrix else the value will
be one.
5. Then show the segmented image.
From the below figure we can know how ramp edge with and without noise is affected by using
first and second derivative.
From above we can know how first and second derivatives helps in detection.
STEPS FOR CREATING EDGE DETECTION:
1. Take an image and read it and convert the image from rgb to gray image.
2. Pad zeros to input matrix.
3. Create a empty matrix using the size of the padded matrix.
4. Apply the 3*3 mask for every 3*3 of the padded matrix.
5. Then show the segmented image using edge detection.
STEPS FOR CREATING POINT DETECTION:
1. Take an image and read it and convert the image from rgb to gray image.
2. Pad zeros to input matrix.
3. Create a empty matrix using the size of the padded matrix.
4. Apply the 3*3 or 5*5 mask for every 3*3 or 5*5 of the padded matrix.
5. Then show the segmented image using point detection.
HPF MASK:
3*3 Laplacian mask:
5*5 Laplacian mask:
HOUGH TRANSFORM:
HOUGH TRANSFORM USAGE FOR DETECTION OF CIRCLES:
STEPS FOR CREATING LINE DETECTION USING HOUGH TRANSFORM
A straight line can be represented as
◦ y = mx + c
◦ This representation fails in case of vertical lines
A more useful representation in this case is
Quantize the Hough Transform space: identify the maximum and minimum values of r
and q
Generate an accumulator array A(r, q); set all values to zero
For all edge points (xi, yi) in the image
◦ Use gradient direction for q
◦ Compute r from the equation
◦ Increment A(r, q) by one
For all cells in A(r, q)
◦ Search for the maximum value of A(r, q)
◦ Calculate the equation of the line
STEPS FOR CREATING LINE DETECTION
(horizontal,vertical,+45,-45 degree lines)
1. Take an image and read it and convert the image from rgb to gray image.
2. Pad zeros to input matrix.
3. Create a empty matrix using the size of the padded matrix.
4. Apply the 3*3 mask for every 3*3 of the padded matrix.
5. Then show the segmented image using line detection.
6. Different masks for line detection(horizontal,vertical,+45,-45)
COLOR IMAGE PROCESSING
THEORY:
Motivation to use color image processing:
Powerful descriptor that often simplifies object identification and extraction from a scene.
Humans can discern thousands of color shades and intensities, compared to about only two dozen shades
of gray.
Two major areas:
Full-color processing: e.g. images acquired by color TV camera or color scanner.
Pseudo-color processing: assigning a color to a particular monochrome intensity or range of
intensities.
The RGB Color Model:
Each color appears in its primary spectral components of Red, Green and Blue.
Model is based on a Cartesian coordinate System .Here the Color subspace is a cube .
RGB primary values will be at 3 opposite corners (and secondary values at 3 others) .
Black at the origin, White at the opposite corner.
1) SMOOTHING IN RGB :-
Aim: Smoothing of a color image corrupted by salt and pepper noise in RGB model using matlab.
Steps :
1. Read a color image.
2. Corrupt the image by salt and pepper noise.
3. Now we have to restore the image using median filter.
4. Now get the red component separated and perform the median filtering on it.
5. Here for performing median filtering 'medfilt2' function is used.
6. Similarly proceed for green and blue components also.
7. Now we will get the smoothed image as the output.
8. Display the corrupted image and Smoothed image.
2) SMOOTHING IN HSI:-
Aim: Smoothing of color image corrupted by salt and pepper noise in HSI model using matlab.
Steps :
1. Read a color image.
2. Corrupt the image by salt and pepper noise.
3. Now we have to restore the image using median filter.
4. Convert it from RGB to HSI using the function rgb2hsv.
5. Now get the intensity component separated and perform the median filtering on it.
6. Here for performing median filtering 'medfilt2' is used.
7. Now covert the image back to RGB from HSI using the function hsv2rgb .
8. Now we will get the smoothed image as the output.
9. Display the corrupted image and Smoothed image.
3) SHARPENING IN RGB :-
Aim: Sharpening of color image in RGB model using matlab.
Steps :
1. Read a color image.
2. take the mask [0 1 0;1 -4 1;0 1 0].
3. Now get the red component separated and perform the one to one multiplication with the mask.
4. Similarly proceed for green and blue components also.
5. Here we will get the high pass filtered image as the output
6. Now subtract the above output from the input image
7. We will get the Sharpened image as the output.
8. Display the original image and Sharpened image.
4) SHARPENING IN HSI:-
Aim: Sharpening of color image in HSI model using matlab.
Steps :
1. Read a color image.
2. take the mask [0 1 0;1 -4 1;0 1 0].
3. Convert the image from RGB to HSI using the function rgb2hsv.
4. Now get the intensity component separated and perform the one to one multiplication with the mask.
5. Here for performing one to one multiplication we used 'conv2' function.
6. Now covert the image back to RGB from HSI using the function hsv2rgb .
7. Here we will get the high pass filtered image as the output
8. Now subtract the above output from the input image
9. Display the original image and Sharpened image.
5)GAMMA CORRECTION OF A COLOR IMAGE:-
AIM: To perform the gamma correction of a color image through a look up table.
Steps:
1. Read a color image.
2. select a gamma value (1 or >1 or <1).
3. find the maximum intensity of the image.
4. realize the look up table formula, that is
5. look up table=max*[((0:max)/max)^gamma].
6. Now map every pixel of input image into look up table values.
7. We will get output as the gamma corrected image.
8. If gamma is equal to one, we will get the resemble output, if greater than 1 we will get dark output, if
less than 1 we will get bright output.
6)PSEUDO COLORING OPERATION ON GRAY IMAGE:-
Aim: To perform the Pseudo color operation on gray image using MATLAB program.
Steps:
1. Read a gray image.
2. get the size of input image which is a gray image.
3. Now partition the input image based on its gray level.
4. Now take the each partition separately and map each pixel value to a color.
5. In same fashion proceed for all partitions.
6. Finally we will get the colored image as the output, which is nothing but a pseudo colored image.
7. Display the original image and the Pseudo colored image.
7)HISTOGRAM EQUALIZATION OF A COLOR IMAGE IN RGB MODEL:-
AIM: To perform the histogram equalization of a color image in RGB model using MATLAB program.
Steps:
1. Read a color image.
2. Now get the red component separated and perform the histogram equalization on it.
3. Here for performing histogram equalization 'histeq' function is used.
4. Similarly proceed for green and blue components also.
5. Now we will get the histogram equalized image as the output.
6. Display the original image and histogram equalized image.
8)HISTOGRAM EQUALIZATION OF A COLOR IMAGE IN HSI MODEL:-
AIM: To perform the histogram equalization of a color image in HSI mdoel using MATLAB program.
Steps:
1. Read a color image.
2. Convert the image from RGB to HSI using the function rgb2hsv.
3. Now get the intensity component separated and perform the histogram equalization on it
4. Here for performing histogram equalization 'histeq' function is used..
5. Now covert the image back to RGB from HSI using the function hsv2rgb .
6. Here we will get the histogram equalized image as the output
7. Display the original image and histogram equalized mage.
9)EDGE DETECTION OF A COLOR IMAGE IN RGB MODEL:-
AIM: To perform the Edge detection of a color image in RGB model using MATLAB program.
Steps:
1. Read a color image.
2. take the mask [-1 -1 -1;-1 8 -1;-1 -1 -1].
3. Now get the red component separated and perform the one to one multiplication with the mask.
4. Similarly proceed for green and blue components also.
5. Here we will get the high pass filtered image.
6. That is nothing but the edge detected image
7. Display the original image and edge detected image.
10)EDGE DETECTION OF A COLOR IMAGE IN HSI MODEL:-
AIM: To perform the Edge detection of a color image in HSI model using MATLAB program.
Steps:
1. Read a color image.
2. take the mask [-1 -1 -1;-1 8 -1;-1 -1 -1].
3. Convert the image from RGB to HSI using the function rgb2hsv.
4. Now get the intensity component separated and perform the one to one multiplication with the mask.
5. Here for performing one to one multiplication we used 'conv2' function.
6. Now covert the image back to RGB from HSI using the function hsv2rgb .
7. Here we will get the high pass filtered image as the output
8. That is nothing but the edge detected image.
9. Display the original image and edge detected image.