SlideShare a Scribd company logo
Comparison of Gaussian Filtering and Bilateral Filtering on
RGB Images
Aprameyo Roy
SC14B079
Avionics
Nikunj Gupta
SC14B105
Avionics
1 Abstract
This report presents the implementation of Bilateral Filtering - a filter which is used for
smoothening an image while conserving its edges. The comparison with other filters such
as the Box and the Gaussian filters has been elucidated. There has been rigorous analysis
of all the parameters of Bilateral Filtering and their effects on the test images with and
without noise added to it. Finally an analysis was performed on the parallel and serial
implementation of the Bilateral Filter and various factors such as speed and memory used
were compared for both the implementations.
2 Introduction
An image is a 2D array of pixels. Each of this pixel can be defined either by intensity(in case of Grayscale)
or a 3D vector(in case of RGB colour). Blurring is used in pre-processing steps, such as removal of small
details from an image prior to large object extraction. The shape of an object is due to its edges. So in
blurring, we reduce the edge content in an image and try to make the transitions between different pixel
intensities as smooth as possible.
(a) Original Image (b) Image only with edges
The concept of blurring involves making adjacent pixels look similar. So, the strategy which is
employed by most of the blur filters is that of replacing a particular pixel by an average of its neighbouring
pixels. The type of average which we will take is going to define different types of filters. Here, we would
be comparing the results of three very basic but effective filters, namely, box filter, Gaussian filter and
Bilateral filter. Also, the Bilateral filter has complex computations involved(basically because it uses two
different filters). So the paper discusses an effective parallel implementation of this filter and compares
its results with the normal implementation.
1
3 Box Filter
Box(Mean) filtering is a simple, intuitive and easy to implement method of smoothing images, i.e.
reducing the amount of intensity variation between one pixel and the next. The idea of box filtering is
simply to replace each pixel value in an image with the mean (average) value of its neighbors, including
itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings
(very different in intensity). Box filtering is based around a kernel, which represents the shape and size
of the neighbourhood to be sampled when calculating the mean.
The kernel used looks like a box, hence the name of the filter. Due to its property of using equal weights
it can be implemented using a much simpler accumulation algorithm. The only degree of freedom in this
filter is the window(kernel) size whose effect is seen later. The equation in effect is:
BA[I]p = q∈S Bσ(p − q)Iq
Here, BA[I]p is the result at pixel p, Bσ(p − q) is the box function, which basically depends on the
distance between the two pixels(p and q) and Iq is the intensity at pixel q. Here the summation on pixel
q goes over the entire kernel(window).
As can be seen, the problem with such an approach is that it gives inappropriate blurring at the
edges(i.e. wherever there is sudden change in intensity). Further, a single pixel with a very unrepresen-
tative value can significantly affect the mean value of all the pixels in its neighborhood. Such a filter
gives blocky results and may cause axis-aligned streaks.
3.1 Effect of Kernel(window) Size
It can be seen that as the window size is increased, the results get worse, with image getting very
blurry for window of size around 10.
The common strategy to overcome these problems is the use of a window which has a smooth falloff.
Hence, we introduce Gaussian filter which uses an isotropic(i.e. circular) window.
2
4 Gaussian Filter
Gaussian filter blurs an image by implementing the Gaussian function. Here, g(x) has mean = 0 and
variance = σ2
s .
g(x) = 1√
2πσ2
s
e
− x2
2σ2
s
Since image is a 2D array, we’ll be using two dimensional Gaussian, which is the product of two such
Gaussians, one per direction:
g(x, y) = 1
2πσ2
s
e
− x2+y2
2σ2
s
where x is the distance from the origin in the horizontal axis and y is the distance from the origin in
the vertical axis. The subscript s in σs has been used to emphasize on the fact that this parameter con-
trols the space over which the Gaussian function is spread. The effect of this parameter is discussed later.
Mathematically, applying a Gaussian blur to an image is the same as convolving the image with a
Gaussian function. Since the Fourier transform of a Gaussian is another Gaussian, applying a Gaussian
filter has the effect of reducing the image’s high-frequency components, therefore, a Gaussian filter is a
low pass filter.
It takes “weighted average of pixels”, and hence, this technique is much more efficient than the box filter.
The weights, in this case, is determined by the Gaussian function. The new pixel value is governed by
the following transformation:
GB[I]p = q∈S Gσs (||p − q||)Iq
Here, Gσs
(||p − q||) is the normalized Gaussian function with mean µ = 0 and variance = σ2
s . Therefore,
the control parameters here are the window size and the sigma for the Gaussian function. Changing the
two parameter values gives different results on the images.
4.1 Effect of Window Size
Here σs = 4.
It can be seen that Gaussian Filtering gives pretty good results, even when the window size is
increased. There is not much difference in output images for window size 8 and 12 as can be seen. This
3
is where the parameter σs plays a crucial role. Since σs(or its square, the variance) decides the area over
which the Gaussian is spread, however large window is taken beyond a certain value, the result will be
the same. Hence, the parameter σs gives some control so that the image doesn’t become too blurred
and indistinguishable from the original image and most of the important information from the original
image is still retained.
4.2 Effect of Spatial Parameter σs
With the window size kept a constant(say 5) and σs varied, following results are obtained:
The difference between the effect of window size and spatial parameter σs can be difficult to observe
or even explain. There is just a subtle difference, which is more clear from the MATLAB code(Appendix
B). Window size defines the area over which I’m currently focussing on, with distance between each pixel
as the input. Whereas, σs defines the variance or the spread of the Gaussian over this window. Hence,
the window is always a square, but the Gaussian function controls which pixels would actually contribute
in averaging the pixel of interest. Large variance(σs) gives more spread of the Gaussian over the window,
taking more pixels to average out the pixel of interest. It is observed that for certain σs, as window size
is increased beyond a certain value, the filter won’t give a different output. This is because the spread
of the Gaussian is fixed, so however large window is chosen, the output won’t be affected because of new
far away pixels.
If someone observes very closely around the eyes of the hawk in the picture, it can be seen that it
is blurred(except when σs is very small). Filtering of the edges can remove important information from
images, especially when the images being dealt with are related to weather or satellite data or something
of the sort. Edges form the basic shape of an image(as explained in the Introduction) and if the edges
are blurred, useful information which defines the image might get lost.
Intuitively, it can be seen that if there is another parameter which can control the shape of the ker-
nel(window), better results are expected. Bilateral Filtering is an example, where a third parameter(σr)
4
is employed. Bilteral Filtering is discussed in the following sections.
5 Bilateral Filter
The bilateral filter is a nonlinear filter that smooths a signal while preserving strong edges. As mentioned
earlier, it is able to preserve edges because of the third parameter, σr which is called the Range Parameter.
The technique is that it doesn’t average out the pixels around the edges and hence. the kernel shape
depends on the image content(i.e. the pixels intensity). Another Gaussian function with variance σr is
used, but the random variable here is the intensity(or RGB) difference between the current pixel and
it’s neighbouring pixels. Same idea as the Gaussian filter is used, with the only difference now being my
filter multiplied with another Gaussian factor.
BF[I]p = q∈S Gσs (||p − q||)Gσr (|Ip − Iq|)Iq
The first two factors are the same as defined in Gaussian filter. The additional factor Gσr takes dif-
ference in intensity of the pixels as input, and accordingly gives weights to the output. Therefore, the
combination of Gσs
and Gσr
considers effect of only those pixels which are close in space and in range.
An additional normalization factor(Wp) is required to take care of the amplitude changes which happen
due to the two Gaussians. Hence, the modified equation is:
BF[I]p = 1
Wp q∈S Gσs
(||p − q||)Gσr
(|Ip − Iq|)Iq
The effect of window size and σs are the same as observed in Gaussian filtering and won’t be discussed
further. The main point of interest here is how the range parameter σr produces edge retention and its
comparison with output of the Gaussian filter.
5
5.1 Effect of Range Parameter σr
Following results are obtained for fixed values of window size(=5) and spatial parameter(σs = 2.5):
Same effect as of varying the spatial parameter σs is observed. As σr increases, the image gets more
blurred. But the important thing to note here is that the edges are retained, or the process atleast tries
to retain those points which have sudden jump in pixel intensity. This result is further discussed when
the Gaussian filter and Bilateral filter are compared.
6 Comparison of Gaussian Filtering and Bilateral Filtering
The main between the two type of filters lies in one using an additional parameter(σr) to control the
shape of the window. Keeping the window size and spatial parameter same for both the filters, output
of the filters is taken and observed
Here window size = 5 and σs = 3.5 .
It can be observed that for σr = 0.5, bilateral filter is able to retain the edges as well(notice closely the
beak and eyes). Gaussian filter causes blur to sharp edges as well, whereas depending on the value of
range parameter(σr), good results can be obtained from Bilateral filtering in terms of edge retention.
In case of Gaussian filter, only the spatial distance between the pixel matters. Even though this falls
of gradually given some σs, it is not effective in taking into account the intensity difference between these
pixels. In other words, the kernel shape is same everywhere which is nearly circular in 2 dimensions. On
the other hand, Bilateral filter takes the intensity difference into account, converting it into Gaussian
and is ultimately multiplied with the original filter to give different shaped kernels.
One can make an obvious remark that when range parameter σr is infinity, the Bilateral filter becomes
equal to the Gaussian filter.
6
Effect of Gaussian Filtering and Bilateral Filtering on Noisy Images
Common signal processing applications require removing noise from images or even other signals. The
most common type of noise in the environment is the Gaussian noise(or it can be shown that large
number of noises ultimately add up to form a gaussian noise according to Central Limit Theorem). Here
performance of both Gaussian and Bilateral filtering on noisy images is observed.
The MATLAB command imnoise is used to insert Gaussian noise of certain mean and variance to the
image. Results of the two filters are shown:
Both Bilateral and Gaussian filtering give good performance against noise. By varying the parameters
of these filters, better results can be obtained. It is interesting to see that in Bilateral Filtering sharper
edges are retained and thus better filtering is performed.
7 Parallel Implementation Of Bilateral Filter
7.1 Basic Introduction To General Purpose Graphics Processing Units
We are in a time where we require very high computational ability from our processors and in just a few
years the programmable graphics processor unit has evolved into very powerful computing workhorse.
All of the programs which have been implemented have been highly optimized for a sequential run but
the speeds of execution cannot match that of the program running in a massively parallel architecture.
With multiple cores driven by very high memory bandwidth, today’s GPUs offer incredible resources for
both graphics and non-graphics processing.
7
The above architecture is extremely efficient in compute-intensive, highly parallel computation and
that is exactly what image processing primarily needs. It sacrifices data caching and flow control features
almost entirely and all of the transistors are devoted to processing and there is enormous amounts of
brute computational power due to this.
7.1.1 CUDA by NVIDIATM
We employ CUDA- Compute Unified Device Architecture , a recent hardware and software archi-
tecture developed by NVIDIATM
for issuing and managing computations on the GPU.
8
The Programming Model is as follows:
Here a kernel is a C function that, when called, is executed N times in parallel by N different CUDA
threads, as opposed to only once like regular C functions.This is the basic idea behind parallelizing a
process.
The hierarchy is as follows :
GRID consists of multiple Blocks and a block consists of multiple Threads. The threads per block
and the blocks per grid have a maximum number which can be allocated according to the device which
is being used. The device is used to refer to the GPU whereas the HOST is the CPU. The CPU is used
to control the input and initialization of the GPU and then it is used for the computation and again
returns the data back to the CPU. This is the fundamental which is used in our project to make the
bilateral filtering operation to be much more computationally effective.
The other basic fundamental includes the cudaMemcpy() command which is used to transfer data
from the HOST memory to the DEVICE memory or vice-versa. This is the only Achilles heel in the
entire process of parallel computing as this instruction takes time , but if the process is computationally
intensive then the time taken for the transfer of data is insignificant to the amount of time taken to
compute , and thus the true power of multi core processors are visible.
9
7.1.2 Current Specifications
GPU
Model: Nvidia - GeForce GTX- 980m
Dedicated Video Memory : 8192 MB - GDDR5
CUDA cores : 1536
Memory Bandwidth : 160.32 GB/sec
Memory Data Rate :5010 MHz
Graphics Clock: 1038 MHz
CPU
Model : Intel i7 6700
Memory : 8 GB 2133 MHz DDR4
Clock Speed : 3.40 GHz
7.2 Parallel Implementation Of Bilateral Filtering
Filtering images can often be a highly process where each pixel in the image is affected by a given filter.
Filtering each pixel is an operation which is independent of the application of the filter to other neighbor
pixels. Since an image consists of a very large number pixels this leads it to be a good candidate for
parallelization.
Bilateral filtering is in itself a very computationally heavy process and requires more time than any
standard filtering technique. Bilateral Filtering as discussed before is an edge preserving and smoothen-
ing filter which is twice as computationally costly as the Gaussian filter.
10
A sequential implementation of the filter allows Bilateral Filtering on each pixel on the image, using
a kernel radius/window to define the size of local neighborhood.A basic parallelization can be done by
taking the code for the individual pixel and use that as a basis for a kernel. This kernel is then launched
with parameters which generates a thread for each pixel in the image. The pseudo-code given below
would resemble what is used to call a kernel , where gridSize and blockSize are determined by image
height and width.
d_bilateral_filter<<< gridSize, blockSize>>>(res, width, height, e_d, radius);
7.3 Performance Analysis
We now analyze the massive boost in performance which is achieved due to the import of the Bilateral
Filter program from a sequential style to a parallel mode.
The following is the result obtained from the NSIGHTTM
debugger’s performance analysis tool for the
GPU. The program has been run for ”hawk.bmp” and a window of 5 with sigma = 2.5 and delta = .5.
7.3.1 CPU AND GPU
Figure 2: Performance Analysis Summary
Figure 3: Utilization Of CPU cores
Here we can see that the complete duration taken by the program to execute completely is 4.56
seconds which is still significantly less than what a single threaded CPU would have taken. However
the major chunk of this time has been eaten away by secondary processes like the debugger , wireless
services and system processes , however the time what we need to focus on is the time taken by the GPU
to compute and also the copying of data from HOST to DEVICE and vice-versa.
7.3.2 GPU
Here we see that the duration of the computation done by the GPU only requires a mere 1.167 seconds
to complete calculation. This is extremely fast and is slowed down further due to the transport of infor-
mation from DEVICE and HOST. Further improvement in performance with respect to serial execution
is visible when the image to be filtered has higher resolution ex. 1920x1080 or more.
11
Figure 4: Performance Analysis Summary(GPU)
Figure 5: Function Calls And Thread Usage)
8 References
http://dsp.stackexchange.com/questions/6289/understanding-the-parameters-for-a-bilateral-filter
TOMASI, C. and MANDUCHI, R. 1998. Bilateral Filtering for Gray and Color Images. In Proceedings
of the International Conference on Computer Vision
http://www.nvidia.com/object/cuda-home-new.html.
http://en.wikipedia.org/wiki/Gaussian-blur
Bilateral Filtering with CUDA Lasse Kljgaard Staal
http://people.csail.mit.edu/sparis/siggraph07-course/
12

