By:
Nimai Chand Das Adhikari
Indian Institute of Space Science and Technology
Guide:
Dr. Meera Viswavandya (CET)
Dr Rama Rao (IIST)
Image Stitching for Panorama View
Introduction
 Image Stitching is basically combining two or
more different images to form a single panorama
view.
 Panorama is derived from a Greek word,
Pan=Everything and Horama=to view.
 Camera has a field view of 50X35 degrees,
whereas human eye has 200X135 degrees.
Simple Image Stitching Code
a= imread('left.jpg'); %read the left part of the
image
b=imread('right.jpg'); %read the right part of the
image
sa= size(a) %get the size of the left image
sb = size(b)%get the size of the left image
b= imresize(b,[sa(1) sa(2)]); %now resize 'b' as per
the size of 'a' in order to get perfect sized image
c= [a b]; % club the image a & b into another new
image after making their size same
%note the semicolon in the above line inside
bracket
imshow(c) % show the image
Basic Steps:
Image Acquisition
Image Registration
Image Blending
Image Acquisition
 This is the first step
 It is the action of retrieving an image from some
sources.
 This can be done using a handheld camera.
Features detection and Matching
 This is considered to be the main step in the
image stitching process.
 Features can be defined as the elements in the
two or more input images.
There are many algorithms in literature SURF,PCA-
SIFT, SIFT, HOG etc. In this we have used SIFT.
Scale Invariant Feature Transform
SIFT
To find the below pictures from this
picture:
Let Us Look Into Some Examples
Figure 1 Figure 2
Figure 3 Figure 4
Result!!!!
What the features behave????
 Scale
 Rotation
 Illumination
 Viewpoint
Algorithm…
 Constructing a scale space
 LoG Approximation
 Finding keypoints
 Get rid of bad key points
 Assigning an orientation to the keypoints
 Generate SIFT features
1. Scale Space
Gaussian Blur
 A Gaussian blur (also known as Gaussian
smoothing) is the result of blurring an image by
a Gaussian function.
 It is a widely used effect in graphics software,
typically to reduce image noise and reduce detail.
 Gaussian smoothing is also used as a pre-
processing stage in computer vision algorithms in
order to enhance image structures at different
scales
Example
Additional..
 How to make the Gaussian Blur?
Ans : It is same as convolution of the original image
with the Gaussian Function.
1 dimension 2 dimension
Why Gaussian Blur is used?
Effect of Gaussian Blurring..
 https://upload.wikimedia.org/wikipedia/commons/
7/73/Edge_Image.gif
Scale Spaces in SIFT
Octaves and Scales…
 Images seen in the previous slide with the same
size(vertical) fall in the same Octave.
 Each octave has different images which is the
result of the different standard deviation value or
the range of blurring .
 The number of octaves and scale depends on the
size of the original image.
 Mostly 4 octaves and 5 blur levels are ideal for
the algorithm.
Blurring
 Mathematically, "blurring" is referred to as the
convolution of the Gaussian operator and the
image.
 Gaussian blur has a particular expression or
"operator" that is applied to each pixel. What
results is the blurred image.
Cont..
2. LoG Approximations
 Now we use those blurred images to generate
another set of images, the Difference of
Gaussians (DoG).
 These DoG images are a great for finding out
interesting key points in the image.
Laplacian of Gaussian (LoG)
Steps:
 You take an image, and blur it a little.
 You calculate second order derivatives on it (or,
the "laplacian").
 This locates edges and corners on the image.
Note: These edges and corners are good for
finding keypoints.
The Con…
Benefits
 Just the Laplacian of Gaussian images are not
scale invariant.
 That is, they depend on the amount of blur you
do. This is because of the Gaussian expression.
 If the LoG is represented by:
Then the scale invariant of LoG :
Example:
3. Finding Keypoints
Finding the keypoints is a two part process:
 Locate maxima/minima in DoG images
 Find subpixel maxima/minima
Locate maxima/minima in DoG
images
4. Getting rid of low contrast
keypoints
 Removing low contrast features:
If the magnitude of the intensity (i.e., without sign)
at the current pixel in the DoG image (that is being
checked for minima/maxima) is less than a certain
value, it is rejected.
Contd.
 Removing edges:
The idea is to calculate two gradients at the
keypoint. Both perpendicular to each other. Based
on the image around the keypoint, three
possibilities exist. The image around the keypoint
can be:
Visual Explanation:
5. Keypoint Orientations
 The idea is to collect gradient directions and
magnitudes around each keypoint.
 Then we figure out the most prominent
orientation(s) in that region.
 And we assign this orientation(s) to the keypoint.
The Details:
Gradient magnitudes and
orientations formulae:
Histogram
6. Generating a Feature
 This is to make every keypoint a unique.
contd.
Final Panorama
References:
 A technical Analysis of Image Stitching Algorithm
(Pranoti Kale and KR Singh),IJCSIT,2015,284-
288
 Implementation of HDR panorama stitching