More Related Content

What's hot

Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
Texture Unit based Monocular Real-world Scene Classification using SOM and KN...Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
IDES Editor
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
mmjalbiaty
 
3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides
BHAGYAPRASADBUGGE
 
Qcce quality constrained co saliency estimation for common object detection
Qcce quality constrained co saliency estimation for common object detectionQcce quality constrained co saliency estimation for common object detection
Qcce quality constrained co saliency estimation for common object detection
Koteswar Rao Jerripothula
 
Improved Characters Feature Extraction and Matching Algorithm Based on SIFT
Improved Characters Feature Extraction and Matching Algorithm Based on SIFTImproved Characters Feature Extraction and Matching Algorithm Based on SIFT
Improved Characters Feature Extraction and Matching Algorithm Based on SIFT
Nooria Sukmaningtyas
 
SinGAN for Image Denoising
SinGAN for Image DenoisingSinGAN for Image Denoising
SinGAN for Image Denoising
KhalilBergaoui
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
Amnaakhaan
 
Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical image Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical image
acijjournal
 
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
Binus Online Learning
 
Ijetr011917
Ijetr011917Ijetr011917
Ijetr011917
ER Publication.org
 
SinGAN - Learning a Generative Model from a Single Natural Image
SinGAN - Learning a Generative Model from a Single Natural ImageSinGAN - Learning a Generative Model from a Single Natural Image
SinGAN - Learning a Generative Model from a Single Natural Image
Jishnu P
 
Image segmentation using normalized graph cut
Image segmentation using normalized graph cutImage segmentation using normalized graph cut
Image segmentation using normalized graph cut
Mahesh Dananjaya
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
Rania H
 
Effect of Block Sizes on the Attributes of Watermarking Digital Images
Effect of Block Sizes on the Attributes of Watermarking Digital ImagesEffect of Block Sizes on the Attributes of Watermarking Digital Images
Effect of Block Sizes on the Attributes of Watermarking Digital Images
Dr. Michael Agbaje
 
Anatomy of a Texture Fetch
Anatomy of a Texture FetchAnatomy of a Texture Fetch
Anatomy of a Texture Fetch
Mark Kilgard
 
Final
FinalFinal
Lecture 12
Lecture 12Lecture 12
Lecture 12
Wael Sharba
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
ijceronline
 

What's hot (18)

Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
Texture Unit based Monocular Real-world Scene Classification using SOM and KN...Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
Texture Unit based Monocular Real-world Scene Classification using SOM and KN...
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
 
3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides
 
Qcce quality constrained co saliency estimation for common object detection
Qcce quality constrained co saliency estimation for common object detectionQcce quality constrained co saliency estimation for common object detection
Qcce quality constrained co saliency estimation for common object detection
 
Improved Characters Feature Extraction and Matching Algorithm Based on SIFT
Improved Characters Feature Extraction and Matching Algorithm Based on SIFTImproved Characters Feature Extraction and Matching Algorithm Based on SIFT
Improved Characters Feature Extraction and Matching Algorithm Based on SIFT
 