algorithm (Piotr Ostiak),ICGMS
 http://www.aishack.in/tutorials/sift-scale-invariant-
feature-transform-keypoints/
Thank you!!!!

Image Stitching for Panorama View

  • 1.
    By: Nimai Chand DasAdhikari Indian Institute of Space Science and Technology Guide: Dr. Meera Viswavandya (CET) Dr Rama Rao (IIST) Image Stitching for Panorama View
  • 2.
    Introduction  Image Stitchingis basically combining two or more different images to form a single panorama view.  Panorama is derived from a Greek word, Pan=Everything and Horama=to view.  Camera has a field view of 50X35 degrees, whereas human eye has 200X135 degrees.
  • 3.
    Simple Image StitchingCode a= imread('left.jpg'); %read the left part of the image b=imread('right.jpg'); %read the right part of the image sa= size(a) %get the size of the left image sb = size(b)%get the size of the left image b= imresize(b,[sa(1) sa(2)]); %now resize 'b' as per the size of 'a' in order to get perfect sized image c= [a b]; % club the image a & b into another new image after making their size same %note the semicolon in the above line inside bracket imshow(c) % show the image
  • 6.
    Basic Steps: Image Acquisition ImageRegistration Image Blending
  • 7.
    Image Acquisition  Thisis the first step  It is the action of retrieving an image from some sources.  This can be done using a handheld camera.
  • 8.
    Features detection andMatching  This is considered to be the main step in the image stitching process.  Features can be defined as the elements in the two or more input images. There are many algorithms in literature SURF,PCA- SIFT, SIFT, HOG etc. In this we have used SIFT.
  • 9.
  • 10.
    To find thebelow pictures from this picture:
  • 11.
    Let Us LookInto Some Examples Figure 1 Figure 2 Figure 3 Figure 4
  • 12.
  • 13.
    What the featuresbehave????  Scale  Rotation  Illumination  Viewpoint
  • 14.
    Algorithm…  Constructing ascale space  LoG Approximation  Finding keypoints  Get rid of bad key points  Assigning an orientation to the keypoints  Generate SIFT features
  • 15.
  • 16.
    Gaussian Blur  AGaussian blur (also known as Gaussian smoothing) is the result of blurring an image by a Gaussian function.  It is a widely used effect in graphics software, typically to reduce image noise and reduce detail.  Gaussian smoothing is also used as a pre- processing stage in computer vision algorithms in order to enhance image structures at different scales
  • 17.
  • 18.
    Additional..  How tomake the Gaussian Blur? Ans : It is same as convolution of the original image with the Gaussian Function. 1 dimension 2 dimension
  • 19.
  • 20.
    Effect of GaussianBlurring..  https://upload.wikimedia.org/wikipedia/commons/ 7/73/Edge_Image.gif
  • 21.
  • 22.
    Octaves and Scales… Images seen in the previous slide with the same size(vertical) fall in the same Octave.  Each octave has different images which is the result of the different standard deviation value or the range of blurring .  The number of octaves and scale depends on the size of the original image.  Mostly 4 octaves and 5 blur levels are ideal for the algorithm.
  • 23.
    Blurring  Mathematically, "blurring"is referred to as the convolution of the Gaussian operator and the image.  Gaussian blur has a particular expression or "operator" that is applied to each pixel. What results is the blurred image.
  • 24.
  • 25.
    2. LoG Approximations Now we use those blurred images to generate another set of images, the Difference of Gaussians (DoG).  These DoG images are a great for finding out interesting key points in the image.
  • 26.
    Laplacian of Gaussian(LoG) Steps:  You take an image, and blur it a little.  You calculate second order derivatives on it (or, the "laplacian").  This locates edges and corners on the image. Note: These edges and corners are good for finding keypoints.
  • 27.
  • 28.
    Benefits  Just theLaplacian of Gaussian images are not scale invariant.  That is, they depend on the amount of blur you do. This is because of the Gaussian expression.  If the LoG is represented by: Then the scale invariant of LoG :
  • 29.
  • 30.
    3. Finding Keypoints Findingthe keypoints is a two part process:  Locate maxima/minima in DoG images  Find subpixel maxima/minima
  • 31.
  • 33.
    4. Getting ridof low contrast keypoints  Removing low contrast features: If the magnitude of the intensity (i.e., without sign) at the current pixel in the DoG image (that is being checked for minima/maxima) is less than a certain value, it is rejected.
  • 34.
    Contd.  Removing edges: Theidea is to calculate two gradients at the keypoint. Both perpendicular to each other. Based on the image around the keypoint, three possibilities exist. The image around the keypoint can be:
  • 35.
  • 36.
    5. Keypoint Orientations The idea is to collect gradient directions and magnitudes around each keypoint.  Then we figure out the most prominent orientation(s) in that region.  And we assign this orientation(s) to the keypoint.
  • 38.
  • 39.
  • 40.
  • 41.
    6. Generating aFeature  This is to make every keypoint a unique.
  • 42.
  • 46.
  • 47.
    References:  A technicalAnalysis of Image Stitching Algorithm (Pranoti Kale and KR Singh),IJCSIT,2015,284- 288  Implementation of HDR panorama stitching algorithm (Piotr Ostiak),ICGMS  http://www.aishack.in/tutorials/sift-scale-invariant- feature-transform-keypoints/
  • 48.