SinGAN for Image Denoising
SinGAN for Image DenoisingSinGAN for Image Denoising
SinGAN for Image Denoising
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical image Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical image
 
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
 
Ijetr011917
Ijetr011917Ijetr011917
Ijetr011917
 
SinGAN - Learning a Generative Model from a Single Natural Image
SinGAN - Learning a Generative Model from a Single Natural ImageSinGAN - Learning a Generative Model from a Single Natural Image
SinGAN - Learning a Generative Model from a Single Natural Image
 
Image segmentation using normalized graph cut
Image segmentation using normalized graph cutImage segmentation using normalized graph cut
Image segmentation using normalized graph cut
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Effect of Block Sizes on the Attributes of Watermarking Digital Images
Effect of Block Sizes on the Attributes of Watermarking Digital ImagesEffect of Block Sizes on the Attributes of Watermarking Digital Images
Effect of Block Sizes on the Attributes of Watermarking Digital Images
 
Anatomy of a Texture Fetch
Anatomy of a Texture FetchAnatomy of a Texture Fetch
Anatomy of a Texture Fetch
 
Final
FinalFinal
Final
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 

Viewers also liked

CH5
CH5CH5
Bilateral filtering for gray and color images
Bilateral filtering for gray and color imagesBilateral filtering for gray and color images
Bilateral filtering for gray and color images
Harshal Ladhe
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
Suhaila Afzana
 
Matlab Image Restoration Techniques
Matlab Image Restoration TechniquesMatlab Image Restoration Techniques
Matlab Image Restoration Techniques
DataminingTools Inc
 
SPATIAL FILTER
SPATIAL FILTERSPATIAL FILTER
Spatial filtering using image processing
Spatial filtering using image processingSpatial filtering using image processing
Spatial filtering using image processing
Anuj Arora
 
Introduction to Wavelet Transform with Applications to DSP
Introduction to Wavelet Transform with Applications to DSPIntroduction to Wavelet Transform with Applications to DSP
Introduction to Wavelet Transform with Applications to DSP
Hicham Berkouk
 
Introduction to wavelet transform
Introduction to wavelet transformIntroduction to wavelet transform
Introduction to wavelet transform
Raj Endiran
 
discrete wavelet transform
discrete wavelet transformdiscrete wavelet transform
discrete wavelet transform
piyush_11
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
Vinay Gupta
 

Viewers also liked (10)

CH5
CH5CH5
CH5
 
Bilateral filtering for gray and color images
Bilateral filtering for gray and color imagesBilateral filtering for gray and color images
Bilateral filtering for gray and color images
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
 