Editor's Notes

  • #16 Think that there is a tree and we want to focus that. Then while focusing on it, we have to get rid of leaves, twigs and other things. Remember while getting rid of the additional information, no false information should be introduced. This can be done using the Gaussian Blur.
  • #19 This is also known as a two-dimensional Weierstrass transform.
  • #20 Gaussian blur can be used in order to obtain a smooth grayscale digital image of a halftone print
  • #21 Gaussian smoothing is commonly used with edge detection. Most edge-detection algorithms are sensitive to noise; the 2-D Laplacian filter, built from a discretization of the Laplace operator, is highly sensitive to noisy environments. Using a Gaussian Blur filter before edge detection aims to reduce the level of noise in the image, which improves the result of the following edge-detection algorithm. This approach is commonly referred to as Laplacian of Gaussian, or LoG filtering.
  • #22 SIFT takes scale spaces to the next level. We take the original image, and generate progressively blurred out images. Then, we resize the original image to half size. And we generate blurred out images again. And we keep repeating.
  • #23 For the first octave: If the original image is doubled in size and antialiased a bit (by blurring it) then the algorithm produces more four times more keypoints. The more the keypoints, the better!
  • #25 The amount of blurring in each image is important. It goes like this. Assume the amount of blur in a particular image is σ. Then, the amount of blur in the next image will be k*σ. Here k is whatever constant you choose. This is a table of σ's for my current example. See how each σ differs by a factor sqrt(2) from the previous one.
  • #27 But the second order derivative is extremely sensitive to noise. The blur smoothes it out the noise and stabilizes the second order derivative. This is the actual theory behind it. The problem is, calculating all those second order derivatives is computationally intensive. So we cheat a bit.
  • #28 To generate Laplacian of Guassian images quickly, we use the scale space. We calculate the difference between two consecutive scales. Or, the Difference of Gaussians. These Difference of Gaussian images are approximately equivalent to the Laplacian of Gaussian. These DoG images comes with another little goodie. These approximations are also "scale invariant". 
  • #29 See the σ2 in the demonimator? That's the scale. If we somehow get rid of it, we'll have true scale independence. But all these complexities are taken care of by the Difference of Gaussian operation. The resultant images after the DoG operation are already multiplied by the σ2. 
  • #31 Up till now, we have generated a scale space and used the scale space to calculate the Difference of Gaussians. Those are then used to calculate Laplacian of Gaussian approximations that is scale invariant. I told you that they produce great key points. Here it is done by:
  • #33 The author of SIFT recommends generating two such extrema images. So, you need exactly 4 DoG images. To generate 4 DoG images, you need 5 Gaussian blurred images. Hence the 5 level of blurs in each octave. In the image, I've shown just one octave. This is done for all octaves. Also, this image just shows the first part of keypoint detection. The Taylor series part has been skipped.
  • #34 Key points generated in the previous step produce a lot of key points. Some of them lie along an edge, or they don't have enough contrast. In both cases, they are not useful as features. So we get rid of them. For low contrast features, we simply check their intensities. 1.
  • #35 Corners are great keypoints. So we want just corners. If both gradients are big enough, we let it pass as a key point. Otherwise, it is rejected. Mathematically, this is achieved by the Hessian Matrix. Using this matrix, you can easily check if a point is a corner or not.
  • #36 Both extrema images go through the two tests: the contrast test and the edge test. They reject a few keypoints (sometimes a lot) and thus, we're left with a lower number of keypoints to deal with.
  • #37 This orientation provides rotation invariance. The more invariance you have the better it is.
  • #38 The size of the "orientation collection region" around the keypoint depends on it's scale. The bigger the scale, the bigger the collection region.
  • #41 Magnitudes Saw the gradient magnitude image above? In SIFT, you need to blur it by an amount of 1.5*sigma. Size of the window The window size, or the "orientation collection region", is equal to the size of the kernel for Gaussian Blur of amount 1.5*sigma.
  • #42 Till now we have scale and rotation invariants, now we will make the fingerprints. i.e if we have eye as a keypoint then we will assign or make it something that it is unique and can be identified and distinguished from ear, nose etc.
  • #43 Within each 4x4 window, gradient magnitudes and orientations are calculated. These orientations are put into an 8 bin histogram. Any gradient orientation in the range 0-44 degrees add to the first bin. 45-89 add to the next bin. Unlike the past, the amount added also depends on the distance from the keypoint. So gradients that are far away from the keypoint will add smaller values to the histogram. This is done using a "gaussian weighting function". This function simply generates a gradient (it's like a 2D bell curve). You multiple it with the magnitude of orientations, and you get a weighted thingy. The farther away, the lesser the magnutide.