Matlab Image Restoration Techniques
Matlab Image Restoration TechniquesMatlab Image Restoration Techniques
Matlab Image Restoration Techniques
 
SPATIAL FILTER
SPATIAL FILTERSPATIAL FILTER
SPATIAL FILTER
 
Spatial filtering using image processing
Spatial filtering using image processingSpatial filtering using image processing
Spatial filtering using image processing
 
Introduction to Wavelet Transform with Applications to DSP
Introduction to Wavelet Transform with Applications to DSPIntroduction to Wavelet Transform with Applications to DSP
Introduction to Wavelet Transform with Applications to DSP
 
Introduction to wavelet transform
Introduction to wavelet transformIntroduction to wavelet transform
Introduction to wavelet transform
 
discrete wavelet transform
discrete wavelet transformdiscrete wavelet transform
discrete wavelet transform
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 

Similar to linkd

channel_mzhazbay.pdf
channel_mzhazbay.pdfchannel_mzhazbay.pdf
channel_mzhazbay.pdf
Maksat Zhazbayev
 
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
CSCJournals
 
An Analysis of Energy Efficient Gaussian Filter Architectures
An Analysis of Energy Efficient Gaussian Filter ArchitecturesAn Analysis of Energy Efficient Gaussian Filter Architectures
An Analysis of Energy Efficient Gaussian Filter Architectures
IRJET Journal
 
Multiexposure Image Fusion
Multiexposure Image FusionMultiexposure Image Fusion
Multiexposure Image Fusion
IJMER
 
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
idescitation
 
BilateralFiltering
BilateralFilteringBilateralFiltering
BilateralFiltering
Jacob Logas
 
I010634450
I010634450I010634450
I010634450
IOSR Journals
 
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier ExposurePerformance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
iosrjce
 
Paper on image processing
Paper on image processingPaper on image processing
Paper on image processing
Saloni Bhatia
 
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
CSCJournals
 
image-processing-husseina-ozigi-otaru.ppt
image-processing-husseina-ozigi-otaru.pptimage-processing-husseina-ozigi-otaru.ppt
image-processing-husseina-ozigi-otaru.ppt
RaviSharma65345
 
K010236168
K010236168K010236168
K010236168
IOSR Journals
 
robio-2014-falquez
robio-2014-falquezrobio-2014-falquez
robio-2014-falquez
Vincent Spinella-Mamo
 
Visual Quality for both Images and Display of Systems by Visual Enhancement u...
Visual Quality for both Images and Display of Systems by Visual Enhancement u...Visual Quality for both Images and Display of Systems by Visual Enhancement u...
Visual Quality for both Images and Display of Systems by Visual Enhancement u...
IJMER
 
Multiexposure Image Fusion
Multiexposure Image FusionMultiexposure Image Fusion
Multiexposure Image Fusion
IJMER
 
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTIONEDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
csitconf
 
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTIONEDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
cscpconf
 
Paper id 27201451
Paper id 27201451Paper id 27201451
Paper id 27201451
IJRAT
 
An automatic algorithm for object recognition and detection based on asift ke...
An automatic algorithm for object recognition and detection based on asift ke...An automatic algorithm for object recognition and detection based on asift ke...
An automatic algorithm for object recognition and detection based on asift ke...
Kunal Kishor Nirala
 
MachineVision_Chapter5_Edge_Detection.pdf
MachineVision_Chapter5_Edge_Detection.pdfMachineVision_Chapter5_Edge_Detection.pdf
MachineVision_Chapter5_Edge_Detection.pdf
Aurele Gnanha
 

Similar to linkd (20)

channel_mzhazbay.pdf
channel_mzhazbay.pdfchannel_mzhazbay.pdf
channel_mzhazbay.pdf
 
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
 
An Analysis of Energy Efficient Gaussian Filter Architectures
An Analysis of Energy Efficient Gaussian Filter ArchitecturesAn Analysis of Energy Efficient Gaussian Filter Architectures
An Analysis of Energy Efficient Gaussian Filter Architectures
 
Multiexposure Image Fusion
Multiexposure Image FusionMultiexposure Image Fusion
Multiexposure Image Fusion
 
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
NMS and Thresholding Architecture used for FPGA based Canny Edge Detector for...
 
BilateralFiltering
BilateralFilteringBilateralFiltering
BilateralFiltering
 
I010634450
I010634450I010634450
I010634450
 
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier ExposurePerformance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
 
Paper on image processing
Paper on image processingPaper on image processing
Paper on image processing
 
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
Invariant Recognition of Rectangular Biscuits with Fuzzy Moment Descriptors, ...
 
image-processing-husseina-ozigi-otaru.ppt
image-processing-husseina-ozigi-otaru.pptimage-processing-husseina-ozigi-otaru.ppt
image-processing-husseina-ozigi-otaru.ppt
 
K010236168
K010236168K010236168
K010236168
 
robio-2014-falquez
robio-2014-falquezrobio-2014-falquez
robio-2014-falquez
 
Visual Quality for both Images and Display of Systems by Visual Enhancement u...
Visual Quality for both Images and Display of Systems by Visual Enhancement u...Visual Quality for both Images and Display of Systems by Visual Enhancement u...
Visual Quality for both Images and Display of Systems by Visual Enhancement u...
 
Multiexposure Image Fusion
Multiexposure Image FusionMultiexposure Image Fusion
Multiexposure Image Fusion
 
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTIONEDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
 
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTIONEDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
EDGE DETECTION IN RADAR IMAGES USING WEIBULL DISTRIBUTION
 
Paper id 27201451
Paper id 27201451Paper id 27201451
Paper id 27201451
 
An automatic algorithm for object recognition and detection based on asift ke...
An automatic algorithm for object recognition and detection based on asift ke...An automatic algorithm for object recognition and detection based on asift ke...
An automatic algorithm for object recognition and detection based on asift ke...
 
MachineVision_Chapter5_Edge_Detection.pdf
MachineVision_Chapter5_Edge_Detection.pdfMachineVision_Chapter5_Edge_Detection.pdf
MachineVision_Chapter5_Edge_Detection.pdf
 

linkd

  • 1. Comparison of Gaussian Filtering and Bilateral Filtering on RGB Images Aprameyo Roy SC14B079 Avionics Nikunj Gupta SC14B105 Avionics 1 Abstract This report presents the implementation of Bilateral Filtering - a filter which is used for smoothening an image while conserving its edges. The comparison with other filters such as the Box and the Gaussian filters has been elucidated. There has been rigorous analysis of all the parameters of Bilateral Filtering and their effects on the test images with and without noise added to it. Finally an analysis was performed on the parallel and serial implementation of the Bilateral Filter and various factors such as speed and memory used were compared for both the implementations. 2 Introduction An image is a 2D array of pixels. Each of this pixel can be defined either by intensity(in case of Grayscale) or a 3D vector(in case of RGB colour). Blurring is used in pre-processing steps, such as removal of small details from an image prior to large object extraction. The shape of an object is due to its edges. So in blurring, we reduce the edge content in an image and try to make the transitions between different pixel intensities as smooth as possible. (a) Original Image (b) Image only with edges The concept of blurring involves making adjacent pixels look similar. So, the strategy which is employed by most of the blur filters is that of replacing a particular pixel by an average of its neighbouring pixels. The type of average which we will take is going to define different types of filters. Here, we would be comparing the results of three very basic but effective filters, namely, box filter, Gaussian filter and Bilateral filter. Also, the Bilateral filter has complex computations involved(basically because it uses two different filters). So the paper discusses an effective parallel implementation of this filter and compares its results with the normal implementation. 1
  • 2. 3 Box Filter Box(Mean) filtering is a simple, intuitive and easy to implement method of smoothing images, i.e. reducing the amount of intensity variation between one pixel and the next. The idea of box filtering is simply to replace each pixel value in an image with the mean (average) value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings (very different in intensity). Box filtering is based around a kernel, which represents the shape and size of the neighbourhood to be sampled when calculating the mean. The kernel used looks like a box, hence the name of the filter. Due to its property of using equal weights it can be implemented using a much simpler accumulation algorithm. The only degree of freedom in this filter is the window(kernel) size whose effect is seen later. The equation in effect is: BA[I]p = q∈S Bσ(p − q)Iq Here, BA[I]p is the result at pixel p, Bσ(p − q) is the box function, which basically depends on the distance between the two pixels(p and q) and Iq is the intensity at pixel q. Here the summation on pixel q goes over the entire kernel(window). As can be seen, the problem with such an approach is that it gives inappropriate blurring at the edges(i.e. wherever there is sudden change in intensity). Further, a single pixel with a very unrepresen- tative value can significantly affect the mean value of all the pixels in its neighborhood. Such a filter gives blocky results and may cause axis-aligned streaks. 3.1 Effect of Kernel(window) Size It can be seen that as the window size is increased, the results get worse, with image getting very blurry for window of size around 10. The common strategy to overcome these problems is the use of a window which has a smooth falloff. Hence, we introduce Gaussian filter which uses an isotropic(i.e. circular) window. 2
  • 3. 4 Gaussian Filter Gaussian filter blurs an image by implementing the Gaussian function. Here, g(x) has mean = 0 and variance = σ2 s . g(x) = 1√ 2πσ2 s e − x2 2σ2 s Since image is a 2D array, we’ll be using two dimensional Gaussian, which is the product of two such Gaussians, one per direction: g(x, y) = 1 2πσ2 s e − x2+y2 2σ2 s where x is the distance from the origin in the horizontal axis and y is the distance from the origin in the vertical axis. The subscript s in σs has been used to emphasize on the fact that this parameter con- trols the space over which the Gaussian function is spread. The effect of this parameter is discussed later. Mathematically, applying a Gaussian blur to an image is the same as convolving the image with a Gaussian function. Since the Fourier transform of a Gaussian is another Gaussian, applying a Gaussian filter has the effect of reducing the image’s high-frequency components, therefore, a Gaussian filter is a low pass filter. It takes “weighted average of pixels”, and hence, this technique is much more efficient than the box filter. The weights, in this case, is determined by the Gaussian function. The new pixel value is governed by the following transformation: GB[I]p = q∈S Gσs (||p − q||)Iq Here, Gσs (||p − q||) is the normalized Gaussian function with mean µ = 0 and variance = σ2 s . Therefore, the control parameters here are the window size and the sigma for the Gaussian function. Changing the two parameter values gives different results on the images. 4.1 Effect of Window Size Here σs = 4. It can be seen that Gaussian Filtering gives pretty good results, even when the window size is increased. There is not much difference in output images for window size 8 and 12 as can be seen. This 3
  • 4. is where the parameter σs plays a crucial role. Since σs(or its square, the variance) decides the area over which the Gaussian is spread, however large window is taken beyond a certain value, the result will be the same. Hence, the parameter σs gives some control so that the image doesn’t become too blurred and indistinguishable from the original image and most of the important information from the original image is still retained. 4.2 Effect of Spatial Parameter σs With the window size kept a constant(say 5) and σs varied, following results are obtained: The difference between the effect of window size and spatial parameter σs can be difficult to observe or even explain. There is just a subtle difference, which is more clear from the MATLAB code(Appendix B). Window size defines the area over which I’m currently focussing on, with distance between each pixel as the input. Whereas, σs defines the variance or the spread of the Gaussian over this window. Hence, the window is always a square, but the Gaussian function controls which pixels would actually contribute in averaging the pixel of interest. Large variance(σs) gives more spread of the Gaussian over the window, taking more pixels to average out the pixel of interest. It is observed that for certain σs, as window size is increased beyond a certain value, the filter won’t give a different output. This is because the spread of the Gaussian is fixed, so however large window is chosen, the output won’t be affected because of new far away pixels. If someone observes very closely around the eyes of the hawk in the picture, it can be seen that it is blurred(except when σs is very small). Filtering of the edges can remove important information from images, especially when the images being dealt with are related to weather or satellite data or something of the sort. Edges form the basic shape of an image(as explained in the Introduction) and if the edges are blurred, useful information which defines the image might get lost. Intuitively, it can be seen that if there is another parameter which can control the shape of the ker- nel(window), better results are expected. Bilateral Filtering is an example, where a third parameter(σr) 4
  • 5. is employed. Bilteral Filtering is discussed in the following sections. 5 Bilateral Filter The bilateral filter is a nonlinear filter that smooths a signal while preserving strong edges. As mentioned earlier, it is able to preserve edges because of the third parameter, σr which is called the Range Parameter. The technique is that it doesn’t average out the pixels around the edges and hence. the kernel shape depends on the image content(i.e. the pixels intensity). Another Gaussian function with variance σr is used, but the random variable here is the intensity(or RGB) difference between the current pixel and it’s neighbouring pixels. Same idea as the Gaussian filter is used, with the only difference now being my filter multiplied with another Gaussian factor. BF[I]p = q∈S Gσs (||p − q||)Gσr (|Ip − Iq|)Iq The first two factors are the same as defined in Gaussian filter. The additional factor Gσr takes dif- ference in intensity of the pixels as input, and accordingly gives weights to the output. Therefore, the combination of Gσs and Gσr considers effect of only those pixels which are close in space and in range. An additional normalization factor(Wp) is required to take care of the amplitude changes which happen due to the two Gaussians. Hence, the modified equation is: BF[I]p = 1 Wp q∈S Gσs (||p − q||)Gσr (|Ip − Iq|)Iq The effect of window size and σs are the same as observed in Gaussian filtering and won’t be discussed further. The main point of interest here is how the range parameter σr produces edge retention and its comparison with output of the Gaussian filter. 5
  • 6. 5.1 Effect of Range Parameter σr Following results are obtained for fixed values of window size(=5) and spatial parameter(σs = 2.5): Same effect as of varying the spatial parameter σs is observed. As σr increases, the image gets more blurred. But the important thing to note here is that the edges are retained, or the process atleast tries to retain those points which have sudden jump in pixel intensity. This result is further discussed when the Gaussian filter and Bilateral filter are compared. 6 Comparison of Gaussian Filtering and Bilateral Filtering The main between the two type of filters lies in one using an additional parameter(σr) to control the shape of the window. Keeping the window size and spatial parameter same for both the filters, output of the filters is taken and observed Here window size = 5 and σs = 3.5 . It can be observed that for σr = 0.5, bilateral filter is able to retain the edges as well(notice closely the beak and eyes). Gaussian filter causes blur to sharp edges as well, whereas depending on the value of range parameter(σr), good results can be obtained from Bilateral filtering in terms of edge retention. In case of Gaussian filter, only the spatial distance between the pixel matters. Even though this falls of gradually given some σs, it is not effective in taking into account the intensity difference between these pixels. In other words, the kernel shape is same everywhere which is nearly circular in 2 dimensions. On the other hand, Bilateral filter takes the intensity difference into account, converting it into Gaussian and is ultimately multiplied with the original filter to give different shaped kernels. One can make an obvious remark that when range parameter σr is infinity, the Bilateral filter becomes equal to the Gaussian filter. 6
  • 7. Effect of Gaussian Filtering and Bilateral Filtering on Noisy Images Common signal processing applications require removing noise from images or even other signals. The most common type of noise in the environment is the Gaussian noise(or it can be shown that large number of noises ultimately add up to form a gaussian noise according to Central Limit Theorem). Here performance of both Gaussian and Bilateral filtering on noisy images is observed. The MATLAB command imnoise is used to insert Gaussian noise of certain mean and variance to the image. Results of the two filters are shown: Both Bilateral and Gaussian filtering give good performance against noise. By varying the parameters of these filters, better results can be obtained. It is interesting to see that in Bilateral Filtering sharper edges are retained and thus better filtering is performed. 7 Parallel Implementation Of Bilateral Filter 7.1 Basic Introduction To General Purpose Graphics Processing Units We are in a time where we require very high computational ability from our processors and in just a few years the programmable graphics processor unit has evolved into very powerful computing workhorse. All of the programs which have been implemented have been highly optimized for a sequential run but the speeds of execution cannot match that of the program running in a massively parallel architecture. With multiple cores driven by very high memory bandwidth, today’s GPUs offer incredible resources for both graphics and non-graphics processing. 7
  • 8. The above architecture is extremely efficient in compute-intensive, highly parallel computation and that is exactly what image processing primarily needs. It sacrifices data caching and flow control features almost entirely and all of the transistors are devoted to processing and there is enormous amounts of brute computational power due to this. 7.1.1 CUDA by NVIDIATM We employ CUDA- Compute Unified Device Architecture , a recent hardware and software archi- tecture developed by NVIDIATM for issuing and managing computations on the GPU. 8
  • 9. The Programming Model is as follows: Here a kernel is a C function that, when called, is executed N times in parallel by N different CUDA threads, as opposed to only once like regular C functions.This is the basic idea behind parallelizing a process. The hierarchy is as follows : GRID consists of multiple Blocks and a block consists of multiple Threads. The threads per block and the blocks per grid have a maximum number which can be allocated according to the device which is being used. The device is used to refer to the GPU whereas the HOST is the CPU. The CPU is used to control the input and initialization of the GPU and then it is used for the computation and again returns the data back to the CPU. This is the fundamental which is used in our project to make the bilateral filtering operation to be much more computationally effective. The other basic fundamental includes the cudaMemcpy() command which is used to transfer data from the HOST memory to the DEVICE memory or vice-versa. This is the only Achilles heel in the entire process of parallel computing as this instruction takes time , but if the process is computationally intensive then the time taken for the transfer of data is insignificant to the amount of time taken to compute , and thus the true power of multi core processors are visible. 9
  • 10. 7.1.2 Current Specifications GPU Model: Nvidia - GeForce GTX- 980m Dedicated Video Memory : 8192 MB - GDDR5 CUDA cores : 1536 Memory Bandwidth : 160.32 GB/sec Memory Data Rate :5010 MHz Graphics Clock: 1038 MHz CPU Model : Intel i7 6700 Memory : 8 GB 2133 MHz DDR4 Clock Speed : 3.40 GHz 7.2 Parallel Implementation Of Bilateral Filtering Filtering images can often be a highly process where each pixel in the image is affected by a given filter. Filtering each pixel is an operation which is independent of the application of the filter to other neighbor pixels. Since an image consists of a very large number pixels this leads it to be a good candidate for parallelization. Bilateral filtering is in itself a very computationally heavy process and requires more time than any standard filtering technique. Bilateral Filtering as discussed before is an edge preserving and smoothen- ing filter which is twice as computationally costly as the Gaussian filter. 10
  • 11. A sequential implementation of the filter allows Bilateral Filtering on each pixel on the image, using a kernel radius/window to define the size of local neighborhood.A basic parallelization can be done by taking the code for the individual pixel and use that as a basis for a kernel. This kernel is then launched with parameters which generates a thread for each pixel in the image. The pseudo-code given below would resemble what is used to call a kernel , where gridSize and blockSize are determined by image height and width. d_bilateral_filter<<< gridSize, blockSize>>>(res, width, height, e_d, radius); 7.3 Performance Analysis We now analyze the massive boost in performance which is achieved due to the import of the Bilateral Filter program from a sequential style to a parallel mode. The following is the result obtained from the NSIGHTTM debugger’s performance analysis tool for the GPU. The program has been run for ”hawk.bmp” and a window of 5 with sigma = 2.5 and delta = .5. 7.3.1 CPU AND GPU Figure 2: Performance Analysis Summary Figure 3: Utilization Of CPU cores Here we can see that the complete duration taken by the program to execute completely is 4.56 seconds which is still significantly less than what a single threaded CPU would have taken. However the major chunk of this time has been eaten away by secondary processes like the debugger , wireless services and system processes , however the time what we need to focus on is the time taken by the GPU to compute and also the copying of data from HOST to DEVICE and vice-versa. 7.3.2 GPU Here we see that the duration of the computation done by the GPU only requires a mere 1.167 seconds to complete calculation. This is extremely fast and is slowed down further due to the transport of infor- mation from DEVICE and HOST. Further improvement in performance with respect to serial execution is visible when the image to be filtered has higher resolution ex. 1920x1080 or more. 11
  • 12. Figure 4: Performance Analysis Summary(GPU) Figure 5: Function Calls And Thread Usage) 8 References http://dsp.stackexchange.com/questions/6289/understanding-the-parameters-for-a-bilateral-filter TOMASI, C. and MANDUCHI, R. 1998. Bilateral Filtering for Gray and Color Images. In Proceedings of the International Conference on Computer Vision http://www.nvidia.com/object/cuda-home-new.html. http://en.wikipedia.org/wiki/Gaussian-blur Bilateral Filtering with CUDA Lasse Kljgaard Staal http://people.csail.mit.edu/sparis/siggraph07-course/ 12